make theme's platform Android when Linux Mobile Mode is on

Allows for swiping drawers closed
This commit is contained in:
Henry Hiles 2026-10-22 10:37:31 -04:00
commit 7f30150e95
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
2 changed files with 28 additions and 14 deletions

View file

@ -177,7 +177,7 @@ class SettingsSectionsController
),
.new(
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,
builder: (title, description, icon) => SwitchListTile(
title: Text(title),

View file

@ -111,10 +111,21 @@ class const App({super.key}) extends StatelessWidget {
@override
Widget build(BuildContext context) => DynamicColorBuilder(
builder: (lightDynamic, darkDynamic) => Consumer(
builder: (context, ref, child) => MaterialApp(
navigatorKey: navigatorKey,
debugShowCheckedModeBanner: false,
theme:
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,
debugShowCheckedModeBanner: false,
theme: forPlatform(
(ref
.watch(SettingsController.provider)
.maybeWhen(
@ -124,7 +135,8 @@ class const App({super.key}) extends StatelessWidget {
) ??
ThemeData.light().colorScheme)
.theme,
darkTheme:
),
darkTheme: forPlatform(
(ref
.watch(SettingsController.provider)
.maybeWhen(
@ -134,14 +146,16 @@ class const App({super.key}) extends StatelessWidget {
) ??
ThemeData.dark().colorScheme)
.theme,
themeMode: ref
.watch(SettingsController.provider)
.maybeWhen(
data: (settings) => settings.theme,
orElse: () => ThemeMode.system,
),
home: child,
),
),
themeMode: ref
.watch(SettingsController.provider)
.maybeWhen(
data: (settings) => settings.theme,
orElse: () => ThemeMode.system,
),
home: child,
);
},
child: DefaultTextHeightBehavior(
textHeightBehavior: .new(leadingDistribution: .even),
child: Scaffold(