opt: shrink unnecessary theme code
This commit is contained in:
parent
6119e04006
commit
205f37cd56
@ -225,22 +225,18 @@ class MyTheme {
|
|||||||
return themeModeFromString(bind.mainGetLocalOption(key: kCommConfKeyTheme));
|
return themeModeFromString(bind.mainGetLocalOption(key: kCommConfKeyTheme));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void changeDarkMode(ThemeMode mode) {
|
static void changeDarkMode(ThemeMode mode) async {
|
||||||
Get.changeThemeMode(mode);
|
Get.changeThemeMode(mode);
|
||||||
if (desktopType == DesktopType.main) {
|
if (desktopType == DesktopType.main) {
|
||||||
if (mode == ThemeMode.system) {
|
if (mode == ThemeMode.system) {
|
||||||
bind.mainSetLocalOption(key: kCommConfKeyTheme, value: '');
|
await bind.mainSetLocalOption(key: kCommConfKeyTheme, value: '');
|
||||||
} else {
|
} else {
|
||||||
bind.mainSetLocalOption(
|
await bind.mainSetLocalOption(
|
||||||
key: kCommConfKeyTheme, value: mode.toShortString());
|
key: kCommConfKeyTheme, value: mode.toShortString());
|
||||||
}
|
}
|
||||||
bind.mainChangeTheme(dark: mode.toShortString());
|
await bind.mainChangeTheme(dark: mode.toShortString());
|
||||||
}
|
// Synchronize the window theme of the system.
|
||||||
// Synchronize the window theme of the system.
|
updateSystemWindowTheme();
|
||||||
if (Platform.isMacOS) {
|
|
||||||
final isDark = mode == ThemeMode.dark;
|
|
||||||
RdPlatformChannel.instance.changeSystemWindowTheme(
|
|
||||||
isDark ? SystemWindowTheme.dark : SystemWindowTheme.light);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1694,12 +1690,12 @@ String getWindowNameWithId(String id, {WindowType? overrideType}) {
|
|||||||
return "${DesktopTab.labelGetterAlias(id).value} - ${getWindowName(overrideType: overrideType)}";
|
return "${DesktopTab.labelGetterAlias(id).value} - ${getWindowName(overrideType: overrideType)}";
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateSystemWindowTheme() {
|
Future<void> updateSystemWindowTheme() async {
|
||||||
// Set system window theme for macOS
|
// Set system window theme for macOS.
|
||||||
final userPreference = MyTheme.getThemeModePreference();
|
final userPreference = MyTheme.getThemeModePreference();
|
||||||
if (userPreference != ThemeMode.system) {
|
if (userPreference != ThemeMode.system) {
|
||||||
if (Platform.isMacOS) {
|
if (Platform.isMacOS) {
|
||||||
RdPlatformChannel.instance.changeSystemWindowTheme(
|
await RdPlatformChannel.instance.changeSystemWindowTheme(
|
||||||
userPreference == ThemeMode.light
|
userPreference == ThemeMode.light
|
||||||
? SystemWindowTheme.light
|
? SystemWindowTheme.light
|
||||||
: SystemWindowTheme.dark);
|
: SystemWindowTheme.dark);
|
||||||
|
@ -6,7 +6,7 @@ import 'package:flutter_hbb/main.dart';
|
|||||||
|
|
||||||
enum SystemWindowTheme { light, dark }
|
enum SystemWindowTheme { light, dark }
|
||||||
|
|
||||||
/// The platform channel for RustDesk
|
/// The platform channel for RustDesk.
|
||||||
class RdPlatformChannel {
|
class RdPlatformChannel {
|
||||||
RdPlatformChannel._();
|
RdPlatformChannel._();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user