feat: dynamic text scale prep

This commit is contained in:
2024-03-31 03:14:04 +03:00
parent 7166bea926
commit c43c48eadf
4 changed files with 23 additions and 2 deletions

View File

@@ -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<String, dynamic> json) => GlobalSettings(
keepAwake: json['keepAwake'] as bool? ?? true,
gameTextScale: json['gameTextScale'] as double? ?? 1.0,
);
Map<String, dynamic> toJson() => {
'keepAwake': keepAwake,
'gameTextScale': gameTextScale,
};
GlobalSettings copyWith({
bool? keepAwake,
double? gameTextScale,
}) {
return GlobalSettings(
keepAwake: keepAwake ?? this.keepAwake,
gameTextScale: gameTextScale ?? this.gameTextScale,
);
}
}

View File

@@ -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(

View File

@@ -125,7 +125,7 @@ class HomePageState extends State<HomePage>
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(),

View File

@@ -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