mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 04:57:23 +00:00
window effect for windows
This commit is contained in:
@@ -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>();
|
||||
|
@@ -4,6 +4,7 @@ import "package:dynamic_color/dynamic_color.dart";
|
||||
import "package:fluent_ui/fluent_ui.dart";
|
||||
import "package:flutter/material.dart" as md;
|
||||
import "package:flutter/services.dart";
|
||||
import "package:flutter_acrylic/flutter_acrylic.dart" as flutter_acrylic;
|
||||
import "package:pixes/appdata.dart";
|
||||
import "package:pixes/components/md.dart";
|
||||
import "package:pixes/components/message.dart";
|
||||
@@ -28,6 +29,10 @@ void main() async {
|
||||
await Translation.init();
|
||||
handleLinks();
|
||||
if (App.isDesktop) {
|
||||
await flutter_acrylic.Window.initialize();
|
||||
if (App.isWindows) {
|
||||
await flutter_acrylic.Window.hideWindowControls();
|
||||
}
|
||||
await WindowManager.instance.ensureInitialized();
|
||||
windowManager.waitUntilReadyToShow().then((_) async {
|
||||
await windowManager.setTitleBarStyle(
|
||||
@@ -109,7 +114,7 @@ class MyApp extends StatelessWidget {
|
||||
throw "widget is null";
|
||||
}
|
||||
|
||||
return MdTheme(
|
||||
Widget widget = MdTheme(
|
||||
data: MdThemeData.from(
|
||||
colorScheme: colorScheme, useMaterial3: true),
|
||||
child: DefaultTextStyle.merge(
|
||||
@@ -119,6 +124,34 @@ class MyApp extends StatelessWidget {
|
||||
child: OverlayWidget(child),
|
||||
),
|
||||
);
|
||||
|
||||
if (App.isWindows) {
|
||||
if (App.windowsVersion == 11) {
|
||||
flutter_acrylic.Window.setEffect(
|
||||
effect: flutter_acrylic.WindowEffect.mica,
|
||||
dark: false);
|
||||
widget = NavigationPaneTheme(
|
||||
data: const NavigationPaneThemeData(
|
||||
backgroundColor: Colors.transparent,
|
||||
),
|
||||
child: widget,
|
||||
);
|
||||
} else if (App.windowsVersion == 10) {
|
||||
flutter_acrylic.Window.setEffect(
|
||||
effect: flutter_acrylic.WindowEffect.acrylic,
|
||||
dark: false);
|
||||
widget = NavigationPaneTheme(
|
||||
data: NavigationPaneThemeData(
|
||||
backgroundColor: FluentTheme.of(context)
|
||||
.micaBackgroundColor
|
||||
.withOpacity(0.05),
|
||||
),
|
||||
child: widget,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return widget;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
@@ -56,6 +56,8 @@ dependencies:
|
||||
flutter_file_dialog: 3.0.1
|
||||
archive: ^3.5.1
|
||||
webview_flutter: ^4.7.0
|
||||
flutter_acrylic: ^1.0.0+2
|
||||
device_info_plus: ^10.1.0
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
Reference in New Issue
Block a user