advanced desktop mode

This commit is contained in:
Fabian Freund
2026-06-06 15:39:09 +02:00
parent 4a12acab99
commit 370c422e12
23 changed files with 732 additions and 78 deletions
@@ -105,12 +105,23 @@ const List<SettingsSectionDefinition> browsingSettingsSections = [
keywords: ['app links', 'external apps'],
child: _AppLinksModeSection(),
),
],
),
SettingsSectionDefinition(
title: 'Desktop Mode',
entries: [
SettingsEntryDefinition(
title: 'Always Request Desktop Site',
subtitle: 'Open new tabs in desktop mode by default',
keywords: ['desktop mode', 'user agent', 'mobile site', 'tablet'],
child: _GlobalDesktopModeTile(),
),
SettingsEntryDefinition(
title: 'Desktop Mode Sites',
subtitle: 'Sites that always load in desktop mode',
keywords: ['desktop mode', 'per-site', 'user agent', 'exceptions'],
child: _DesktopModeSitesTile(),
),
],
),
SettingsSectionDefinition(
@@ -764,6 +775,23 @@ class _GlobalDesktopModeTile extends HookConsumerWidget {
}
}
class _DesktopModeSitesTile extends StatelessWidget {
const _DesktopModeSitesTile();
@override
Widget build(BuildContext context) {
return ListTile(
leading: const Icon(Icons.desktop_windows),
title: const Text('Desktop Mode Sites'),
subtitle: const Text('Sites that always load in desktop mode'),
trailing: const Icon(Icons.chevron_right),
onTap: () async {
await const DesktopModeSitesRoute().push(context);
},
);
}
}
class _PullToRefreshTile extends HookConsumerWidget {
const _PullToRefreshTile();
@@ -0,0 +1,56 @@
/*
* 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:hooks_riverpod/hooks_riverpod.dart';
import 'package:weblibre/features/settings/presentation/controllers/save_settings.dart';
import 'package:weblibre/features/settings/presentation/widgets/string_list_settings_screen.dart';
import 'package:weblibre/features/user/data/models/general_settings.dart';
import 'package:weblibre/features/user/domain/repositories/general_settings.dart';
import 'package:weblibre/utils/host_rules.dart';
/// Manages the list of sites that always load in desktop mode.
class DesktopModeSitesScreen extends HookConsumerWidget {
const DesktopModeSitesScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final desktopModeSites = ref.watch(
generalSettingsWithDefaultsProvider.select((s) => s.desktopModeSites),
);
return StringListSettingsScreen(
title: 'Desktop mode sites',
description:
'These sites always load in desktop mode, overriding the default. '
'Subdomains are included (e.g. "example.com" also covers '
'"m.example.com").',
values: desktopModeSites,
hintText: 'example.com',
itemIcon: Icons.desktop_windows,
emptyLabel: 'No sites added.',
normalize: normalizeRuleHost,
onChanged: (next) async {
await ref
.read(saveGeneralSettingsControllerProvider.notifier)
.save((current) => current.copyWith.desktopModeSites(next));
},
);
}
}