Closed Solido closed 7 years ago
Thanks! Good point. In my project I do use a widget to navigate to another page. I'll add that right away. A name constructor would be fine?
🤣 so I don't think I can integrate it in the Circle Widget. In my project I add it to the main page logic like this:
class StartPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => new _StartPageState();
}
class _StartPageState extends State<StartPage> {
final PageController controller = new PageController();
Stack rootWidget;
bool showStart = false;
int previousPage = 0;
@override
Widget build(BuildContext context) {
rootWidget = createPages();
controller.addListener(pagerListener);
return new Scaffold(
body: new Container(
padding: new EdgeInsets.only(top: 16.0,),
decoration: new BoxDecoration(
color: primaryColor
),
child: rootWidget,
),
);
}
Stack createPages() {
var pageList = <StartPageItem>[
new StartPageItem("assets/ic_info_01.png"),
new StartPageItem("assets/ic_info_02.png"),
new StartPageItem("assets/ic_info_03.png"),
new StartPageItem("assets/ic_info_04.png"),
new StartPageItem("assets/ic_info_05.png"),
new StartPageItem("assets/ic_info_06.png"),
new StartPageItem("assets/ic_info_07.png"),
new StartPageItem("assets/ic_info_08.png"),
];
var childrenList = <Widget>[
new PageView.builder(
controller: controller,
itemCount: pageList.length,
itemBuilder: (_, int i) => pageList[i],
),
new Container(
margin: new EdgeInsets.only(
top: 16.0,
bottom: 16.0,
),
child: new CircleIndicator(
controller, pageList.length, 3.0,
Colors.white70, Colors.white),
),
];
if (showStart) {
childrenList.add(
new Container(
alignment: FractionalOffset.bottomRight,
margin: new EdgeInsets.all(16.0),
child: new GestureDetector(
onTap: startApp,
child: new Text("START",
style: Theme
.of(context)
.textTheme
.body1
.copyWith(
color: Colors.white,
fontFamily: "DancingScript-Regular",
),
),
),
),
);
}
return new Stack(
alignment: FractionalOffset.bottomCenter,
children: childrenList,
);
}
void pagerListener() {
setState(() => showStart = controller.page == 7);
}
void startApp() {
Navigator.popAndPushNamed(context, HomePage.routeName);
}
}
I guess you can provide the widget like you do now but also a global page wrapper
Something like new IntroductionView and the constructor take the PageList and the final action as parameters
ooo, nice, so you only need to provide the pages, ok
new CircleIntroduction( <Widget>[], onComplete => // Fade or navigate somewhere else )
perfect
Done, you can check it now.
Tested and it works great 👍
Can you close this issue?
I've already integrated it in my project. I miss a next button to the right to move from screen to screen. Also when on the last screen the label and action can change to finish/complete event listener so we can close the presentation view. What you think about it ?