From 5452fc0a78223494925e7b52c76d7aadc412747b Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Wed, 13 Feb 2019 21:02:33 +0100 Subject: [PATCH] GitHostSetup: Automatically open the correct url This is a behaviour that got lost during the refactor. --- lib/apis/githost_factory.dart | 1 + lib/screens/githostsetup_screens.dart | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/apis/githost_factory.dart b/lib/apis/githost_factory.dart index b7aef005..b5c8d0bf 100644 --- a/lib/apis/githost_factory.dart +++ b/lib/apis/githost_factory.dart @@ -5,6 +5,7 @@ import 'gitlab.dart'; export 'githost.dart'; enum GitHostType { + Unknown, GitHub, GitLab, Custom, diff --git a/lib/screens/githostsetup_screens.dart b/lib/screens/githostsetup_screens.dart index 1d073ce7..6994068e 100644 --- a/lib/screens/githostsetup_screens.dart +++ b/lib/screens/githostsetup_screens.dart @@ -38,7 +38,7 @@ class GitHostSetupScreenState extends State { PageChoice2.Unknown, ]; - GitHostType _gitHostType; + GitHostType _gitHostType = GitHostType.Unknown; var _gitCloneUrl = ""; String gitCloneErrorMessage = ""; @@ -122,6 +122,8 @@ class GitHostSetupScreenState extends State { onDone: (GitHostSetupType setupType) { if (setupType == GitHostSetupType.Manual) { setState(() { + _launchCreateRepoPage(); + _pageCount = pos + 2; _pageChoice[2] = PageChoice2.Manual; _nextPage(); @@ -333,11 +335,13 @@ class GitHostSetupScreenState extends State { } } - void _launchCreateRepoPage(GitHostType hostType) async { + void _launchCreateRepoPage() async { + assert(_gitHostType != GitHostType.Unknown); + try { - if (hostType == GitHostType.GitHub) { + if (_gitHostType == GitHostType.GitHub) { await launch("https://github.com/new"); - } else if (hostType == GitHostType.GitLab) { + } else if (_gitHostType == GitHostType.GitLab) { await launch("https://gitlab.com/projects/new"); } } catch (err, stack) {