bookmar default open setting

This commit is contained in:
Fabian Freund
2026-07-31 05:46:26 +02:00
parent bdfc851681
commit 22c2b15de6
9 changed files with 250 additions and 18 deletions
@@ -181,7 +181,7 @@ final class TabThumbnailsProvider
}
}
String _$tabThumbnailsHash() => r'16c4bb6edff2e6413100d9ce02c1ae7948740cfe';
String _$tabThumbnailsHash() => r'c3066c4d05520d9edefcafc03810cda47302f43e';
/// Page screenshots per tab. Refreshed on a 10s timer for the selected tab and
/// consumed only by the tab tray previews.
@@ -323,7 +323,7 @@ final class TabHistoryStatesProvider
}
}
String _$tabHistoryStatesHash() => r'3920410334c4354ca66da605d9bfe85b4853f3bf';
String _$tabHistoryStatesHash() => r'e27d36cbb16f7c025fa9a5034699151706d7ba21';
/// Session history (back/forward stack) per tab.
@@ -464,7 +464,7 @@ final class TabFindResultStatesProvider
}
String _$tabFindResultStatesHash() =>
r'f57dee1658eae789002ac3cff15808cbc96b7883';
r'e9d68ea9ed3d8d4f319073204415fa27420de29d';
/// Find-in-page match counters per tab. Emitted at a high rate by Gecko while
/// a search is running.
@@ -612,7 +612,7 @@ final class TabTranslationStatesProvider
}
String _$tabTranslationStatesHash() =>
r'f04004026dc5fd638319528a55e2f10e0f64c9b3';
r'28daf6c0d421a3ed60ccb5087021d5fc078c2927';
/// Translation progress/result per tab.
@@ -41,7 +41,7 @@ final class TabStatesProvider
}
}
String _$tabStatesHash() => r'1ae4e941890116eabf1803809014b3e575c33e73';
String _$tabStatesHash() => r'6009e702c84e913c81d674585d391bcefb2d7cc1';
abstract class _$TabStates extends $Notifier<Map<String, TabState>> {
Map<String, TabState> build();
@@ -30,6 +30,8 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:share_plus/share_plus.dart';
import 'package:weblibre/core/logger.dart';
import 'package:weblibre/core/routing/routes.dart';
import 'package:weblibre/extensions/uri.dart';
import 'package:weblibre/features/geckoview/domain/entities/tab_container_selection.dart';
import 'package:weblibre/features/geckoview/domain/providers/tab_state.dart';
import 'package:weblibre/features/geckoview/domain/repositories/tab.dart';
import 'package:weblibre/features/geckoview/features/bookmarks/domain/entities/bookmark_item.dart';
@@ -47,6 +49,10 @@ import 'package:weblibre/features/geckoview/features/bookmarks/presentation/dial
import 'package:weblibre/features/geckoview/features/bookmarks/presentation/dialogs/select_bookmark_folder_dialog.dart';
import 'package:weblibre/features/geckoview/features/bookmarks/utils/bookmark_import_isolate.dart';
import 'package:weblibre/features/geckoview/features/tabs/data/entities/tab_mode.dart';
import 'package:weblibre/features/geckoview/features/tabs/data/models/container_data.dart';
import 'package:weblibre/features/geckoview/features/tabs/domain/providers/selected_container.dart';
import 'package:weblibre/features/geckoview/features/tabs/domain/repositories/container.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/menu_controller.dart';
import 'package:weblibre/presentation/widgets/failure_widget.dart';
@@ -572,17 +578,7 @@ class BookmarkListScreen extends HookConsumerWidget {
trailing: _buildEntryMenu(context, ref, bookmark),
title: Text(bookmark.title, maxLines: 3, overflow: TextOverflow.ellipsis),
subtitle: UriBreadcrumb(uri: bookmark.url),
onTap: () async {
final result = await OpenSharedContentRoute(
sharedUrl: bookmark.url.toString(),
).push<bool>(context);
if (result == true) {
if (context.mounted) {
const BrowserRoute().go(context);
}
}
},
onTap: () => _openBookmark(context, ref, bookmark.url),
onLongPress: () {
uiStateNotifier.enterSelectionMode(initialGuid: bookmark.guid);
},
@@ -1016,6 +1012,69 @@ class BookmarkListScreen extends HookConsumerWidget {
// -- Tab Opening Helper --
/// Opens a tapped bookmark according to [BookmarkOpenSetting]. `ask` shows
/// the "open in..." sheet (the historical, default behavior); the other
/// values open the bookmark directly with no intermediate prompt.
Future<void> _openBookmark(
BuildContext context,
WidgetRef ref,
Uri url,
) async {
final settings = ref.read(generalSettingsWithDefaultsProvider);
switch (settings.effectiveBookmarkOpenSetting) {
case BookmarkOpenSetting.ask:
final result = await OpenSharedContentRoute(
sharedUrl: url.toString(),
).push<bool>(context);
if (result == true && context.mounted) {
const BrowserRoute().go(context);
}
case BookmarkOpenSetting.regular:
case BookmarkOpenSetting.isolated:
final isolated =
settings.effectiveBookmarkOpenSetting ==
BookmarkOpenSetting.isolated;
await ref
.read(tabRepositoryProvider.notifier)
.addTab(
url: url,
tabMode: isolated ? TabMode.newIsolated() : TabMode.regular,
selectTab: true,
containerSelection: isolated
? const TabContainerSelection.unassigned()
: const TabContainerSelection.useSelected(),
);
if (context.mounted) {
const BrowserRoute().go(context);
}
case BookmarkOpenSetting.customTab:
final containerRepo = ref.read(containerRepositoryProvider.notifier);
ContainerData? container;
if (url.hasAuthority && url.isHttpOrHttps) {
final siteAssignedId = await containerRepo.siteAssignedContainerId(
url,
);
if (siteAssignedId != null) {
container = await containerRepo.getContainerData(siteAssignedId);
}
}
container ??= await ref
.read(selectedContainerProvider.notifier)
.fetchData();
await GeckoBrowserService().openInCustomTab(
url: url,
private: false,
contextId: container?.metadata.contextualIdentity,
);
}
}
Future<void> _openInNewTab(
BuildContext context,
WidgetRef ref,