Add settings page #46
3 changed files with 36 additions and 3 deletions
add linux mobile mode toggle
commit
a7a3a7d4d3
|
|
@ -8,6 +8,7 @@ abstract class Settings with _$Settings {
|
||||||
const factory Settings({
|
const factory Settings({
|
||||||
@Default(ThemeMode.system) ThemeMode theme,
|
@Default(ThemeMode.system) ThemeMode theme,
|
||||||
@Default(true) bool useDynamicTheming,
|
@Default(true) bool useDynamicTheming,
|
||||||
|
@Default(false) bool linuxMobileMode,
|
||||||
}) = _Settings;
|
}) = _Settings;
|
||||||
|
|
||||||
factory Settings.fromJson(Map<String, Object?> json) =>
|
factory Settings.fromJson(Map<String, Object?> json) =>
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,30 @@ class SettingsPage extends ConsumerWidget {
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
.new(
|
||||||
|
title: "Behavior",
|
||||||
|
icon: Icons.psychology,
|
||||||
|
settings: .new([
|
||||||
|
Setting(
|
||||||
|
title: "Linux Mobile Mode",
|
||||||
|
description:
|
||||||
|
"Enables some fixes for Linux mobile, e.g. disabling dragging appbar for moving window.",
|
||||||
|
icon: Icons.construction,
|
||||||
|
builder: (title, description, icon) => SwitchListTile(
|
||||||
|
title: Text(title),
|
||||||
|
subtitle: Text(description),
|
||||||
|
secondary: Icon(icon),
|
||||||
|
value: settings.linuxMobileMode,
|
||||||
|
onChanged: Platform.isLinux
|
||||||
|
? (value) => ref
|
||||||
|
.watch(SettingsController.provider.notifier)
|
||||||
|
.set(settings.copyWith(linuxMobileMode: value))
|
||||||
|
.onError(showError)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
]),
|
]),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
import "dart:io";
|
import "dart:io";
|
||||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
|
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||||
|
import "package:nexus/controllers/settings_controller.dart";
|
||||||
import "package:window_manager/window_manager.dart";
|
import "package:window_manager/window_manager.dart";
|
||||||
|
|
||||||
class Appbar extends StatelessWidget implements PreferredSizeWidget {
|
class Appbar extends ConsumerWidget implements PreferredSizeWidget {
|
||||||
final Widget? leading;
|
final Widget? leading;
|
||||||
final Widget? title;
|
final Widget? title;
|
||||||
final Color? backgroundColor;
|
final Color? backgroundColor;
|
||||||
|
|
@ -25,7 +27,7 @@ class Appbar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
Size get preferredSize => const .fromHeight(kToolbarHeight);
|
Size get preferredSize => const .fromHeight(kToolbarHeight);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
Future<void> maximize() async {
|
Future<void> maximize() async {
|
||||||
final isMaximized = await windowManager.isMaximized();
|
final isMaximized = await windowManager.isMaximized();
|
||||||
|
|
||||||
|
|
@ -37,7 +39,13 @@ class Appbar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onPanStart: (_) => windowManager.startDragging(),
|
onPanStart: ref
|
||||||
|
.watch(SettingsController.provider)
|
||||||
|
.whenOrNull(
|
||||||
|
data: (settings) => settings.linuxMobileMode
|
||||||
|
? null
|
||||||
|
: (_) => windowManager.startDragging(),
|
||||||
|
),
|
||||||
child: AppBar(
|
child: AppBar(
|
||||||
leading: InkWell(onTap: onTap, child: leading),
|
leading: InkWell(onTap: onTap, child: leading),
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue