Files
lunasea/lib/core/ui/scaffold.dart
Jagandeep Brar a1d68cd234 [share_plus] iOS 12 and lower crashes at launch due to missing LinkPresentation.framework (#442)
* chore(packages): Added pedantic package to enforce linting and styling
* feat(lunasea): Enforce effective dart styling
* Comment and format colours class
* Localize additional classes in Dashboard, cleanup additional code
* chore(lunasea): Major refactor by running dartfmt on the entire codebase, added widget return for page routers
* Additional work on conforming to effective dart style
* fix(share_plus): Roll back share_plus package to 2.0.0 to support iOS 12 or lower
* chore(lunasea): Fix remaining enabled analysis warnings
2021-04-24 04:26:39 -05:00

61 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:lunasea/core.dart';
class LunaScaffold extends StatelessWidget {
final GlobalKey<ScaffoldState> scaffoldKey;
final PreferredSizeWidget appBar;
final Widget body;
final Widget drawer;
final Widget bottomNavigationBar;
final Widget floatingActionButton;
final bool extendBody;
final bool extendBodyBehindAppBar;
/// Called when [LunaDatabaseValue.ENABLED_PROFILE] has changed. Triggered within the build function.
final void Function(BuildContext) onProfileChange;
LunaScaffold({
Key key,
@required this.scaffoldKey,
this.appBar,
this.body,
this.drawer,
this.bottomNavigationBar,
this.floatingActionButton,
this.extendBody = false,
this.extendBodyBehindAppBar = false,
this.onProfileChange,
}) : super(key: key);
@override
Widget build(BuildContext context) {
if (drawer != null)
return LunaWillPopScope(
scaffoldKey: scaffoldKey,
child: scaffold,
);
return scaffold;
}
Widget get scaffold {
return ValueListenableBuilder(
valueListenable: Database.lunaSeaBox
.listenable(keys: [LunaDatabaseValue.ENABLED_PROFILE.key]),
builder: (context, _, __) {
if (onProfileChange != null) onProfileChange(context);
return Scaffold(
key: scaffoldKey,
appBar: appBar,
body: body,
drawer: drawer,
bottomNavigationBar: bottomNavigationBar,
floatingActionButton: floatingActionButton,
extendBody: extendBody,
extendBodyBehindAppBar: extendBodyBehindAppBar,
onDrawerChanged: (_) => FocusManager.instance.primaryFocus?.unfocus(),
);
},
);
}
}