registerMagicStarterSupportRoutes function
Registers the support desk routes provided by Magic Starter plugin.
Routes are only registered when magic_starter.features.support is
enabled. When disabled, calling this function is a no-op.
/support/new and, behind support_feedback, /support/feedback are
registered before /support/:id so the literal segment wins over the
parameter. The list replaces and the other two are
.stacked(), the hub-and-spoke shape the settings routes use: a host
commonly gives the list a nav destination, and the create and thread pages
are places a reader drills into and needs the back gesture out of.
The thread is a chat screen, so its page is wrapped in MagicStarterHideBottomNav: the phone's bottom navigation slides away under the composer with the push and comes back with the pop, and stays on the list and the create page. Every support page shares the one app shell, so moving between them never rebuilds the layout.
The host calls this from its route provider, as it does the other
registerMagicStarter*Routes(): the profile dropdown shows its Support item
whenever the feature is on, and without this call that item leads nowhere.
The view keys (support.index, support.create, support.thread, and
support.feedback behind its flag) have default builders;
MagicStarter.view.register(...) replaces one.
Implementation
void registerMagicStarterSupportRoutes() {
if (!MagicStarterConfig.hasSupportFeatures()) return;
MagicRoute.group(
middleware: ['auth'],
layoutId: MagicStarterLayoutIds.app,
layout: (child) => MagicStarter.view.makeLayout('layout.app', child: child),
routes: () {
MagicRoute.page(
MagicStarterConfig.supportRoute(),
() => _supportView('support.index'),
).title('magic_starter.titles.support');
MagicRoute.page(
MagicStarterConfig.supportCreateRoute(),
() => _supportView('support.create'),
).title('magic_starter.titles.support_create').stacked();
if (MagicStarterConfig.hasSupportFeedbackFeatures()) {
MagicRoute.page(magicStarterSupportFeedbackRoute(), () {
Magic.findOrPut(MagicStarterFeedbackController.new);
return MagicStarter.view.make('support.feedback');
}).title('magic_starter.titles.support_feedback').stacked();
}
MagicRoute.page(
MagicStarterConfig.supportThreadRoute(),
() => MagicStarterHideBottomNav(child: _supportView('support.thread')),
).title('magic_starter.titles.support_thread').stacked();
},
);
}