diff --git a/lib/screens/githostsetup_screens.dart b/lib/screens/githostsetup_screens.dart index 3ad84fd2..41fb9142 100644 --- a/lib/screens/githostsetup_screens.dart +++ b/lib/screens/githostsetup_screens.dart @@ -14,6 +14,7 @@ import 'githostsetup_autoconfigure.dart'; import 'githostsetup_button.dart'; import 'githostsetup_clone.dart'; import 'githostsetup_clone_url.dart'; +import 'githostsetup_sshkey.dart'; class GitHostSetupScreen extends StatefulWidget { final Function onCompletedFunction; @@ -536,113 +537,3 @@ class GitHostAutoConfigureChoicePage extends StatelessWidget { ); } } - -class GitHostSetupSshKey extends StatelessWidget { - final Function doneFunction; - final Function copyKeyFunction; - final String publicKey; - - final Function openDeployKeyPage; - final bool canOpenDeployKeyPage; - - GitHostSetupSshKey({ - @required this.doneFunction, - @required this.copyKeyFunction, - @required this.openDeployKeyPage, - @required this.publicKey, - @required this.canOpenDeployKeyPage, - }); - - @override - Widget build(BuildContext context) { - Widget copyAndDepoyWidget; - Widget cloneButton; - if (this.publicKey.isEmpty) { - copyAndDepoyWidget = Container(); - cloneButton = Container(); - } else { - cloneButton = GitHostSetupButton( - text: "Clone Repo", - onPressed: this.doneFunction, - ); - - if (canOpenDeployKeyPage) { - copyAndDepoyWidget = Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: RaisedButton( - child: Text( - "Copy Key", - textAlign: TextAlign.center, - style: Theme.of(context).textTheme.button, - ), - color: Theme.of(context).primaryColor, - onPressed: copyKeyFunction, - ), - ), - SizedBox(width: 8.0), - Expanded( - child: RaisedButton( - child: Text( - "Open Deploy Key Webpage", - textAlign: TextAlign.center, - style: Theme.of(context).textTheme.button, - ), - color: Theme.of(context).primaryColor, - onPressed: openDeployKeyPage, - ), - ), - ], - ); - } else { - copyAndDepoyWidget = GitHostSetupButton( - text: "Copy Key", - onPressed: this.copyKeyFunction, - ); - } - } - - String publicKeyStr = ""; - if (this.publicKey == null || this.publicKey.isEmpty) { - publicKeyStr = "Generating ..."; - } else { - publicKeyStr = this.publicKey; - } - - var publicKeyWidget = SizedBox( - width: double.infinity, - height: 160.0, - child: Container( - color: Theme.of(context).buttonColor, - child: SingleChildScrollView( - child: Container( - padding: const EdgeInsets.all(8.0), - child: Text( - publicKeyStr, - textAlign: TextAlign.left, - maxLines: null, - style: Theme.of(context).textTheme.body1, - ), - ), - ), - ), - ); - - return Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Deploy Public Key', - style: Theme.of(context).textTheme.headline, - ), - SizedBox(height: 16.0), - publicKeyWidget, - SizedBox(height: 8.0), - copyAndDepoyWidget, - cloneButton, - ], - ); - } -} diff --git a/lib/screens/githostsetup_sshkey.dart b/lib/screens/githostsetup_sshkey.dart new file mode 100644 index 00000000..3b89d2b5 --- /dev/null +++ b/lib/screens/githostsetup_sshkey.dart @@ -0,0 +1,113 @@ +import 'package:flutter/material.dart'; + +import 'githostsetup_button.dart'; + +class GitHostSetupSshKey extends StatelessWidget { + final Function doneFunction; + final Function copyKeyFunction; + final String publicKey; + + final Function openDeployKeyPage; + final bool canOpenDeployKeyPage; + + GitHostSetupSshKey({ + @required this.doneFunction, + @required this.copyKeyFunction, + @required this.openDeployKeyPage, + @required this.publicKey, + @required this.canOpenDeployKeyPage, + }); + + @override + Widget build(BuildContext context) { + Widget copyAndDepoyWidget; + Widget cloneButton; + if (this.publicKey.isEmpty) { + copyAndDepoyWidget = Container(); + cloneButton = Container(); + } else { + cloneButton = GitHostSetupButton( + text: "Clone Repo", + onPressed: this.doneFunction, + ); + + if (canOpenDeployKeyPage) { + copyAndDepoyWidget = Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: RaisedButton( + child: Text( + "Copy Key", + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.button, + ), + color: Theme.of(context).primaryColor, + onPressed: copyKeyFunction, + ), + ), + SizedBox(width: 8.0), + Expanded( + child: RaisedButton( + child: Text( + "Open Deploy Key Webpage", + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.button, + ), + color: Theme.of(context).primaryColor, + onPressed: openDeployKeyPage, + ), + ), + ], + ); + } else { + copyAndDepoyWidget = GitHostSetupButton( + text: "Copy Key", + onPressed: this.copyKeyFunction, + ); + } + } + + String publicKeyStr = ""; + if (this.publicKey == null || this.publicKey.isEmpty) { + publicKeyStr = "Generating ..."; + } else { + publicKeyStr = this.publicKey; + } + + var publicKeyWidget = SizedBox( + width: double.infinity, + height: 160.0, + child: Container( + color: Theme.of(context).buttonColor, + child: SingleChildScrollView( + child: Container( + padding: const EdgeInsets.all(8.0), + child: Text( + publicKeyStr, + textAlign: TextAlign.left, + maxLines: null, + style: Theme.of(context).textTheme.body1, + ), + ), + ), + ), + ); + + return Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Deploy Public Key', + style: Theme.of(context).textTheme.headline, + ), + SizedBox(height: 16.0), + publicKeyWidget, + SizedBox(height: 8.0), + copyAndDepoyWidget, + cloneButton, + ], + ); + } +}