From c43c48eadf8873a5e0c870fa3a05057737aef4b1 Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Sun, 31 Mar 2024 03:14:04 +0300 Subject: [PATCH] feat: dynamic text scale prep --- lib/core/features/settings.dart | 7 +++++++ lib/main.dart | 10 +++++++++- lib/pages/home_page.dart | 2 +- macos/Podfile.lock | 6 ++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/core/features/settings.dart b/lib/core/features/settings.dart index fdb3276..c6f9245 100644 --- a/lib/core/features/settings.dart +++ b/lib/core/features/settings.dart @@ -41,28 +41,35 @@ class Settings { class GlobalSettings { bool keepAwake; + double gameTextScale; GlobalSettings({ required this.keepAwake, + required this.gameTextScale, }); factory GlobalSettings.empty() => GlobalSettings( keepAwake: true, + gameTextScale: 1.0, ); factory GlobalSettings.fromJson(Map json) => GlobalSettings( keepAwake: json['keepAwake'] as bool? ?? true, + gameTextScale: json['gameTextScale'] as double? ?? 1.0, ); Map toJson() => { 'keepAwake': keepAwake, + 'gameTextScale': gameTextScale, }; GlobalSettings copyWith({ bool? keepAwake, + double? gameTextScale, }) { return GlobalSettings( keepAwake: keepAwake ?? this.keepAwake, + gameTextScale: gameTextScale ?? this.gameTextScale, ); } } diff --git a/lib/main.dart b/lib/main.dart index e952a79..dd46f37 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:mudblock/core/background_service.dart'; -import 'package:window_manager/window_manager.dart'; import 'core/platform_utils.dart'; import 'core/routes.dart'; @@ -52,6 +51,15 @@ class MudblockApp extends StatelessWidget { navigatorKey: navigatorKey, builder: (context, child) { return GameStore.provider( + builder: (context, child) { + final store = GameStore.of(context); + return MediaQuery( + data: MediaQuery.of(context).copyWith( + textScaler: TextScaler.linear(store.globalSettings.gameTextScale), + ), + child: child!, + ); + }, child: Container( color: darkTheme.colorScheme.background, child: Padding( diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index a1f939d..fb3be19 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -125,7 +125,7 @@ class HomePageState extends State controller: store.input, onSubmitted: store.submitAsInput, onTap: store.selectInput, - style: consoleStyle.copyWith(color: Colors.black), + style: consoleStyle.copyWith(color: Theme.of(context).colorScheme.onSurface), decoration: InputDecoration( hintText: 'Enter command', border: const OutlineInputBorder(), diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 9a60d90..ea87c24 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -16,6 +16,8 @@ PODS: - FlutterMacOS - url_launcher_macos (0.0.1): - FlutterMacOS + - wakelock_plus (0.0.1): + - FlutterMacOS - window_manager (0.2.0): - FlutterMacOS @@ -28,6 +30,7 @@ DEPENDENCIES: - screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) + - wakelock_plus (from `Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos`) - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`) EXTERNAL SOURCES: @@ -47,6 +50,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin url_launcher_macos: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos + wakelock_plus: + :path: Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos window_manager: :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos @@ -59,6 +64,7 @@ SPEC CHECKSUMS: screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38 shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 + wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269 window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367