proxy private tabs

This commit is contained in:
Fabian Freund
2025-06-23 22:05:59 +02:00
parent 9c6c50b0da
commit 9e785b7984
9 changed files with 125 additions and 14 deletions
@@ -2,7 +2,10 @@ import 'package:flutter/material.dart';
import 'package:flutter_material_design_icons/flutter_material_design_icons.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:weblibre/features/settings/presentation/controllers/save_settings.dart';
import 'package:weblibre/features/tor/domain/services/tor_proxy.dart';
import 'package:weblibre/features/user/data/models/general_settings.dart';
import 'package:weblibre/features/user/domain/repositories/general_settings.dart';
import 'package:weblibre/presentation/hooks/on_initialization.dart';
class TorProxyScreen extends HookConsumerWidget {
@@ -11,6 +14,11 @@ class TorProxyScreen extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final torProxyPort = ref.watch(torProxyServiceProvider);
final proxyPrivateTabsTor = ref.watch(
generalSettingsRepositoryProvider.select(
(value) => value.proxyPrivateTabsTor,
),
);
useOnInitialization(() async {
await ref.read(torProxyServiceProvider.notifier).requestSync();
@@ -77,6 +85,55 @@ class TorProxyScreen extends HookConsumerWidget {
},
),
),
ListTileTheme(
iconColor: Colors.white,
textColor: Colors.white,
child: SwitchListTile.adaptive(
inactiveThumbColor: Colors.white,
activeColor: const Color(0xFF68B030),
trackColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.isEmpty) {
return const Color(0xFF333A41);
}
return null; // Use the default color.
}),
trackOutlineColor:
WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.isEmpty) {
return Colors.white;
}
return null; // Use the default color.
}),
thumbIcon: WidgetStateProperty.resolveWith<Icon?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.selected)) {
return const Icon(MdiIcons.incognito);
}
return null; // Use the default color.
}),
value: proxyPrivateTabsTor,
title: const Text('Proxy Private Tabs'),
subtitle: const Text(
'When enabled, all Private Tabs will be tunneled through Tor',
),
secondary: const Icon(MdiIcons.arrowDecision),
onChanged: (value) async {
await ref
.read(
saveGeneralSettingsControllerProvider.notifier,
)
.save(
(currentSettings) => currentSettings.copyWith
.proxyPrivateTabsTor(value),
);
},
),
),
],
),
),
@@ -87,6 +144,7 @@ class TorProxyScreen extends HookConsumerWidget {
const Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(height: 8),
LinearProgressIndicator(
backgroundColor: Color(0xFF333A41),
color: Color(0xFF68B030),