mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 08:04:51 +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(
|
themeModel.router.define('/:owner/:name', handler: Handler(
|
||||||
handlerFunc: (context, params) {
|
handlerFunc: (context, params) {
|
||||||
|
if (params['ref'] == null) {
|
||||||
return RepositoryScreen(params['owner'].first, params['name'].first);
|
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(
|
themeModel.router.define('/:owner/:name/issues', handler: Handler(
|
||||||
|
@ -152,11 +152,17 @@ class ThemeModel with ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
push(BuildContext context, String path) {
|
push(BuildContext context, String path, {bool replace = false}) {
|
||||||
return router.navigateTo(context, path,
|
return router.navigateTo(
|
||||||
transition: theme == AppThemeType.cupertino
|
context,
|
||||||
|
path,
|
||||||
|
transition: replace
|
||||||
|
? TransitionType.fadeIn
|
||||||
|
: theme == AppThemeType.cupertino
|
||||||
? TransitionType.cupertino
|
? TransitionType.cupertino
|
||||||
: TransitionType.material);
|
: TransitionType.material,
|
||||||
|
replace: replace,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushRoute(
|
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) {
|
Future<bool> showConfirm(BuildContext context, Widget content) {
|
||||||
switch (theme) {
|
switch (theme) {
|
||||||
case AppThemeType.cupertino:
|
case AppThemeType.cupertino:
|
||||||
|
@ -249,14 +249,11 @@ class RepositoryScreen extends StatelessWidget {
|
|||||||
items: refs
|
items: refs
|
||||||
.map((b) => PickerItem(b.name, text: b.name))
|
.map((b) => PickerItem(b.name, text: b.name))
|
||||||
.toList(),
|
.toList(),
|
||||||
onClose: (result) {
|
onClose: (ref) {
|
||||||
if (result != branch) {
|
if (ref != branch) {
|
||||||
Provider.of<ThemeModel>(context)
|
Provider.of<ThemeModel>(context).push(
|
||||||
.pushReplacementRoute(
|
context, '/$owner/$name?ref=$ref',
|
||||||
context,
|
replace: true);
|
||||||
(_) => RepositoryScreen(owner, name,
|
|
||||||
branch: result),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user