1
0
mirror of https://github.com/git-touch/git-touch synced 2025-01-18 18:29:59 +01:00

refactor: replace router

This commit is contained in:
Rongjian Zhang 2019-12-12 21:20:24 +08:00
parent 75eca16f07
commit 24eea80b66
3 changed files with 22 additions and 18 deletions

View File

@ -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(

View File

@ -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<bool> showConfirm(BuildContext context, Widget content) {
switch (theme) {
case AppThemeType.cupertino:

View File

@ -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<ThemeModel>(context)
.pushReplacementRoute(
context,
(_) => RepositoryScreen(owner, name,
branch: result),
);
onClose: (ref) {
if (ref != branch) {
Provider.of<ThemeModel>(context).push(
context, '/$owner/$name?ref=$ref',
replace: true);
}
},
),