diff --git a/lib/main.dart b/lib/main.dart index 7ae766e..6639466 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -246,7 +246,12 @@ void main() async { )); themeModel.router.define('/:owner/:name', handler: Handler( handlerFunc: (context, params) { - return RepositoryScreen(params['owner'].first, params['name'].first); + if (params['ref'] == null) { + return RepositoryScreen(params['owner'].first, params['name'].first); + } else { + return RepositoryScreen(params['owner'].first, params['name'].first, + branch: params['ref'].first); + } }, )); themeModel.router.define('/:owner/:name/issues', handler: Handler( diff --git a/lib/models/theme.dart b/lib/models/theme.dart index 5684252..6ad80db 100644 --- a/lib/models/theme.dart +++ b/lib/models/theme.dart @@ -152,11 +152,17 @@ class ThemeModel with ChangeNotifier { notifyListeners(); } - push(BuildContext context, String path) { - return router.navigateTo(context, path, - transition: theme == AppThemeType.cupertino - ? TransitionType.cupertino - : TransitionType.material); + push(BuildContext context, String path, {bool replace = false}) { + return router.navigateTo( + context, + path, + transition: replace + ? TransitionType.fadeIn + : theme == AppThemeType.cupertino + ? TransitionType.cupertino + : TransitionType.material, + replace: replace, + ); } pushRoute( @@ -178,10 +184,6 @@ class ThemeModel with ChangeNotifier { } } - pushReplacementRoute(BuildContext context, WidgetBuilder builder) { - return Navigator.of(context).pushReplacement(StaticRoute(builder: builder)); - } - Future showConfirm(BuildContext context, Widget content) { switch (theme) { case AppThemeType.cupertino: diff --git a/lib/screens/repository.dart b/lib/screens/repository.dart index 39e7ffe..72b1224 100644 --- a/lib/screens/repository.dart +++ b/lib/screens/repository.dart @@ -249,14 +249,11 @@ class RepositoryScreen extends StatelessWidget { items: refs .map((b) => PickerItem(b.name, text: b.name)) .toList(), - onClose: (result) { - if (result != branch) { - Provider.of(context) - .pushReplacementRoute( - context, - (_) => RepositoryScreen(owner, name, - branch: result), - ); + onClose: (ref) { + if (ref != branch) { + Provider.of(context).push( + context, '/$owner/$name?ref=$ref', + replace: true); } }, ),