diff --git a/lib/screens/onboarding_git_url.dart b/lib/screens/onboarding_git_url.dart index 2b529ad7..48bf948f 100644 --- a/lib/screens/onboarding_git_url.dart +++ b/lib/screens/onboarding_git_url.dart @@ -77,19 +77,55 @@ class OnBoardingGitUrlState extends State { child: inputForm, ), SizedBox(height: 8.0), - SizedBox( - width: double.infinity, - child: RaisedButton( - child: Text( - "Next", - textAlign: TextAlign.center, - style: Theme.of(context).textTheme.button, - ), - color: Theme.of(context).primaryColor, - onPressed: formSubmitted, - ), - ) + OnBoardingButton( + text: "Next", + onPressed: formSubmitted, + ), ], ); } } + +class OnBoardingButton extends StatelessWidget { + final Function onPressed; + final String text; + final String iconUrl; + + OnBoardingButton({ + @required this.text, + @required this.onPressed, + this.iconUrl, + }); + + @override + Widget build(BuildContext context) { + if (iconUrl == null) { + return SizedBox( + width: double.infinity, + child: RaisedButton( + child: Text( + text, + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.button, + ), + color: Theme.of(context).primaryColor, + onPressed: onPressed, + ), + ); + } else { + return SizedBox( + width: double.infinity, + child: RaisedButton.icon( + label: Text( + text, + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.button, + ), + icon: Image.asset(iconUrl, width: 32, height: 32), + color: Theme.of(context).primaryColor, + onPressed: onPressed, + ), + ); + } + } +} diff --git a/lib/screens/onboarding_screens.dart b/lib/screens/onboarding_screens.dart index 9ebaee12..3fe17d46 100644 --- a/lib/screens/onboarding_screens.dart +++ b/lib/screens/onboarding_screens.dart @@ -336,58 +336,34 @@ class OnBoardingCreateRepo extends StatelessWidget { style: Theme.of(context).textTheme.headline, ), SizedBox(height: 16.0), - SizedBox( - width: double.infinity, - child: RaisedButton.icon( - label: Text( - "GitHub", - textAlign: TextAlign.center, - style: Theme.of(context).textTheme.button, - ), - icon: Image.asset( - 'assets/icon/github-icon.png', - width: 32, - height: 32, - ), - color: Theme.of(context).primaryColor, - onPressed: () async { - try { - await launch("https://github.com/new"); - } catch (err, stack) { - // FIXME: Error handling? - print(err); - print(stack); - } - onDone(); - }, - ), + OnBoardingButton( + text: "GitHub", + iconUrl: 'assets/icon/github-icon.png', + onPressed: () async { + try { + await launch("https://github.com/new"); + } catch (err, stack) { + // FIXME: Error handling? + print(err); + print(stack); + } + onDone(); + }, ), SizedBox(height: 8.0), - SizedBox( - width: double.infinity, - child: RaisedButton.icon( - label: Text( - "GitLab", - textAlign: TextAlign.center, - style: Theme.of(context).textTheme.button, - ), - icon: Image.asset( - 'assets/icon/gitlab-icon.png', - width: 32, - height: 32, - ), - color: Theme.of(context).primaryColor, - onPressed: () async { - try { - await launch("https://gitlab.com/projects/new"); - } catch (err, stack) { - // FIXME: Error handling? - print(err); - print(stack); - } - onDone(); - }, - ), + OnBoardingButton( + text: "GitLab", + iconUrl: 'assets/icon/gitlab-icon.png', + onPressed: () async { + try { + await launch("https://gitlab.com/projects/new"); + } catch (err, stack) { + // FIXME: Error handling? + print(err); + print(stack); + } + onDone(); + }, ), ], mainAxisAlignment: MainAxisAlignment.center,