mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-31 20:52:32 +00:00
* (new): [MacOS] Add LunaSea icon * (new): [Scaffold] Use LunaScaffold across application * (tweak): [theme]: Add hover colour to theme * (fix): [Platform] Add platform checks and platform availability checks to Firebase Analytics & IAPs * (fix): [MacOS] Ensure all deployment targets are 10.12 (Sierra) * (fix): [MacOS] Correctly set the application name's capitalization * (chore): Updated packages
58 lines
1.9 KiB
Dart
58 lines
1.9 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(scaffoldKey?.currentState?.hasDrawer ?? false) 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(),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|