feat(app): register the saved-schedule list under Settings at /schedules
This commit is contained in:
@@ -31,12 +31,14 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
required this.cupertino,
|
||||
this.searchBuilder,
|
||||
this.templatesBuilder,
|
||||
this.schedulesBuilder,
|
||||
AppRoute initial = AppRoute.pipelines,
|
||||
}) : _route = initial,
|
||||
_searchReturn = initial.kind == AppRouteKind.search
|
||||
? AppRoute.pipelines
|
||||
: initial,
|
||||
_templatesReturn = initial.kind == AppRouteKind.templates
|
||||
|| initial.kind == AppRouteKind.schedules
|
||||
? AppRoute.settings
|
||||
: initial;
|
||||
|
||||
@@ -46,6 +48,7 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
/// shell keeps the Settings destination mounted underneath and its state is
|
||||
/// restored when this page closes.
|
||||
final Widget Function(BuildContext context)? templatesBuilder;
|
||||
final Widget Function(BuildContext context)? schedulesBuilder;
|
||||
|
||||
/// The Search page above the shell. Search is transient chrome, not a fifth
|
||||
/// tab: the shell stays mounted underneath so closing restores its loaded
|
||||
@@ -64,6 +67,7 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
static const _pageKey = ValueKey<String>('pipelines-shell');
|
||||
static const _searchPageKey = ValueKey<String>('app-search');
|
||||
static const _templatesPageKey = ValueKey<String>('app-templates');
|
||||
static const _schedulesPageKey = ValueKey<String>('app-schedules');
|
||||
|
||||
AppRoute _route;
|
||||
|
||||
@@ -79,6 +83,9 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
|
||||
bool get templatesOpen => _route.kind == AppRouteKind.templates;
|
||||
|
||||
/// The saved-schedule list page, opened above Settings.
|
||||
bool get schedulesOpen => _route.kind == AppRouteKind.schedules;
|
||||
|
||||
@override
|
||||
AppRoute get currentConfiguration => _route;
|
||||
|
||||
@@ -96,9 +103,10 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
Widget build(BuildContext context) {
|
||||
final searching = searchOpen && searchBuilder != null;
|
||||
final templates = templatesOpen && templatesBuilder != null;
|
||||
final schedules = schedulesOpen && schedulesBuilder != null;
|
||||
final shellRoute = searching
|
||||
? _searchReturn
|
||||
: templates
|
||||
: templates || schedules
|
||||
? _templatesReturn
|
||||
: _route;
|
||||
return Navigator(
|
||||
@@ -108,6 +116,7 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
// Templates is a Settings sub-page: the shell stays mounted underneath,
|
||||
// so closing restores Settings exactly as it was left.
|
||||
if (templates) _page(_templatesPageKey, templatesBuilder!(context)),
|
||||
if (schedules) _page(_schedulesPageKey, schedulesBuilder!(context)),
|
||||
// Search is a transient full-screen mode, so a full-screen dialog gives
|
||||
// the standard Close/Cancel action instead of a Back chevron.
|
||||
if (searching)
|
||||
@@ -116,6 +125,7 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
onDidRemovePage: (page) {
|
||||
if (page.key == _searchPageKey) closeSearch();
|
||||
if (page.key == _templatesPageKey) closeTemplates();
|
||||
if (page.key == _schedulesPageKey) closeSchedules();
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -133,6 +143,19 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
goTo(AppRoute.settings);
|
||||
}
|
||||
|
||||
/// Open the saved-schedule list above Settings. Back restores the same
|
||||
/// Settings screen instance, like Templates.
|
||||
void openSchedules() {
|
||||
if (schedulesOpen) return;
|
||||
_templatesReturn = AppRoute.settings;
|
||||
goTo(AppRoute.schedules);
|
||||
}
|
||||
|
||||
void closeSchedules() {
|
||||
if (!schedulesOpen) return;
|
||||
goTo(AppRoute.settings);
|
||||
}
|
||||
|
||||
/// Open Search above the current destination; its route carries the browser
|
||||
/// history entry, and close/back returns to what was open before.
|
||||
void openSearch() {
|
||||
@@ -164,6 +187,10 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
closeSearch();
|
||||
return true;
|
||||
}
|
||||
if (schedulesOpen) {
|
||||
closeSchedules();
|
||||
return true;
|
||||
}
|
||||
if (templatesOpen) {
|
||||
closeTemplates();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user