Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Proxy Configuration #544

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: proxy toggle button issue solved
abhinavs1920 committed Jan 22, 2025
commit 24d775bab923e9cef7a34606ece75c41f3ade1cb
36 changes: 18 additions & 18 deletions lib/providers/settings_providers.dart
Original file line number Diff line number Diff line change
@@ -39,24 +39,24 @@ class ThemeStateNotifier extends StateNotifier<SettingsModel> {
String? proxyUsername,
String? proxyPassword,
}) async {
state = state.copyWith(
isDark: isDark,
alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar,
size: size,
offset: offset,
defaultUriScheme: defaultUriScheme,
defaultCodeGenLang: defaultCodeGenLang,
saveResponses: saveResponses,
promptBeforeClosing: promptBeforeClosing,
activeEnvironmentId: activeEnvironmentId,
historyRetentionPeriod: historyRetentionPeriod,
workspaceFolderPath: workspaceFolderPath,
isSSLDisabled: isSSLDisabled,
isProxyEnabled: isProxyEnabled,
proxyHost: proxyHost,
proxyPort: proxyPort,
proxyUsername: proxyUsername,
proxyPassword: proxyPassword,
state = SettingsModel(
isDark: isDark ?? state.isDark,
alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar ?? state.alwaysShowCollectionPaneScrollbar,
size: size ?? state.size,
offset: offset ?? state.offset,
defaultUriScheme: defaultUriScheme ?? state.defaultUriScheme,
defaultCodeGenLang: defaultCodeGenLang ?? state.defaultCodeGenLang,
saveResponses: saveResponses ?? state.saveResponses,
promptBeforeClosing: promptBeforeClosing ?? state.promptBeforeClosing,
activeEnvironmentId: activeEnvironmentId ?? state.activeEnvironmentId,
historyRetentionPeriod: historyRetentionPeriod ?? state.historyRetentionPeriod,
workspaceFolderPath: workspaceFolderPath ?? state.workspaceFolderPath,
isSSLDisabled: isSSLDisabled ?? state.isSSLDisabled,
isProxyEnabled: isProxyEnabled ?? state.isProxyEnabled,
proxyHost: proxyHost ?? state.proxyHost,
proxyPort: proxyPort ?? state.proxyPort,
proxyUsername: proxyUsername ?? state.proxyUsername,
proxyPassword: proxyPassword ?? state.proxyPassword,
);
await setSettingsToSharedPrefs(state);
}
17 changes: 14 additions & 3 deletions lib/screens/settings_page.dart
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import '../services/services.dart';
import '../utils/utils.dart';
import '../widgets/widgets.dart';
import '../consts.dart';
import 'dart:developer' as developer;

class SettingsPage extends ConsumerWidget {
const SettingsPage({super.key});
@@ -55,12 +56,22 @@ class SettingsPage extends ConsumerWidget {
hoverColor: kColorTransparent,
title: const Text('Enable Proxy'),
subtitle: const Text('Configure HTTP proxy settings'),
value: settings.isProxyEnabled,
value: ref.watch(settingsProvider.select((settings) => settings.isProxyEnabled)),
onChanged: (bool? value) {
ref.read(settingsProvider.notifier).update(isProxyEnabled: value);
if (value != null) {
developer.log('Toggling proxy settings', name: 'settings_page', error: 'New value: $value');
ref.read(settingsProvider.notifier).update(
isProxyEnabled: value,
proxyHost: value ? settings.proxyHost : '',
proxyPort: value ? settings.proxyPort : '',
proxyUsername: value ? settings.proxyUsername : null,
proxyPassword: value ? settings.proxyPassword : null,
);
developer.log('Proxy settings updated', name: 'settings_page');
}
},
),
if (settings.isProxyEnabled) ...[
if (ref.watch(settingsProvider.select((settings) => settings.isProxyEnabled))) ...[
ListTile(
title: TextField(
decoration: const InputDecoration(