mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-31 20:52:32 +00:00
* 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
61 lines
1.7 KiB
Dart
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(),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|