respect tor mark

This commit is contained in:
Fabian Freund
2025-07-17 15:52:50 +02:00
parent 36d097486d
commit cb0eef7eb8
3 changed files with 162 additions and 146 deletions
@@ -270,7 +270,7 @@ class BrowserBottomAppBar extends HookConsumerWidget {
await TorProxyRoute().push(context); await TorProxyRoute().push(context);
}, },
leadingIcon: const Icon(TorIcons.onionAlt), leadingIcon: const Icon(TorIcons.onionAlt),
child: const Text('Tor'), child: const Text('Tor™ Proxy'),
), ),
const Divider(), const Divider(),
MenuItemButton( MenuItemButton(
@@ -1,12 +1,12 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_material_design_icons/flutter_material_design_icons.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:hooks_riverpod/hooks_riverpod.dart';
import 'package:weblibre/features/settings/presentation/controllers/save_settings.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/tor/domain/services/tor_proxy.dart';
import 'package:weblibre/features/user/data/models/general_settings.dart'; import 'package:weblibre/features/user/data/models/general_settings.dart';
import 'package:weblibre/features/user/domain/repositories/general_settings.dart'; import 'package:weblibre/features/user/domain/repositories/general_settings.dart';
import 'package:weblibre/presentation/hooks/on_initialization.dart'; import 'package:weblibre/presentation/hooks/on_initialization.dart';
import 'package:weblibre/presentation/icons/tor_icons.dart';
class TorProxyScreen extends HookConsumerWidget { class TorProxyScreen extends HookConsumerWidget {
const TorProxyScreen(); const TorProxyScreen();
@@ -25,161 +25,177 @@ class TorProxyScreen extends HookConsumerWidget {
}); });
return Scaffold( return Scaffold(
appBar: AppBar(title: const Text('Tor Proxy')), appBar: AppBar(title: const Text('Tor Proxy')),
body: ColoredBox( body: SafeArea(
color: const Color(0xFF7D4698), child: ColoredBox(
child: Column( color: const Color(0xFF7D4698),
children: [ child: Column(
Flexible( children: [
child: Column( Flexible(
mainAxisAlignment: MainAxisAlignment.end, child: Column(
children: [ mainAxisAlignment: MainAxisAlignment.end,
SvgPicture.asset('assets/images/tor_white.svg', width: 200), children: [
const SizedBox(height: 16), const Icon(TorIcons.onionAlt, size: 84),
ListTileTheme( const SizedBox(height: 16),
iconColor: Colors.white, ListTileTheme(
textColor: Colors.white, iconColor: Colors.white,
child: SwitchListTile.adaptive( textColor: Colors.white,
inactiveThumbColor: Colors.white, child: SwitchListTile.adaptive(
activeColor: const Color(0xFF68B030), inactiveThumbColor: Colors.white,
trackColor: WidgetStateProperty.resolveWith<Color?>(( activeColor: const Color(0xFF68B030),
Set<WidgetState> states, trackColor: WidgetStateProperty.resolveWith<Color?>((
) { Set<WidgetState> states,
if (states.isEmpty) { ) {
return const Color(0xFF333A41); if (states.isEmpty) {
} return const Color(0xFF333A41);
return null; // Use the default color. }
}), return null; // Use the default color.
trackOutlineColor: }),
WidgetStateProperty.resolveWith<Color?>(( trackOutlineColor:
Set<WidgetState> states, WidgetStateProperty.resolveWith<Color?>((
) { Set<WidgetState> states,
if (states.isEmpty) { ) {
return Colors.white; 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.axisArrowLock);
}
return null; // Use the default color.
}),
value: torProxyPort.valueOrNull != null,
title: const Text('Tor Proxy'),
secondary: const Icon(MdiIcons.power),
onChanged: torProxyPort.isLoading
? null
: (value) async {
if (value) {
await ref
.read(torProxyServiceProvider.notifier)
.connect();
} else {
await ref
.read(torProxyServiceProvider.notifier)
.disconnect();
} }
}, return null; // Use the default color.
), }),
), thumbIcon: WidgetStateProperty.resolveWith<Icon?>((
ListTileTheme( Set<WidgetState> states,
iconColor: Colors.white, ) {
textColor: Colors.white, if (states.contains(WidgetState.selected)) {
child: SwitchListTile.adaptive( return const Icon(MdiIcons.axisArrowLock);
inactiveThumbColor: Colors.white, }
activeColor: const Color(0xFF68B030), return null; // Use the default color.
trackColor: WidgetStateProperty.resolveWith<Color?>(( }),
Set<WidgetState> states, value: torProxyPort.valueOrNull != null,
) { title: const Text('Tor™ Proxy'),
if (states.isEmpty) { secondary: const Icon(MdiIcons.power),
return const Color(0xFF333A41); onChanged: torProxyPort.isLoading
} ? null
return null; // Use the default color. : (value) async {
}), if (value) {
trackOutlineColor: await ref
WidgetStateProperty.resolveWith<Color?>(( .read(torProxyServiceProvider.notifier)
Set<WidgetState> states, .connect();
) { } else {
if (states.isEmpty) { await ref
return Colors.white; .read(torProxyServiceProvider.notifier)
} .disconnect();
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),
);
},
), ),
), 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),
);
},
),
),
],
),
), ),
), Flexible(
Flexible( child: Column(
child: Column( children: [
children: [ if (torProxyPort.isLoading)
if (torProxyPort.isLoading) const Column(
const Column( mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(height: 8),
LinearProgressIndicator(
backgroundColor: Color(0xFF333A41),
color: Color(0xFF68B030),
),
SizedBox(height: 8),
Text(
'Establishing connection...',
style: TextStyle(color: Colors.white),
),
],
),
if (torProxyPort.valueOrNull != null)
Padding(
padding: const EdgeInsets.only(top: 24.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
const Icon( SizedBox(height: 8),
MdiIcons.shieldLockOutline, LinearProgressIndicator(
backgroundColor: Color(0xFF333A41),
color: Color(0xFF68B030), color: Color(0xFF68B030),
size: 32,
), ),
const SizedBox(width: 12), SizedBox(height: 8),
Text( Text(
'Connected to the Tor Network', 'Establishing connection...',
style: Theme.of(context).textTheme.titleMedium style: TextStyle(color: Colors.white),
?.copyWith(color: const Color(0xFF68B030)),
), ),
], ],
), ),
), if (torProxyPort.valueOrNull != null)
], Padding(
padding: const EdgeInsets.only(top: 24.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
MdiIcons.shieldLockOutline,
color: Color(0xFF68B030),
size: 32,
),
const SizedBox(width: 12),
Text(
'Connected to the Tor Network',
style: Theme.of(context).textTheme.titleMedium
?.copyWith(color: const Color(0xFF68B030)),
),
],
),
),
],
),
), ),
), Padding(
], padding: const EdgeInsets.only(
right: 8.0,
left: 8.0,
bottom: 8.0,
),
child: Text(
'Tor is a trademark of The Tor Project; all rights reserved. WebLibre is not endorsed or sponsored by, or affiliated with, the Tor Project.',
textAlign: TextAlign.center,
style: Theme.of(
context,
).textTheme.bodySmall?.copyWith(fontStyle: FontStyle.italic),
),
),
],
),
), ),
), ),
); );
@@ -7,7 +7,7 @@ class TorDialog extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AlertDialog( return AlertDialog(
icon: const Icon(TorIcons.onionAlt, color: Color(0xFF7D4698)), icon: const Icon(TorIcons.onionAlt, color: Color(0xFF7D4698)),
title: const Text('Tor Proxy'), title: const Text('Tor Proxy'),
content: const Text( content: const Text(
'This container requires a Tor proxy for secure connections, which is not currently running.', 'This container requires a Tor proxy for secure connections, which is not currently running.',
), ),