window effect for windows

This commit is contained in:
wgh19
2024-05-31 15:21:58 +08:00
parent e6d015a2bc
commit 1652a93772
3 changed files with 57 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
import 'dart:io';
import 'dart:ui';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:path_provider/path_provider.dart';
@@ -16,6 +17,8 @@ class _App {
bool get isAndroid => Platform.isAndroid;
bool get isIOS => Platform.isIOS;
bool get isWindows => Platform.isWindows;
int? _windowsVersion;
int get windowsVersion => _windowsVersion!;
bool get isLinux => Platform.isLinux;
bool get isMacOS => Platform.isMacOS;
bool get isDesktop =>
@@ -23,8 +26,8 @@ class _App {
bool get isMobile => Platform.isAndroid || Platform.isIOS;
Locale get locale {
if(appdata.settings["language"] != "System"){
return switch(appdata.settings["language"]){
if (appdata.settings["language"] != "System") {
return switch (appdata.settings["language"]) {
"English" => const Locale("en"),
"简体中文" => const Locale("zh", "CN"),
"繁體中文" => const Locale("zh", "TW"),
@@ -32,7 +35,8 @@ class _App {
};
}
Locale deviceLocale = PlatformDispatcher.instance.locale;
if (deviceLocale.languageCode == "zh" && deviceLocale.scriptCode == "Hant") {
if (deviceLocale.languageCode == "zh" &&
deviceLocale.scriptCode == "Hant") {
deviceLocale = const Locale("zh", "TW");
}
return deviceLocale;
@@ -41,9 +45,22 @@ class _App {
late String dataPath;
late String cachePath;
init() async{
init() async {
cachePath = (await getApplicationCacheDirectory()).path;
dataPath = (await getApplicationSupportDirectory()).path;
final deviceInfoPlugin = DeviceInfoPlugin();
final deviceInfo = await deviceInfoPlugin.windowsInfo;
if (deviceInfo.majorVersion <= 6) {
if (deviceInfo.minorVersion < 2) {
_windowsVersion = 7;
} else {
_windowsVersion = 8;
}
} else if (deviceInfo.buildNumber < 22000) {
_windowsVersion = 10;
} else {
_windowsVersion = 11;
}
}
final rootNavigatorKey = GlobalKey<NavigatorState>();