Skip to content

Commit 812f60b

Browse files
committed
Windows优化
1 parent e603242 commit 812f60b

File tree

9 files changed

+100
-39
lines changed

9 files changed

+100
-39
lines changed

.gradle/config.properties

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#Tue Jul 09 13:58:48 CST 2024
2+
java.home=D\:\\Program Files\\Android\\Android Studio\\jbr

android/app/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ android {
3737
ndkVersion flutter.ndkVersion
3838

3939
compileOptions {
40-
sourceCompatibility JavaVersion.VERSION_1_8
41-
targetCompatibility JavaVersion.VERSION_1_8
40+
sourceCompatibility JavaVersion.VERSION_17
41+
targetCompatibility JavaVersion.VERSION_17
4242
}
4343

4444
kotlinOptions {
45-
jvmTarget = '1.8'
45+
jvmTarget = '17'
4646
}
4747

4848
android.buildFeatures.buildConfig true

android/local.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
sdk.dir=/Users/Waiting/Library/Android/sdk
2-
flutter.sdk=/Users/Waiting/Library/flutter
1+
sdk.dir=D:/Android/Sdk
2+
flutter.sdk=D:\\flutter_windows_3.22.2-stable\\flutter
33
flutter.buildMode=debug
44
flutter.versionName=1.0.0
55
flutter.versionCode=3

assets/ic_logo.ico

720 Bytes
Binary file not shown.

lib/main.dart

+16-9
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ void main() async {
4343
);
4444
} else {
4545
windowManager.ensureInitialized();
46-
WindowOptions windowOptions = const WindowOptions(
47-
size: Size(950, 650),
48-
minimumSize: Size(800, 600),
46+
WindowOptions windowOptions = WindowOptions(
47+
size: const Size(950, 650),
48+
minimumSize: const Size(800, 600),
4949
center: true,
5050
backgroundColor: Colors.transparent,
5151
windowButtonVisibility: true,
5252
skipTaskbar: false,
53-
titleBarStyle: TitleBarStyle.hidden,
53+
titleBarStyle:
54+
PlatformUtil.isMacOS ? TitleBarStyle.hidden : TitleBarStyle.normal,
5455
);
5556
windowManager.waitUntilReadyToShow(windowOptions, () async {
5657
await windowManager.show();
@@ -73,7 +74,8 @@ void main() async {
7374
}
7475

7576
if (Storage().getString(StorageKeys.CACHE_DIR_KEY) == null) {
76-
Storage().set(StorageKeys.CACHE_DIR_KEY, (await getApplicationDocumentsDirectory()).path);
77+
Storage().set(StorageKeys.CACHE_DIR_KEY,
78+
(await getApplicationDocumentsDirectory()).path);
7779
}
7880
}
7981

@@ -88,7 +90,8 @@ class _MyAppState extends State<MyApp> {
8890
@override
8991
Widget build(BuildContext context) {
9092
ScreenUtil.init(context, designSize: const Size(750, 1378));
91-
return Consumer2<ThemeManager, LocaleManager>(builder: (context, themeManager, localeManager, _) {
93+
return Consumer2<ThemeManager, LocaleManager>(
94+
builder: (context, themeManager, localeManager, _) {
9295
return MaterialApp(
9396
debugShowCheckedModeBanner: false,
9497
themeMode: themeManager.currentTheme,
@@ -129,7 +132,8 @@ class _MainPageState extends State<MainPage> {
129132
@override
130133
void initState() {
131134
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
132-
systemNavigationBarColor: Theme.of(context).scaffoldBackgroundColor, statusBarColor: Colors.transparent));
135+
systemNavigationBarColor: Theme.of(context).scaffoldBackgroundColor,
136+
statusBarColor: Colors.transparent));
133137

134138
drawerIndex = DrawerIndex.Home;
135139
screenView = const HomePage();
@@ -143,7 +147,9 @@ class _MainPageState extends State<MainPage> {
143147
var brightness = MediaQuery.of(context).platformBrightness;
144148
bool isLightMode = brightness == Brightness.light;
145149
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
146-
systemNavigationBarColor: isLightMode ? AppTheme.nearlyWhite : AppTheme.nearlyBlack, statusBarColor: Colors.transparent));
150+
systemNavigationBarColor:
151+
isLightMode ? AppTheme.nearlyWhite : AppTheme.nearlyBlack,
152+
statusBarColor: Colors.transparent));
147153

148154
return SafeArea(
149155
top: false,
@@ -212,7 +218,8 @@ class _MainPageState extends State<MainPage> {
212218
}
213219

214220
void _showAppReview() async {
215-
if (!Storage().getBool(StorageKeys.SHOW_APPREVIEW_KEY) && (PlatformUtil.isMobile || PlatformUtil.isMacOS)) {
221+
if (!Storage().getBool(StorageKeys.SHOW_APPREVIEW_KEY) &&
222+
(PlatformUtil.isMobile || PlatformUtil.isMacOS)) {
216223
if (await InAppReview.instance.isAvailable()) {
217224
if (PlatformUtil.isIOS || PlatformUtil.isMacOS) {
218225
InAppReview.instance.openStoreListing(appStoreId: '6503423677');

lib/screen/desktop/pages/home_page.dart

+36-13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:package_info_plus/package_info_plus.dart';
33
import 'package:tubesavely/generated/l10n.dart';
44
import 'package:tubesavely/screen/desktop/main.dart';
5+
import 'package:tubesavely/utils/platform_util.dart';
56

67
import 'convert_page.dart';
78
import 'download_page.dart';
@@ -27,16 +28,23 @@ class _HomePageState extends State<HomePage> {
2728
@override
2829
void initState() {
2930
super.initState();
30-
currentSegment = pages.first is DownloadPage ? SegmentType.download : SegmentType.convert;
31+
currentSegment = pages.first is DownloadPage
32+
? SegmentType.download
33+
: SegmentType.convert;
3134
buttonSegments = pages
3235
.map((item) => ButtonSegment<SegmentType>(
33-
value: item is DownloadPage ? SegmentType.download : SegmentType.convert,
36+
value: item is DownloadPage
37+
? SegmentType.download
38+
: SegmentType.convert,
3439
label: Container(
35-
padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 5),
40+
padding:
41+
const EdgeInsets.symmetric(horizontal: 25, vertical: 5),
3642
child: Row(
3743
children: [
3844
Icon(
39-
item is DownloadPage ? Icons.save_alt : Icons.cached_outlined,
45+
item is DownloadPage
46+
? Icons.save_alt
47+
: Icons.cached_outlined,
4048
size: 25,
4149
),
4250
// Text(
@@ -57,7 +65,8 @@ class _HomePageState extends State<HomePage> {
5765
top: true,
5866
child: Scaffold(
5967
body: Container(
60-
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
68+
padding: EdgeInsets.symmetric(
69+
vertical: PlatformUtil.isMacOS ? 10 : 0, horizontal: 10),
6170
color: Theme.of(context).colorScheme.surface,
6271
child: Column(
6372
children: [
@@ -68,14 +77,17 @@ class _HomePageState extends State<HomePage> {
6877
const SizedBox(
6978
width: 60,
7079
height: 80,
71-
child: Image(image: AssetImage('assets/images/ic_logo.png')),
80+
child: Image(
81+
image: AssetImage('assets/images/ic_logo.png')),
7282
),
7383
const SizedBox(
7484
width: 10,
7585
),
7686
Text(
7787
S.current.appName,
78-
style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontSize: 20),
88+
style: TextStyle(
89+
color: Theme.of(context).colorScheme.onSurface,
90+
fontSize: 20),
7991
),
8092
const SizedBox(
8193
width: 5,
@@ -85,7 +97,8 @@ class _HomePageState extends State<HomePage> {
8597
builder: (context, snapshot) {
8698
return Text(
8799
'${snapshot.data?.version}',
88-
style: const TextStyle(fontSize: 15, color: Colors.grey),
100+
style: const TextStyle(
101+
fontSize: 15, color: Colors.grey),
89102
);
90103
}),
91104
],
@@ -100,15 +113,19 @@ class _HomePageState extends State<HomePage> {
100113
shape: RoundedRectangleBorder(
101114
borderRadius: BorderRadius.circular(50.0),
102115
),
103-
side: BorderSide(width: 0.5, color: Theme.of(context).primaryColor),
104-
selectedBackgroundColor: Theme.of(context).primaryColor,
116+
side: BorderSide(
117+
width: 0.5,
118+
color: Theme.of(context).primaryColor),
119+
selectedBackgroundColor:
120+
Theme.of(context).primaryColor,
105121
selectedForegroundColor: Colors.white,
106122
foregroundColor: Theme.of(context).primaryColor,
107123
),
108124
segments: buttonSegments,
109125
showSelectedIcon: false,
110126
selected: {currentSegment},
111-
onSelectionChanged: (Set<SegmentType> newSelection) {
127+
onSelectionChanged:
128+
(Set<SegmentType> newSelection) {
112129
setState(() {
113130
currentSegment = newSelection.first;
114131
controller.jumpToPage(currentSegment.index);
@@ -127,15 +144,21 @@ class _HomePageState extends State<HomePage> {
127144
},
128145
icon: Icon(
129146
Icons.settings,
130-
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
147+
color: Theme.of(context)
148+
.colorScheme
149+
.onSurface
150+
.withOpacity(0.5),
131151
)),
132152
IconButton(
133153
onPressed: () {
134154
showAppAboutDialog(context);
135155
},
136156
icon: Icon(
137157
Icons.info_outlined,
138-
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
158+
color: Theme.of(context)
159+
.colorScheme
160+
.onSurface
161+
.withOpacity(0.5),
139162
))
140163
],
141164
)),

pubspec.lock

+36-12
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,18 @@ packages:
165165
dependency: "direct main"
166166
description:
167167
name: dio
168-
sha256: "11e40df547d418cc0c4900a9318b26304e665da6fa4755399a9ff9efd09034b5"
168+
sha256: e17f6b3097b8c51b72c74c9f071a605c47bcc8893839bd66732457a5ebe73714
169169
url: "https://pub.dev"
170170
source: hosted
171-
version: "5.4.3+1"
171+
version: "5.5.0+1"
172+
dio_web_adapter:
173+
dependency: transitive
174+
description:
175+
name: dio_web_adapter
176+
sha256: "36c5b2d79eb17cdae41e974b7a8284fec631651d2a6f39a8a2ff22327e90aeac"
177+
url: "https://pub.dev"
178+
source: hosted
179+
version: "1.0.1"
172180
dropdown_button2:
173181
dependency: "direct main"
174182
description:
@@ -221,10 +229,10 @@ packages:
221229
dependency: "direct main"
222230
description:
223231
name: file_picker
224-
sha256: "2ca051989f69d1b2ca012b2cf3ccf78c70d40144f0861ff2c063493f7c8c3d45"
232+
sha256: "824f5b9f389bfc4dddac3dea76cd70c51092d9dff0b2ece7ef4f53db8547d258"
225233
url: "https://pub.dev"
226234
source: hosted
227-
version: "8.0.5"
235+
version: "8.0.6"
228236
fixnum:
229237
dependency: transitive
230238
description:
@@ -274,10 +282,10 @@ packages:
274282
dependency: "direct dev"
275283
description:
276284
name: flutter_lints
277-
sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
285+
sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c"
278286
url: "https://pub.dev"
279287
source: hosted
280-
version: "2.0.3"
288+
version: "4.0.0"
281289
flutter_localizations:
282290
dependency: "direct main"
283291
description: flutter
@@ -365,6 +373,22 @@ packages:
365373
url: "https://pub.dev"
366374
source: hosted
367375
version: "2.0.3"
376+
in_app_review:
377+
dependency: "direct main"
378+
description:
379+
name: in_app_review
380+
sha256: "99869244d09adc76af16bf8fd731dd13cef58ecafd5917847589c49f378cbb30"
381+
url: "https://pub.dev"
382+
source: hosted
383+
version: "2.0.9"
384+
in_app_review_platform_interface:
385+
dependency: transitive
386+
description:
387+
name: in_app_review_platform_interface
388+
sha256: fed2c755f2125caa9ae10495a3c163aa7fab5af3585a9c62ef4a6920c5b45f10
389+
url: "https://pub.dev"
390+
source: hosted
391+
version: "2.0.5"
368392
intl:
369393
dependency: "direct main"
370394
description:
@@ -425,10 +449,10 @@ packages:
425449
dependency: transitive
426450
description:
427451
name: lints
428-
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
452+
sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235"
429453
url: "https://pub.dev"
430454
source: hosted
431-
version: "2.1.1"
455+
version: "4.0.0"
432456
logging:
433457
dependency: transitive
434458
description:
@@ -617,10 +641,10 @@ packages:
617641
dependency: transitive
618642
description:
619643
name: path_provider_android
620-
sha256: bca87b0165ffd7cdb9cad8edd22d18d2201e886d9a9f19b4fb3452ea7df3a72a
644+
sha256: "30c5aa827a6ae95ce2853cdc5fe3971daaac00f6f081c419c013f7f57bff2f5e"
621645
url: "https://pub.dev"
622646
source: hosted
623-
version: "2.2.6"
647+
version: "2.2.7"
624648
path_provider_foundation:
625649
dependency: transitive
626650
description:
@@ -934,10 +958,10 @@ packages:
934958
dependency: transitive
935959
description:
936960
name: sqlite3
937-
sha256: b384f598b813b347c5a7e5ffad82cbaff1bec3d1561af267041e66f6f0899295
961+
sha256: "6d17989c0b06a5870b2190d391925186f944cb943e5262d0d3f778fcfca3bc6e"
938962
url: "https://pub.dev"
939963
source: hosted
940-
version: "2.4.3"
964+
version: "2.4.4"
941965
stack_trace:
942966
dependency: transitive
943967
description:

windows/flutter/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ include(${EPHEMERAL_DIR}/generated_config.cmake)
1010
# https://github.com/flutter/flutter/issues/57146.
1111
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
1212

13+
# Set fallback configurations for older versions of the flutter tool.
14+
if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
15+
set(FLUTTER_TARGET_PLATFORM "windows-x64")
16+
endif()
17+
1318
# === Flutter Library ===
1419
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
1520

windows/runner/resources/app_icon.ico

-433 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)