Skip to content

Commit 866fbb7

Browse files
committed
Fix windows tray issues
Support setting bypassDomain Update flutter version
1 parent 3baa26e commit 866fbb7

36 files changed

+1456
-488
lines changed

lib/common/color.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ extension ColorSchemeExtension on ColorScheme {
2929
ColorScheme toPrueBlack(bool isPrueBlack) => isPrueBlack
3030
? copyWith(
3131
surface: Colors.black,
32-
background: Colors.black,
3332
surfaceContainer: surfaceContainer.darken(0.05),
3433
)
3534
: this;

lib/common/link.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'dart:async';
22

33
import 'package:app_links/app_links.dart';
4-
import 'package:flutter/cupertino.dart';
4+
import 'package:flutter/material.dart';
55

66
typedef InstallConfigCallBack = void Function(String url);
77

lib/controller.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ class AppController {
528528
}
529529

530530
updateSystemProxy() {
531-
config.desktopProps = config.desktopProps.copyWith(
532-
systemProxy: !config.desktopProps.systemProxy,
531+
config.networkProps = config.networkProps.copyWith(
532+
systemProxy: !config.networkProps.systemProxy,
533533
);
534534
}
535535

lib/fragments/config/config.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class _ConfigFragmentState extends State<ConfigFragment> {
2424
title: appLocalizations.network,
2525
isScaffold: true,
2626
isBlur: false,
27+
extendPageWidth: 360,
2728
widget: const NetworkListView(),
2829
),
2930
),

lib/fragments/config/network.dart

Lines changed: 78 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class TUNItem extends StatelessWidget {
3939

4040
@override
4141
Widget build(BuildContext context) {
42-
return Selector<Config, bool>(
43-
selector: (_, config) => config.vpnProps.enable,
42+
return Selector<ClashConfig, bool>(
43+
selector: (_, clashConfig) => clashConfig.tun.enable,
4444
builder: (_, enable, __) {
4545
return ListItem.switchItem(
4646
title: Text(appLocalizations.tun),
@@ -87,8 +87,8 @@ class AllowBypassSwitch extends StatelessWidget {
8787
}
8888
}
8989

90-
class SystemProxySwitch extends StatelessWidget {
91-
const SystemProxySwitch({super.key});
90+
class VpnSystemProxySwitch extends StatelessWidget {
91+
const VpnSystemProxySwitch({super.key});
9292

9393
@override
9494
Widget build(BuildContext context) {
@@ -114,6 +114,33 @@ class SystemProxySwitch extends StatelessWidget {
114114
}
115115
}
116116

117+
class SystemProxySwitch extends StatelessWidget {
118+
const SystemProxySwitch({super.key});
119+
120+
@override
121+
Widget build(BuildContext context) {
122+
return Selector<Config, bool>(
123+
selector: (_, config) => config.networkProps.systemProxy,
124+
builder: (_, systemProxy, __) {
125+
return ListItem.switchItem(
126+
title: Text(appLocalizations.systemProxy),
127+
subtitle: Text(appLocalizations.systemProxyDesc),
128+
delegate: SwitchDelegate(
129+
value: systemProxy,
130+
onChanged: (bool value) async {
131+
final config = globalState.appController.config;
132+
final networkProps = config.networkProps;
133+
config.networkProps = networkProps.copyWith(
134+
systemProxy: value,
135+
);
136+
},
137+
),
138+
);
139+
},
140+
);
141+
}
142+
}
143+
117144
class Ipv6Switch extends StatelessWidget {
118145
const Ipv6Switch({super.key});
119146

@@ -176,26 +203,57 @@ class TunStackItem extends StatelessWidget {
176203
class BypassDomainItem extends StatelessWidget {
177204
const BypassDomainItem({super.key});
178205

206+
_initActions(BuildContext context) {
207+
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
208+
final commonScaffoldState =
209+
context.findAncestorStateOfType<CommonScaffoldState>();
210+
commonScaffoldState?.actions = [
211+
IconButton(
212+
onPressed: () {
213+
globalState.showMessage(
214+
title: appLocalizations.reset,
215+
message: TextSpan(
216+
text: appLocalizations.resetTip,
217+
),
218+
onTab: () {
219+
final config = globalState.appController.config;
220+
config.networkProps = config.networkProps.copyWith(
221+
bypassDomain: defaultBypassDomain,
222+
);
223+
Navigator.of(context).pop();
224+
},
225+
);
226+
},
227+
tooltip: appLocalizations.reset,
228+
icon: const Icon(
229+
Icons.replay,
230+
),
231+
)
232+
];
233+
});
234+
}
235+
179236
@override
180237
Widget build(BuildContext context) {
181238
return ListItem.open(
182239
title: Text(appLocalizations.bypassDomain),
183240
subtitle: Text(appLocalizations.bypassDomainDesc),
184241
delegate: OpenDelegate(
185242
isBlur: false,
243+
isScaffold: true,
186244
title: appLocalizations.bypassDomain,
187245
widget: Selector<Config, List<String>>(
188-
selector: (_, config) => config.vpnProps.bypassDomain,
189-
shouldRebuild: (prev, next) =>
190-
!stringListEquality.equals(prev, next),
191-
builder: (_, bypassDomain, __) {
246+
selector: (_, config) => config.networkProps.bypassDomain,
247+
shouldRebuild: (prev, next) => !stringListEquality.equals(prev, next),
248+
builder: (context, bypassDomain, __) {
249+
_initActions(context);
192250
return ListPage(
193251
title: appLocalizations.bypassDomain,
194252
items: bypassDomain,
195253
titleBuilder: (item) => Text(item),
196-
onChange: (items){
254+
onChange: (items) {
197255
final config = globalState.appController.config;
198-
config.vpnProps = config.vpnProps.copyWith(
256+
config.networkProps = config.networkProps.copyWith(
199257
bypassDomain: List.from(items),
200258
);
201259
},
@@ -209,20 +267,28 @@ class BypassDomainItem extends StatelessWidget {
209267
}
210268

211269
final networkItems = [
212-
Platform.isAndroid ? const VPNSwitch() : const TUNItem(),
270+
if (Platform.isAndroid) const VPNSwitch(),
213271
if (Platform.isAndroid)
214272
...generateSection(
215273
title: "VPN",
216274
items: [
217275
const SystemProxySwitch(),
218276
const AllowBypassSwitch(),
219277
const Ipv6Switch(),
220-
const BypassDomainItem(),
278+
],
279+
),
280+
if (system.isDesktop)
281+
...generateSection(
282+
title: appLocalizations.system,
283+
items: [
284+
SystemProxySwitch(),
285+
BypassDomainItem(),
221286
],
222287
),
223288
...generateSection(
224289
title: appLocalizations.options,
225290
items: [
291+
if (system.isDesktop) const TUNItem(),
226292
const TunStackItem(),
227293
],
228294
),

lib/fragments/dashboard/dashboard.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
import 'dart:io';
12
import 'dart:math';
23

34
import 'package:fl_clash/common/common.dart';
45
import 'package:fl_clash/fragments/dashboard/intranet_ip.dart';
56
import 'package:fl_clash/fragments/dashboard/status_switch.dart';
67
import 'package:fl_clash/models/models.dart';
7-
import 'package:flutter/material.dart';
88
import 'package:fl_clash/widgets/widgets.dart';
9+
import 'package:flutter/material.dart';
910
import 'package:provider/provider.dart';
11+
1012
import 'network_detection.dart';
13+
import 'network_speed.dart';
1114
import 'outbound_mode.dart';
1215
import 'start_button.dart';
13-
import 'network_speed.dart';
1416
import 'traffic_usage.dart';
1517

1618
class DashboardFragment extends StatefulWidget {
@@ -22,7 +24,7 @@ class DashboardFragment extends StatefulWidget {
2224

2325
class _DashboardFragmentState extends State<DashboardFragment> {
2426
_initFab(bool isCurrent) {
25-
if(!isCurrent){
27+
if (!isCurrent) {
2628
return;
2729
}
2830
WidgetsBinding.instance.addPostFrameCallback((_) {
@@ -66,10 +68,11 @@ class _DashboardFragmentState extends State<DashboardFragment> {
6668
// child: const VPNSwitch(),
6769
// ),
6870
if (system.isDesktop) ...[
69-
GridItem(
70-
crossAxisCellCount: switchCount,
71-
child: const TUNSwitch(),
72-
),
71+
if (Platform.isWindows)
72+
GridItem(
73+
crossAxisCellCount: switchCount,
74+
child: const TUNSwitch(),
75+
),
7376
GridItem(
7477
crossAxisCellCount: switchCount,
7578
child: const ProxySwitch(),

lib/fragments/dashboard/status_switch.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ class ProxySwitch extends StatelessWidget {
7575
iconData: Icons.shuffle,
7676
),
7777
child: Selector<Config, bool>(
78-
selector: (_, config) => config.desktopProps.systemProxy,
78+
selector: (_, config) => config.networkProps.systemProxy,
7979
builder: (_, systemProxy, __) {
8080
return LocaleBuilder(
8181
builder: (_) => Switch(
8282
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
8383
value: systemProxy,
8484
onChanged: (value) {
8585
final config = globalState.appController.config;
86-
config.desktopProps =
87-
config.desktopProps.copyWith(systemProxy: value);
86+
config.networkProps =
87+
config.networkProps.copyWith(systemProxy: value);
8888
},
8989
),
9090
);

lib/l10n/arb/intl_en.arb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
"ipv6Desc": "When turned on it will be able to receive IPv6 traffic",
169169
"app": "App",
170170
"general": "General",
171+
"vpnSystemProxyDesc": "Attach HTTP proxy to VpnService",
171172
"systemProxyDesc": "Attach HTTP proxy to VpnService",
172173
"unifiedDelay": "Unified delay",
173174
"unifiedDelayDesc": "Remove extra delays such as handshaking",
@@ -323,5 +324,6 @@
323324
"adminAutoLaunchDesc": "Boot up by using admin mode",
324325
"fontFamily": "FontFamily",
325326
"systemFont": "System font",
326-
"toggle": "Toggle"
327+
"toggle": "Toggle",
328+
"system": "System"
327329
}

lib/l10n/arb/intl_zh_CN.arb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@
168168
"ipv6Desc": "开启后将可以接收IPv6流量",
169169
"app": "应用",
170170
"general": "基础",
171-
"systemProxyDesc": "为VpnService附加HTTP代理",
171+
"vpnSystemProxyDesc": "为VpnService附加HTTP代理",
172+
"systemProxyDesc": "设置系统代理",
172173
"unifiedDelay": "统一延迟",
173174
"unifiedDelayDesc": "去除握手等额外延迟",
174175
"tcpConcurrent": "TCP并发",
@@ -323,5 +324,6 @@
323324
"adminAutoLaunchDesc": "使用管理员模式开机自启动",
324325
"fontFamily": "字体",
325326
"systemFont": "系统字体",
326-
"toggle": "切换"
327+
"toggle": "切换",
328+
"system": "系统"
327329
}

lib/l10n/intl/messages_en.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ class MessageLookup extends MessageLookupByLibrary {
426426
"style": MessageLookupByLibrary.simpleMessage("Style"),
427427
"submit": MessageLookupByLibrary.simpleMessage("Submit"),
428428
"sync": MessageLookupByLibrary.simpleMessage("Sync"),
429+
"system": MessageLookupByLibrary.simpleMessage("System"),
429430
"systemFont": MessageLookupByLibrary.simpleMessage("System font"),
430431
"systemProxy": MessageLookupByLibrary.simpleMessage("System proxy"),
431432
"systemProxyDesc": MessageLookupByLibrary.simpleMessage(
@@ -475,6 +476,8 @@ class MessageLookup extends MessageLookupByLibrary {
475476
MessageLookupByLibrary.simpleMessage("Modify VPN related settings"),
476477
"vpnEnableDesc": MessageLookupByLibrary.simpleMessage(
477478
"Auto routes all system traffic through VpnService"),
479+
"vpnSystemProxyDesc": MessageLookupByLibrary.simpleMessage(
480+
"Attach HTTP proxy to VpnService"),
478481
"vpnTip": MessageLookupByLibrary.simpleMessage(
479482
"Changes take effect after restarting the VPN"),
480483
"webDAVConfiguration":

0 commit comments

Comments
 (0)