diff --git a/lib/screens/onboarding_screens.dart b/lib/screens/onboarding_screens.dart index 351b27e6..80905da6 100644 --- a/lib/screens/onboarding_screens.dart +++ b/lib/screens/onboarding_screens.dart @@ -22,6 +22,8 @@ class OnBoardingScreenState extends State { var pageController = PageController(); final GlobalKey _scaffoldKey = new GlobalKey(); + String publicKey = "Generating ..."; + @override Widget build(BuildContext context) { var pageCount = 1; @@ -45,6 +47,7 @@ class OnBoardingScreenState extends State { SharedPreferences.getInstance().then((SharedPreferences pref) { pref.setString("sshCloneUrl", sshUrl); + this._generateSshKey(); }); }); } @@ -57,7 +60,7 @@ class OnBoardingScreenState extends State { curve: Curves.easeIn, ); }, - scaffoldKey: _scaffoldKey, + publicKey: publicKey, ); } @@ -92,6 +95,22 @@ class OnBoardingScreenState extends State { this._pageSshKeyDone = true; }); } + + void _generateSshKey() { + generateSSHKeys(comment: "GitJournal").then((String _publicKey) { + setState(() { + print("Changing the state"); + publicKey = _publicKey; + + Clipboard.setData(ClipboardData(text: publicKey)); + var text = "Public Key copied to Clipboard"; + this + ._scaffoldKey + .currentState + .showSnackBar(new SnackBar(content: new Text(text))); + }); + }); + } } class OnBoardingGitUrl extends StatefulWidget { @@ -184,42 +203,15 @@ class OnBoardingGitUrlState extends State { } } -class OnBoardingSshKey extends StatefulWidget { +class OnBoardingSshKey extends StatelessWidget { final Function doneFunction; - final GlobalKey scaffoldKey; + final String publicKey; OnBoardingSshKey({ @required this.doneFunction, - @required this.scaffoldKey, + @required this.publicKey, }); - @override - OnBoardingSshKeyState createState() { - return new OnBoardingSshKeyState(); - } -} - -class OnBoardingSshKeyState extends State { - String publicKey = "Generating ..."; - - void initState() { - super.initState(); - generateSSHKeys(comment: "GitJournal").then((String _publicKey) { - setState(() { - print("Changing the state"); - publicKey = _publicKey; - - Clipboard.setData(ClipboardData(text: publicKey)); - var text = "Public Key copied to Clipboard"; - this - .widget - .scaffoldKey - .currentState - .showSnackBar(new SnackBar(content: new Text(text))); - }); - }); - } - @override Widget build(BuildContext context) { return Column( @@ -239,7 +231,7 @@ class OnBoardingSshKeyState extends State { ), RaisedButton( child: Text("Start Clone"), - onPressed: this.widget.doneFunction, + onPressed: this.doneFunction, ) ], );