@@ -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+
117144class Ipv6Switch extends StatelessWidget {
118145 const Ipv6Switch ({super .key});
119146
@@ -176,26 +203,57 @@ class TunStackItem extends StatelessWidget {
176203class 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
211269final 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 ),
0 commit comments