1
+ import 'package:apidash/widgets/proxy_settings_dialog.dart' ;
1
2
import 'package:flutter/foundation.dart' ;
2
3
import 'package:flutter/material.dart' ;
3
4
import 'package:flutter_riverpod/flutter_riverpod.dart' ;
@@ -7,7 +8,6 @@ import '../services/services.dart';
7
8
import '../utils/utils.dart' ;
8
9
import '../widgets/widgets.dart' ;
9
10
import '../consts.dart' ;
10
- import 'dart:developer' as developer;
11
11
12
12
class SettingsPage extends ConsumerWidget {
13
13
const SettingsPage ({super .key});
@@ -51,75 +51,24 @@ class SettingsPage extends ConsumerWidget {
51
51
ref.read (settingsProvider.notifier).update (isDark: value);
52
52
},
53
53
),
54
- // Proxy Settings Section
55
54
SwitchListTile (
56
- hoverColor : kColorTransparent ,
57
- title : const Text ('Enable Proxy' ),
58
- subtitle : const Text ( 'Configure HTTP proxy settings' ),
59
- value : ref. watch (settingsProvider. select ((settings) => settings.isProxyEnabled)),
60
- onChanged : ( bool ? value) {
61
- if (value != null ) {
62
- developer. log ( 'Toggling proxy settings' , name : 'settings_page' , error : 'New value: $ value ' );
63
- ref. read (settingsProvider.notifier). update (
64
- isProxyEnabled : value,
65
- proxyHost : value ? settings.proxyHost : '' ,
66
- proxyPort : value ? settings.proxyPort : '' ,
67
- proxyUsername : value ? settings.proxyUsername : null ,
68
- proxyPassword : value ? settings.proxyPassword : null ,
55
+ title : const Text ( 'Proxy Settings' ) ,
56
+ subtitle : Text (ref. watch (settingsProvider).proxySettings != null
57
+ ? 'Enabled - ${ ref . watch ( settingsProvider ). proxySettings !. host }:${ ref . watch ( settingsProvider ). proxySettings !. port }'
58
+ : 'Disabled'
59
+ ),
60
+ value : ref. watch (settingsProvider).proxySettings != null ,
61
+ onChanged : ( bool value) {
62
+ if ( ! value) {
63
+ ref. read (settingsProvider.notifier). update (proxySettings : null );
64
+ } else {
65
+ showDialog (
66
+ context : context ,
67
+ builder : (context) => const ProxySettingsDialog () ,
69
68
);
70
- developer.log ('Proxy settings updated' , name: 'settings_page' );
71
69
}
72
70
},
73
71
),
74
- if (ref.watch (settingsProvider.select ((settings) => settings.isProxyEnabled))) ...[
75
- ListTile (
76
- title: TextField (
77
- decoration: const InputDecoration (
78
- labelText: 'Proxy Host' ,
79
- hintText: 'e.g., localhost' ,
80
- ),
81
- controller: TextEditingController (text: settings.proxyHost),
82
- onChanged: (value) {
83
- ref.read (settingsProvider.notifier).update (proxyHost: value);
84
- },
85
- ),
86
- ),
87
- ListTile (
88
- title: TextField (
89
- decoration: const InputDecoration (
90
- labelText: 'Proxy Port' ,
91
- hintText: 'e.g., 8080' ,
92
- ),
93
- controller: TextEditingController (text: settings.proxyPort),
94
- onChanged: (value) {
95
- ref.read (settingsProvider.notifier).update (proxyPort: value);
96
- },
97
- ),
98
- ),
99
- ListTile (
100
- title: TextField (
101
- decoration: const InputDecoration (
102
- labelText: 'Username (Optional)' ,
103
- ),
104
- controller: TextEditingController (text: settings.proxyUsername),
105
- onChanged: (value) {
106
- ref.read (settingsProvider.notifier).update (proxyUsername: value);
107
- },
108
- ),
109
- ),
110
- ListTile (
111
- title: TextField (
112
- decoration: const InputDecoration (
113
- labelText: 'Password (Optional)' ,
114
- ),
115
- obscureText: true ,
116
- controller: TextEditingController (text: settings.proxyPassword),
117
- onChanged: (value) {
118
- ref.read (settingsProvider.notifier).update (proxyPassword: value);
119
- },
120
- ),
121
- ),
122
- ],
123
72
SwitchListTile (
124
73
hoverColor: kColorTransparent,
125
74
title: const Text ('Collection Pane Scrollbar Visiblity' ),
0 commit comments