fix: ThemeMode not works under copied data

This commit is contained in:
lollipopkit
2023-03-21 15:36:35 +08:00
parent 7732ce5dbb
commit 9e3afe98a9
6 changed files with 45 additions and 33 deletions

View File

@@ -359,7 +359,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 241;
CURRENT_PROJECT_VERSION = 243;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@@ -367,7 +367,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.241;
MARKETING_VERSION = 1.0.243;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -490,7 +490,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 241;
CURRENT_PROJECT_VERSION = 243;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@@ -498,7 +498,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.241;
MARKETING_VERSION = 1.0.243;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -515,7 +515,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 241;
CURRENT_PROJECT_VERSION = 243;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@@ -523,7 +523,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.241;
MARKETING_VERSION = 1.0.243;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";

View File

@@ -41,6 +41,8 @@ class MyApp extends StatelessWidget {
final radioTheme = RadioThemeData(
fillColor: materialColor,
);
final primarySwatch = primaryColor.materialColor;
return ValueListenableBuilder<int>(
valueListenable: _setting.themeMode.listenable(),
builder: (_, tMode, __) {
@@ -51,7 +53,7 @@ class MyApp extends StatelessWidget {
useMaterial3: false,
fontFamily: fontName,
primaryColor: primaryColor,
primarySwatch: primaryColor.materialColor,
primarySwatch: primarySwatch,
appBarTheme: appBarTheme,
floatingActionButtonTheme: fabTheme,
iconTheme: iconTheme,
@@ -60,6 +62,24 @@ class MyApp extends StatelessWidget {
inputDecorationTheme: inputDecorationTheme,
radioTheme: radioTheme,
);
final darkTheme = ThemeData(
useMaterial3: false,
fontFamily: fontName,
primaryColor: primaryColor,
primarySwatch: primarySwatch,
floatingActionButtonTheme: fabTheme,
iconTheme: iconTheme,
primaryIconTheme: iconTheme,
switchTheme: switchTheme,
inputDecorationTheme: inputDecorationTheme,
radioTheme: radioTheme,
brightness: Brightness.dark,
colorScheme: ColorScheme.fromSwatch(
primarySwatch: primaryColor.materialColor,
brightness: Brightness.dark,
accentColor: primaryColor,
),
);
return MaterialApp(
debugShowCheckedModeBanner: false,
@@ -68,13 +88,7 @@ class MyApp extends StatelessWidget {
title: BuildData.name,
themeMode: themeMode,
theme: theme,
darkTheme: theme.copyWith(
colorScheme: ColorScheme.fromSwatch(
primarySwatch: primaryColor.materialColor,
brightness: Brightness.dark,
accentColor: primaryColor,
),
),
darkTheme: darkTheme,
home: const MyHomePage(),
);
},

View File

@@ -87,13 +87,11 @@ class ServerProvider extends BusyProvider {
_servers[i].client?.close();
_servers[i].client = null;
}
notifyListeners();
return;
}
final idx = getServerIdx(spi.id);
_servers[idx].client?.close();
_servers[idx].client = null;
notifyListeners();
}
void addServer(ServerPrivateInfo spi) {

View File

@@ -2,8 +2,8 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 241;
static const int build = 243;
static const String engine = "Flutter 3.7.7 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 2ad6cd72c0 (13 days ago) • 2023-03-08 09:41:59 -0800\nEngine • revision 1837b5be5f\nTools • Dart 2.19.4 • DevTools 2.20.1\n";
static const String buildAt = "2023-03-21 15:00:34.919375";
static const int modifications = 6;
static const String buildAt = "2023-03-21 15:18:42.802605";
static const int modifications = 5;
}

View File

@@ -82,8 +82,7 @@ Future<void> main() async {
runInZone(() async {
await initApp();
runApp(
RebuildWidget(
child: MultiProvider(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => locator<AppProvider>()),
ChangeNotifierProvider(create: (_) => locator<PkgProvider>()),
@@ -92,10 +91,10 @@ Future<void> main() async {
ChangeNotifierProvider(create: (_) => locator<ServerProvider>()),
ChangeNotifierProvider(create: (_) => locator<SnippetProvider>()),
ChangeNotifierProvider(create: (_) => locator<VirtualKeyboard>()),
ChangeNotifierProvider(
create: (_) => locator<PrivateKeyProvider>()),
ChangeNotifierProvider(create: (_) => locator<PrivateKeyProvider>()),
ChangeNotifierProvider(create: (_) => locator<SftpProvider>()),
],
child: RebuildWidget(
child: MyApp(),
),
),

View File

@@ -68,6 +68,7 @@ class _MyHomePageState extends State<MyHomePage>
void dispose() {
super.dispose();
WidgetsBinding.instance.removeObserver(this);
_serverProvider.closeServer();
}
@override