Add proxy routing and sing-box support
This commit is contained in:
+9
-10
@@ -27,6 +27,7 @@ import 'package:weblibre/features/user/data/models/engine_settings.dart';
|
||||
import 'package:weblibre/features/user/domain/presentation/dialogs/quit_browser_dialog.dart';
|
||||
import 'package:weblibre/features/user/domain/repositories/engine_settings.dart';
|
||||
import 'package:weblibre/utils/exit_app.dart';
|
||||
import 'package:weblibre/utils/ui_helper.dart';
|
||||
|
||||
const List<SettingsSectionDefinition> experimentalSettingsSections = [
|
||||
SettingsSectionDefinition(
|
||||
@@ -86,7 +87,6 @@ class _UnifiedPushDistributorTile extends StatelessWidget {
|
||||
),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () async {
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
final success = await GeckoBrowserService()
|
||||
.pickUnifiedPushDistributor();
|
||||
|
||||
@@ -94,15 +94,14 @@ class _UnifiedPushDistributorTile extends StatelessWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
success
|
||||
? 'UnifiedPush distributor configured.'
|
||||
: 'Could not configure UnifiedPush. Install a distributor and try again.',
|
||||
),
|
||||
),
|
||||
);
|
||||
if (success) {
|
||||
showInfoMessage(context, 'UnifiedPush distributor configured.');
|
||||
} else {
|
||||
showErrorMessage(
|
||||
context,
|
||||
'Could not configure UnifiedPush. Install a distributor and try again.',
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -55,12 +55,11 @@ class LocaleSettingsScreen extends HookConsumerWidget {
|
||||
final availableLocales = useMemoized(
|
||||
() =>
|
||||
{
|
||||
...systemLocales,
|
||||
...userLocales.value,
|
||||
Locale.fromSubtags(languageCode: 'en', countryCode: 'US'),
|
||||
}.toList()..sort(
|
||||
(a, b) => a.toLanguageTag().compareTo(b.toLanguageTag()),
|
||||
),
|
||||
...systemLocales,
|
||||
...userLocales.value,
|
||||
Locale.fromSubtags(languageCode: 'en', countryCode: 'US'),
|
||||
}.toList()
|
||||
..sort((a, b) => a.toLanguageTag().compareTo(b.toLanguageTag())),
|
||||
[systemLocales, userLocales],
|
||||
);
|
||||
|
||||
@@ -69,10 +68,9 @@ class LocaleSettingsScreen extends HookConsumerWidget {
|
||||
|
||||
final filteredLocales = availableLocales.where((locale) {
|
||||
if (search.normalizedQuery.isEmpty) return true;
|
||||
return locale
|
||||
.toLanguageTag()
|
||||
.toLowerCase()
|
||||
.contains(search.normalizedQuery);
|
||||
return locale.toLanguageTag().toLowerCase().contains(
|
||||
search.normalizedQuery,
|
||||
);
|
||||
}).toList();
|
||||
|
||||
return SettingsCustomScrollScaffold(
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2024-2026 Fabian Freund.
|
||||
*
|
||||
* This file is part of WebLibre
|
||||
* (see https://weblibre.eu).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_material_design_icons/flutter_material_design_icons.dart';
|
||||
import 'package:weblibre/core/routing/routes.dart';
|
||||
import 'package:weblibre/features/settings/presentation/widgets/settings_detail.dart';
|
||||
|
||||
const List<SettingsSectionDefinition> proxySettingsSections = [
|
||||
SettingsSectionDefinition(
|
||||
title: 'Proxy',
|
||||
entries: [
|
||||
SettingsEntryDefinition(
|
||||
title: 'Proxy Connections',
|
||||
subtitle: 'Manage proxy profiles and connections',
|
||||
keywords: [
|
||||
'sing-box',
|
||||
'socks',
|
||||
'vpn',
|
||||
'wireguard',
|
||||
'tor',
|
||||
'onion',
|
||||
'bridges',
|
||||
'obfs4',
|
||||
'snowflake',
|
||||
],
|
||||
child: _ProxyConnectionsTile(),
|
||||
),
|
||||
SettingsEntryDefinition(
|
||||
title: 'Proxy Routing',
|
||||
subtitle: 'Choose which proxy carries regular and private tabs',
|
||||
keywords: ['routing', 'container'],
|
||||
child: _ProxyRoutingTile(),
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
class ProxySettingsScreen extends StatelessWidget {
|
||||
const ProxySettingsScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const SettingsDetailScaffold(
|
||||
title: 'Proxy',
|
||||
subtitle: 'Manage proxy connections and choose which tabs use them.',
|
||||
icon: MdiIcons.lanConnect,
|
||||
sections: proxySettingsSections,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ProxyConnectionsTile extends StatelessWidget {
|
||||
const _ProxyConnectionsTile();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
leading: const Icon(MdiIcons.lanConnect),
|
||||
title: const Text('Proxy Connections'),
|
||||
subtitle: const Text('Manage proxy profiles and connections'),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
vertical: 8.0,
|
||||
horizontal: 16.0,
|
||||
),
|
||||
onTap: () async {
|
||||
await const SingboxProxyProfilesRoute().push(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ProxyRoutingTile extends StatelessWidget {
|
||||
const _ProxyRoutingTile();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.route_outlined),
|
||||
title: const Text('Proxy Routing'),
|
||||
subtitle: const Text(
|
||||
'Choose which proxy carries regular and private tabs',
|
||||
),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
vertical: 8.0,
|
||||
horizontal: 16.0,
|
||||
),
|
||||
onTap: () async {
|
||||
await const ProxyRoutingSettingsRoute().push(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import 'package:weblibre/features/settings/presentation/screens/browsing_setting
|
||||
import 'package:weblibre/features/settings/presentation/screens/extensions_settings.dart';
|
||||
import 'package:weblibre/features/settings/presentation/screens/general_settings.dart';
|
||||
import 'package:weblibre/features/settings/presentation/screens/privacy_security_settings.dart';
|
||||
import 'package:weblibre/features/settings/presentation/screens/proxy_settings.dart';
|
||||
import 'package:weblibre/features/settings/presentation/screens/search_settings.dart';
|
||||
import 'package:weblibre/features/settings/presentation/screens/web_content_settings.dart';
|
||||
import 'package:weblibre/features/settings/presentation/widgets/settings_detail.dart';
|
||||
@@ -42,7 +43,10 @@ class SettingsScreen extends HookWidget {
|
||||
final categories = _buildCategories();
|
||||
final sections = search.normalizedQuery.isEmpty
|
||||
? _buildCategorySections(categories)
|
||||
: _buildSearchSections(categories, search.normalizedQuery);
|
||||
: _buildSearchSections([
|
||||
...categories.browser,
|
||||
...categories.services,
|
||||
], search.normalizedQuery);
|
||||
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
@@ -83,8 +87,13 @@ class SettingsScreen extends HookWidget {
|
||||
}
|
||||
}
|
||||
|
||||
List<_SettingsCategoryDefinition> _buildCategories() {
|
||||
return [
|
||||
typedef _CategoryGroups = ({
|
||||
List<_SettingsCategoryDefinition> browser,
|
||||
List<_SettingsCategoryDefinition> services,
|
||||
});
|
||||
|
||||
_CategoryGroups _buildCategories() {
|
||||
final browser = [
|
||||
_SettingsCategoryDefinition(
|
||||
title: 'General',
|
||||
subtitle: 'Appearance, language, downloads',
|
||||
@@ -139,6 +148,26 @@ List<_SettingsCategoryDefinition> _buildCategories() {
|
||||
sections: privacySecuritySettingsSections,
|
||||
onTap: (context) => PrivacySecuritySettingsRoute().push(context),
|
||||
),
|
||||
_SettingsCategoryDefinition(
|
||||
title: 'Proxy',
|
||||
subtitle: 'Connections and routing',
|
||||
icon: MdiIcons.lanConnect,
|
||||
keywords: const [
|
||||
'proxy',
|
||||
'sing-box',
|
||||
'socks',
|
||||
'vpn',
|
||||
'wireguard',
|
||||
'routing',
|
||||
'tor',
|
||||
'container',
|
||||
],
|
||||
sections: proxySettingsSections,
|
||||
onTap: (context) => const ProxySettingsRoute().push(context),
|
||||
),
|
||||
];
|
||||
|
||||
final services = [
|
||||
_SettingsCategoryDefinition(
|
||||
title: 'Extensions',
|
||||
subtitle: 'Install and manage extension sources',
|
||||
@@ -170,23 +199,25 @@ List<_SettingsCategoryDefinition> _buildCategories() {
|
||||
onTap: (context) => AdvancedSettingsRoute().push(context),
|
||||
),
|
||||
];
|
||||
|
||||
return (browser: browser, services: services);
|
||||
}
|
||||
|
||||
List<SettingsSectionDefinition> _buildCategorySections(
|
||||
List<_SettingsCategoryDefinition> categories,
|
||||
_CategoryGroups categories,
|
||||
) {
|
||||
return [
|
||||
SettingsSectionDefinition(
|
||||
title: 'Browser',
|
||||
entries: [
|
||||
for (final category in categories.take(7))
|
||||
for (final category in categories.browser)
|
||||
_buildCategoryEntry(category),
|
||||
],
|
||||
),
|
||||
SettingsSectionDefinition(
|
||||
title: 'Services & Advanced',
|
||||
entries: [
|
||||
for (final category in categories.skip(7))
|
||||
for (final category in categories.services)
|
||||
_buildCategoryEntry(category),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -601,8 +601,7 @@ class _GroupCard extends StatelessWidget {
|
||||
|
||||
for (final entry in parentTree.entries) {
|
||||
final parentMatches =
|
||||
groupMatches ||
|
||||
(entry.key?.toLowerCase().contains(query) ?? false);
|
||||
groupMatches || (entry.key?.toLowerCase().contains(query) ?? false);
|
||||
final filteredTokens = entry.value.where((tokenKey) {
|
||||
if (query.isEmpty || parentMatches) return true;
|
||||
final asset = registry[tokenKey];
|
||||
|
||||
Reference in New Issue
Block a user