Resolves #563 Fullscreen mode
This commit is contained in:
parent
096e714a04
commit
e0a28c0b59
@ -185,8 +185,13 @@ void main() async {
|
||||
};
|
||||
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await AppSettings().loadAppTheme();
|
||||
await AppSettings().loadStartupSettings();
|
||||
await Hive.initFlutter();
|
||||
if (AppSettings().displayMode == DisplayMode.fullscreen) {
|
||||
SystemChrome.setEnabledSystemUIOverlays([]);
|
||||
} else {
|
||||
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
|
||||
}
|
||||
|
||||
runZoned(() {
|
||||
runApp(new HAClientApp(
|
||||
|
@ -1,5 +1,7 @@
|
||||
part of '../main.dart';
|
||||
|
||||
enum DisplayMode {normal, fullscreen}
|
||||
|
||||
class AppSettings {
|
||||
|
||||
static const DEFAULT_HIVE_BOX = 'defaultSettingsBox';
|
||||
@ -26,6 +28,7 @@ class AppSettings {
|
||||
String webhookId;
|
||||
double haVersion;
|
||||
bool scrollBadges;
|
||||
DisplayMode displayMode;
|
||||
AppTheme appTheme;
|
||||
final int defaultLocationUpdateIntervalMinutes = 20;
|
||||
Duration locationUpdateInterval;
|
||||
@ -34,9 +37,10 @@ class AppSettings {
|
||||
bool get isAuthenticated => longLivedToken != null;
|
||||
bool get isTempAuthenticated => tempToken != null;
|
||||
|
||||
loadAppTheme() async {
|
||||
loadStartupSettings() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
appTheme = AppTheme.values[prefs.getInt('app-theme') ?? AppTheme.defaultTheme.index];
|
||||
displayMode = DisplayMode.values[prefs.getInt('display-mode') ?? DisplayMode.normal.index];
|
||||
}
|
||||
|
||||
Future load(bool full) async {
|
||||
|
@ -484,7 +484,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
floating: true,
|
||||
pinned: true,
|
||||
snap: false,
|
||||
primary: true,
|
||||
primary: AppSettings().displayMode == DisplayMode.normal,
|
||||
title: Text(HomeAssistant().locationName ?? ""),
|
||||
actions: <Widget>[
|
||||
PopupMenuButton(
|
||||
@ -645,10 +645,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
bottomNavigationBar: BottomInfoBar(
|
||||
controller: _bottomInfoBarController,
|
||||
),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
child: _buildScaffoldBody(true)
|
||||
)
|
||||
body: _buildScaffoldBody(true)
|
||||
);
|
||||
} else {
|
||||
return Scaffold(
|
||||
@ -658,10 +655,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
bottomNavigationBar: BottomInfoBar(
|
||||
controller: _bottomInfoBarController,
|
||||
),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
child: _buildScaffoldBody(false)
|
||||
)
|
||||
body: _buildScaffoldBody(false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
|
||||
|
||||
Widget _buildMenuItem(BuildContext context, IconData icon,String title, AppSettingsSection section) {
|
||||
return ListTile(
|
||||
title: Text(title, style: Theme.of(context).textTheme.subhead),
|
||||
title: Text(title),
|
||||
leading: Icon(icon),
|
||||
trailing: Icon(Icons.keyboard_arrow_right),
|
||||
onTap: () {
|
||||
|
@ -13,6 +13,7 @@ class _LookAndFeelSettingsPageState extends State<LookAndFeelSettingsPage> {
|
||||
|
||||
AppTheme _currentTheme;
|
||||
bool _scrollBadges = false;
|
||||
DisplayMode _displayMode;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -25,7 +26,8 @@ class _LookAndFeelSettingsPageState extends State<LookAndFeelSettingsPage> {
|
||||
await prefs.reload();
|
||||
SharedPreferences.getInstance().then((prefs) {
|
||||
setState(() {
|
||||
_currentTheme = AppTheme.values[prefs.getInt("app-theme") ?? AppTheme.defaultTheme.index];
|
||||
_currentTheme = AppTheme.values[prefs.getInt('app-theme') ?? AppTheme.defaultTheme.index];
|
||||
_displayMode = DisplayMode.values[prefs.getInt('display-mode') ?? DisplayMode.normal.index];
|
||||
_scrollBadges = prefs.getBool('scroll-badges') ?? true;
|
||||
});
|
||||
});
|
||||
@ -42,18 +44,34 @@ class _LookAndFeelSettingsPageState extends State<LookAndFeelSettingsPage> {
|
||||
});
|
||||
}
|
||||
|
||||
Future _saveOther() async {
|
||||
Future _saveBadgesSettings() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
AppSettings().scrollBadges = _scrollBadges;
|
||||
await prefs.setBool('scroll-badges', _scrollBadges);
|
||||
}
|
||||
|
||||
Future _saveDisplayMode(DisplayMode mode) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
AppSettings().displayMode = mode;
|
||||
await prefs.setInt('display-mode', mode.index);
|
||||
if (mode == DisplayMode.fullscreen) {
|
||||
SystemChrome.setEnabledSystemUIOverlays([]);
|
||||
} else {
|
||||
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
|
||||
}
|
||||
}
|
||||
|
||||
Map appThemeName = {
|
||||
AppTheme.defaultTheme: 'Default',
|
||||
AppTheme.haTheme: 'Home Assistant theme',
|
||||
AppTheme.darkTheme: 'Dark theme'
|
||||
};
|
||||
|
||||
Map DisplayModeName = {
|
||||
DisplayMode.normal: 'Normal',
|
||||
DisplayMode.fullscreen: 'Fullscreen'
|
||||
};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(
|
||||
@ -93,7 +111,28 @@ class _LookAndFeelSettingsPageState extends State<LookAndFeelSettingsPage> {
|
||||
setState(() {
|
||||
_scrollBadges = val;
|
||||
});
|
||||
_saveOther();
|
||||
_saveBadgesSettings();
|
||||
},
|
||||
),
|
||||
Container(height: Sizes.doubleRowPadding),
|
||||
Text("Fullscreen mode:", style: Theme.of(context).textTheme.body2),
|
||||
Container(height: Sizes.rowPadding),
|
||||
DropdownButton<DisplayMode>(
|
||||
value: _displayMode,
|
||||
iconSize: 30.0,
|
||||
isExpanded: true,
|
||||
style: Theme.of(context).textTheme.title,
|
||||
items: DisplayMode.values.map((value) {
|
||||
return new DropdownMenuItem<DisplayMode>(
|
||||
value: value,
|
||||
child: Text('${DisplayModeName[value]}'),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (DisplayMode val) {
|
||||
setState(() {
|
||||
_displayMode = val;
|
||||
});
|
||||
_saveDisplayMode(val);
|
||||
},
|
||||
),
|
||||
]
|
||||
|
Reference in New Issue
Block a user