Skip to content

Commit 438a558

Browse files
committed
fix: proxy toggle button issue solved
1 parent 976fa5a commit 438a558

File tree

2 files changed

+32
-21
lines changed

2 files changed

+32
-21
lines changed

lib/providers/settings_providers.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,24 @@ class ThemeStateNotifier extends StateNotifier<SettingsModel> {
3939
String? proxyUsername,
4040
String? proxyPassword,
4141
}) async {
42-
state = state.copyWith(
43-
isDark: isDark,
44-
alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar,
45-
size: size,
46-
offset: offset,
47-
defaultUriScheme: defaultUriScheme,
48-
defaultCodeGenLang: defaultCodeGenLang,
49-
saveResponses: saveResponses,
50-
promptBeforeClosing: promptBeforeClosing,
51-
activeEnvironmentId: activeEnvironmentId,
52-
historyRetentionPeriod: historyRetentionPeriod,
53-
workspaceFolderPath: workspaceFolderPath,
54-
isSSLDisabled: isSSLDisabled,
55-
isProxyEnabled: isProxyEnabled,
56-
proxyHost: proxyHost,
57-
proxyPort: proxyPort,
58-
proxyUsername: proxyUsername,
59-
proxyPassword: proxyPassword,
42+
state = SettingsModel(
43+
isDark: isDark ?? state.isDark,
44+
alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar ?? state.alwaysShowCollectionPaneScrollbar,
45+
size: size ?? state.size,
46+
offset: offset ?? state.offset,
47+
defaultUriScheme: defaultUriScheme ?? state.defaultUriScheme,
48+
defaultCodeGenLang: defaultCodeGenLang ?? state.defaultCodeGenLang,
49+
saveResponses: saveResponses ?? state.saveResponses,
50+
promptBeforeClosing: promptBeforeClosing ?? state.promptBeforeClosing,
51+
activeEnvironmentId: activeEnvironmentId ?? state.activeEnvironmentId,
52+
historyRetentionPeriod: historyRetentionPeriod ?? state.historyRetentionPeriod,
53+
workspaceFolderPath: workspaceFolderPath ?? state.workspaceFolderPath,
54+
isSSLDisabled: isSSLDisabled ?? state.isSSLDisabled,
55+
isProxyEnabled: isProxyEnabled ?? state.isProxyEnabled,
56+
proxyHost: proxyHost ?? state.proxyHost,
57+
proxyPort: proxyPort ?? state.proxyPort,
58+
proxyUsername: proxyUsername ?? state.proxyUsername,
59+
proxyPassword: proxyPassword ?? state.proxyPassword,
6060
);
6161
await setSettingsToSharedPrefs(state);
6262
}

lib/screens/settings_page.dart

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import '../services/services.dart';
77
import '../utils/utils.dart';
88
import '../widgets/widgets.dart';
99
import '../consts.dart';
10+
import 'dart:developer' as developer;
1011

1112
class SettingsPage extends ConsumerWidget {
1213
const SettingsPage({super.key});
@@ -55,12 +56,22 @@ class SettingsPage extends ConsumerWidget {
5556
hoverColor: kColorTransparent,
5657
title: const Text('Enable Proxy'),
5758
subtitle: const Text('Configure HTTP proxy settings'),
58-
value: settings.isProxyEnabled,
59+
value: ref.watch(settingsProvider.select((settings) => settings.isProxyEnabled)),
5960
onChanged: (bool? value) {
60-
ref.read(settingsProvider.notifier).update(isProxyEnabled: 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,
69+
);
70+
developer.log('Proxy settings updated', name: 'settings_page');
71+
}
6172
},
6273
),
63-
if (settings.isProxyEnabled) ...[
74+
if (ref.watch(settingsProvider.select((settings) => settings.isProxyEnabled))) ...[
6475
ListTile(
6576
title: TextField(
6677
decoration: const InputDecoration(

0 commit comments

Comments
 (0)