make theme's platform Android when Linux Mobile Mode is on
Allows for swiping drawers closed
This commit is contained in:
parent
c8e1aef74b
commit
7f30150e95
2 changed files with 28 additions and 14 deletions
|
|
@ -177,7 +177,7 @@ class SettingsSectionsController
|
||||||
),
|
),
|
||||||
.new(
|
.new(
|
||||||
title: "Linux Mobile Mode",
|
title: "Linux Mobile Mode",
|
||||||
description: "Enables some fixes for Linux mobile, e.g. disabling dragging appbar for moving window.",
|
description: "Enables some fixes for Linux mobile, e.g. disabling dragging appbar for moving window, and swiping drawers open.",
|
||||||
icon: Icons.construction,
|
icon: Icons.construction,
|
||||||
builder: (title, description, icon) => SwitchListTile(
|
builder: (title, description, icon) => SwitchListTile(
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
|
|
|
||||||
|
|
@ -111,10 +111,21 @@ class const App({super.key}) extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => DynamicColorBuilder(
|
Widget build(BuildContext context) => DynamicColorBuilder(
|
||||||
builder: (lightDynamic, darkDynamic) => Consumer(
|
builder: (lightDynamic, darkDynamic) => Consumer(
|
||||||
builder: (context, ref, child) => MaterialApp(
|
builder: (context, ref, child) {
|
||||||
|
// Flutter turns off mobile behaviour like swiping drawers open on desktop platforms, so Linux mobile pretends to be Android
|
||||||
|
ThemeData forPlatform(ThemeData theme) =>
|
||||||
|
ref.watch(
|
||||||
|
SettingsController.provider.select(
|
||||||
|
(settings) => settings.value?.linuxMobileMode ?? false,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
? theme.copyWith(platform: .android)
|
||||||
|
: theme;
|
||||||
|
|
||||||
|
return MaterialApp(
|
||||||
navigatorKey: navigatorKey,
|
navigatorKey: navigatorKey,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme:
|
theme: forPlatform(
|
||||||
(ref
|
(ref
|
||||||
.watch(SettingsController.provider)
|
.watch(SettingsController.provider)
|
||||||
.maybeWhen(
|
.maybeWhen(
|
||||||
|
|
@ -124,7 +135,8 @@ class const App({super.key}) extends StatelessWidget {
|
||||||
) ??
|
) ??
|
||||||
ThemeData.light().colorScheme)
|
ThemeData.light().colorScheme)
|
||||||
.theme,
|
.theme,
|
||||||
darkTheme:
|
),
|
||||||
|
darkTheme: forPlatform(
|
||||||
(ref
|
(ref
|
||||||
.watch(SettingsController.provider)
|
.watch(SettingsController.provider)
|
||||||
.maybeWhen(
|
.maybeWhen(
|
||||||
|
|
@ -134,6 +146,7 @@ class const App({super.key}) extends StatelessWidget {
|
||||||
) ??
|
) ??
|
||||||
ThemeData.dark().colorScheme)
|
ThemeData.dark().colorScheme)
|
||||||
.theme,
|
.theme,
|
||||||
|
),
|
||||||
themeMode: ref
|
themeMode: ref
|
||||||
.watch(SettingsController.provider)
|
.watch(SettingsController.provider)
|
||||||
.maybeWhen(
|
.maybeWhen(
|
||||||
|
|
@ -141,7 +154,8 @@ class const App({super.key}) extends StatelessWidget {
|
||||||
orElse: () => ThemeMode.system,
|
orElse: () => ThemeMode.system,
|
||||||
),
|
),
|
||||||
home: child,
|
home: child,
|
||||||
),
|
);
|
||||||
|
},
|
||||||
child: DefaultTextHeightBehavior(
|
child: DefaultTextHeightBehavior(
|
||||||
textHeightBehavior: .new(leadingDistribution: .even),
|
textHeightBehavior: .new(leadingDistribution: .even),
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue