dvModuleShell function
Wraps child in whatever chrome the module mounted as moduleId should
render in.
Applied by the generated router around a module's own pages, and nowhere else: putting a module's chrome around the application's own pages would be the mode applying to the wrong half of the application.
Implementation
Widget dvModuleShell(BuildContext context, String moduleId, Widget child) {
final DVModule? module = dvModuleRegistry.maybeGet(moduleId);
if (module == null) return child;
final DVModuleShellMode mode = module.shellMode;
if (mode == DVModuleShellMode.inherit) return child;
final DVModuleShellBuilder? own = module.declaredShell;
// Unlike a theme, an absent shell is a decision the parent can make on its
// own: "this module has no chrome" needs nothing from the module, so
// override and none both take effect whether or not one was declared.
final bool drawPageChrome = mode == DVModuleShellMode.extend;
final Widget page = DVPageChrome(draw: drawPageChrome, child: child);
// none means none, the module's own included. A module that declares
// chrome and is mounted into a kiosk screen has to lose it, or the parent
// asked for a bare panel and got a titled one.
if (mode == DVModuleShellMode.none || own == null) return page;
return Builder(builder: (BuildContext inner) => own(inner, page));
}