OnBoardingScreens: Do not let us skip screens

This requires us to dynamically generate the screens based on if we have
completed the screen or not.
This commit is contained in:
Vishesh Handa
2019-01-11 18:42:26 +01:00
parent fe4f6effe7
commit 839da00307

View File

@ -16,37 +16,58 @@ class OnBoardingScreen extends StatefulWidget {
}
class OnBoardingScreenState extends State<OnBoardingScreen> {
var _pageInputUrlDone = false;
var _pageSshKeyDone = false;
var pageController = PageController();
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
var pageView = PageView(
controller: pageController,
children: <Widget>[
OnBoardingGitUrl(doneFunction: (String sshUrl) {
pageController.nextPage(
duration: Duration(milliseconds: 200),
curve: Curves.easeIn,
);
var pageCount = 1;
if (_pageInputUrlDone) {
pageCount++;
}
if (_pageSshKeyDone) {
pageCount++;
}
SharedPreferences.getInstance().then((SharedPreferences pref) {
pref.setString("sshCloneUrl", sshUrl);
});
}),
OnBoardingSshKey(
doneFunction: () {
var pageView = PageView.builder(
controller: pageController,
itemBuilder: (BuildContext context, int pos) {
if (pos == 0) {
return OnBoardingGitUrl(doneFunction: (String sshUrl) {
setPageInputUrlDone();
pageController.nextPage(
duration: Duration(milliseconds: 200),
curve: Curves.easeIn,
);
},
scaffoldKey: _scaffoldKey,
),
OnBoardingGitClone(
doneFunction: this.widget.onBoardingCompletedFunction,
),
],
SharedPreferences.getInstance().then((SharedPreferences pref) {
pref.setString("sshCloneUrl", sshUrl);
});
});
}
if (pos == 1) {
return OnBoardingSshKey(
doneFunction: () {
setPageSshKeyDone();
pageController.nextPage(
duration: Duration(milliseconds: 200),
curve: Curves.easeIn,
);
},
scaffoldKey: _scaffoldKey,
);
}
if (pos == 2) {
return OnBoardingGitClone(
doneFunction: this.widget.onBoardingCompletedFunction,
);
}
},
itemCount: pageCount,
);
return new Scaffold(
@ -59,6 +80,18 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
),
);
}
void setPageInputUrlDone() {
setState(() {
this._pageInputUrlDone = true;
});
}
void setPageSshKeyDone() {
setState(() {
this._pageSshKeyDone = true;
});
}
}
class OnBoardingGitUrl extends StatefulWidget {