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:
parent
75eca16f07
commit
24eea80b66
@ -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(
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
}
|
||||
},
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user