reorganize menus

This commit is contained in:
Fabian Freund
2025-12-01 11:23:40 +01:00
parent cb6cb2ba62
commit 73fd816efc
2 changed files with 239 additions and 217 deletions
@@ -349,13 +349,6 @@ class BrowserBottomAppBar extends HookConsumerWidget {
leadingIcon: const Icon(Icons.settings), leadingIcon: const Icon(Icons.settings),
child: const Text('Settings'), child: const Text('Settings'),
), ),
MenuItemButton(
onPressed: () async {
await const HistoryRoute().push(context);
},
leadingIcon: const Icon(Icons.history),
child: const Text('History'),
),
Consumer( Consumer(
builder: (context, childRef, child) { builder: (context, childRef, child) {
final browserExtensions = childRef.watch( final browserExtensions = childRef.watch(
@@ -437,6 +430,13 @@ class BrowserBottomAppBar extends HookConsumerWidget {
), ),
), ),
const Divider(), const Divider(),
MenuItemButton(
onPressed: () async {
await const HistoryRoute().push(context);
},
leadingIcon: const Icon(Icons.history),
child: const Text('History'),
),
MenuItemButton( MenuItemButton(
onPressed: () async { onPressed: () async {
await BookmarkListRoute( await BookmarkListRoute(
@@ -130,41 +130,17 @@ class TabMenu extends HookConsumerWidget {
}, },
), ),
const Divider(), const Divider(),
MenuItemButton( Visibility(
onPressed: () async { visible: showFeeds.value,
await ref replacement: MenuItemButton(
.read(tabRepositoryProvider.notifier) closeOnActivate: false,
.closeTab(selectedTabId); leadingIcon: const Icon(Icons.rss_feed),
child: const Text('Fetch Feeds'),
if (context.mounted) { onPressed: () {
ui_helper.showTabUndoClose( showFeeds.value = true;
context,
ref.read(tabRepositoryProvider.notifier).undoClose,
);
}
},
leadingIcon: const Icon(Icons.close),
child: const Text('Close Tab'),
),
MenuItemButton(
leadingIcon: const Icon(MdiIcons.contentCopy),
child: const Text('Copy address'),
onPressed: () async {
final tabState = ref.read(tabStateProvider(selectedTabId))!;
await Clipboard.setData(
ClipboardData(text: tabState.url.toString()),
);
}, },
), ),
MenuItemButton( child: WebsiteFeedMenuButton(selectedTabId),
leadingIcon: const Icon(Icons.open_in_browser),
child: const Text('Launch External'),
onPressed: () async {
final tabState = ref.read(tabStateProvider(selectedTabId))!;
await ui_helper.launchUrlFeedback(context, tabState.url);
},
), ),
MenuItemButton( MenuItemButton(
leadingIcon: const Icon(MdiIcons.bookmarkPlus), leadingIcon: const Icon(MdiIcons.bookmarkPlus),
@@ -182,15 +158,21 @@ class TabMenu extends HookConsumerWidget {
).push(context); ).push(context);
}, },
), ),
SubmenuButton(
menuChildren: [
MenuItemButton( MenuItemButton(
leadingIcon: const Icon(MdiIcons.tabPlus), leadingIcon: const Icon(MdiIcons.tabPlus),
child: const Text('Clone tab'), child: const Text('Regular'),
onPressed: () async { onPressed: () async {
final tabState = ref.read(tabStateProvider(selectedTabId))!; final tabState = ref.read(tabStateProvider(selectedTabId))!;
final tabId = await ref final tabId = await ref
.read(tabRepositoryProvider.notifier) .read(tabRepositoryProvider.notifier)
.addTab(url: tabState.url, private: false, selectTab: false); .addTab(
url: tabState.url,
private: false,
selectTab: false,
);
if (context.mounted) { if (context.mounted) {
//save reference before pop `ref` gets disposed //save reference before pop `ref` gets disposed
@@ -207,7 +189,7 @@ class TabMenu extends HookConsumerWidget {
), ),
MenuItemButton( MenuItemButton(
leadingIcon: const Icon(MdiIcons.tabUnselected), leadingIcon: const Icon(MdiIcons.tabUnselected),
child: const Text('Clone as private tab'), child: const Text('Private'),
onPressed: () async { onPressed: () async {
final tabState = ref.read(tabStateProvider(selectedTabId))!; final tabState = ref.read(tabStateProvider(selectedTabId))!;
@@ -228,9 +210,15 @@ class TabMenu extends HookConsumerWidget {
} }
}, },
), ),
],
leadingIcon: const Icon(MdiIcons.tabPlus),
child: const Text('Clone Tab'),
),
SubmenuButton(
menuChildren: [
MenuItemButton( MenuItemButton(
leadingIcon: const Icon(MdiIcons.folderArrowUpDownOutline), leadingIcon: const Icon(MdiIcons.folderArrowUpDownOutline),
child: const Text('Assign container'), child: const Text('Assign Container'),
onPressed: () async { onPressed: () async {
final targetContainerId = await const ContainerSelectionRoute() final targetContainerId = await const ContainerSelectionRoute()
.push<String?>(context); .push<String?>(context);
@@ -253,10 +241,12 @@ class TabMenu extends HookConsumerWidget {
Consumer( Consumer(
child: MenuItemButton( child: MenuItemButton(
leadingIcon: const Icon(MdiIcons.webPlus), leadingIcon: const Icon(MdiIcons.webPlus),
child: const Text('Assign Site to Container'), child: const Text('URL relation'),
onPressed: () async { onPressed: () async {
final targetContainerId = await const ContainerSelectionRoute() final targetContainerId =
.push<String?>(context); await const ContainerSelectionRoute().push<String?>(
context,
);
if (targetContainerId != null) { if (targetContainerId != null) {
final containerData = await ref final containerData = await ref
@@ -264,7 +254,9 @@ class TabMenu extends HookConsumerWidget {
.getContainerData(targetContainerId); .getContainerData(targetContainerId);
if (containerData != null) { if (containerData != null) {
final tabState = ref.read(tabStateProvider(selectedTabId)); final tabState = ref.read(
tabStateProvider(selectedTabId),
);
final origin = tabState?.url.origin.mapNotNull(Uri.parse); final origin = tabState?.url.origin.mapNotNull(Uri.parse);
if (origin != null) { if (origin != null) {
@@ -289,7 +281,8 @@ class TabMenu extends HookConsumerWidget {
); );
return Visibility( return Visibility(
visible: isSiteAssigned.hasValue && !isSiteAssigned.requireValue, visible:
isSiteAssigned.hasValue && !isSiteAssigned.requireValue,
child: child!, child: child!,
); );
}, },
@@ -297,7 +290,7 @@ class TabMenu extends HookConsumerWidget {
Consumer( Consumer(
child: MenuItemButton( child: MenuItemButton(
leadingIcon: const Icon(MdiIcons.folderCancelOutline), leadingIcon: const Icon(MdiIcons.folderCancelOutline),
child: const Text('Unassign container'), child: const Text('Unassign Container'),
onPressed: () async { onPressed: () async {
final tabState = ref.read(tabStateProvider(selectedTabId))!; final tabState = ref.read(tabStateProvider(selectedTabId))!;
@@ -316,33 +309,24 @@ class TabMenu extends HookConsumerWidget {
return Visibility(visible: containerId != null, child: child!); return Visibility(visible: containerId != null, child: child!);
}, },
), ),
MenuItemButton(
leadingIcon: const Icon(Icons.share),
onPressed: () async {
final tabState = ref.read(tabStateProvider(selectedTabId))!;
await SharePlus.instance.share(ShareParams(uri: tabState.url));
},
trailingIcon: Row(
mainAxisSize: MainAxisSize.min,
children: [
const VerticalDivider(indent: 4, endIndent: 4),
IconButton(
icon: const Icon(Icons.qr_code),
onPressed: () async {
final tabState = ref.read(tabStateProvider(selectedTabId))!;
await showQrCode(context, tabState.url.toString());
controller.close();
},
),
], ],
leadingIcon: const Icon(MdiIcons.folder),
child: const Text('Container'),
), ),
child: const Text('Share link'), SubmenuButton(
menuChildren: [
MenuItemButton(
leadingIcon: const Icon(Icons.open_in_browser),
child: const Text('Launch External'),
onPressed: () async {
final tabState = ref.read(tabStateProvider(selectedTabId))!;
await ui_helper.launchUrlFeedback(context, tabState.url);
},
), ),
MenuItemButton( MenuItemButton(
leadingIcon: const Icon(Icons.mobile_screen_share), leadingIcon: const Icon(Icons.mobile_screen_share),
child: const Text('Share screenshot'), child: const Text('Share Screenshot'),
onPressed: () async { onPressed: () async {
final screenshot = await ref final screenshot = await ref
.read(selectedTabSessionProvider) .read(selectedTabSessionProvider)
@@ -370,17 +354,55 @@ class TabMenu extends HookConsumerWidget {
} }
}, },
), ),
Visibility( MenuItemButton(
visible: showFeeds.value, leadingIcon: const Icon(Icons.share),
replacement: MenuItemButton( onPressed: () async {
closeOnActivate: false, final tabState = ref.read(tabStateProvider(selectedTabId))!;
leadingIcon: const Icon(Icons.rss_feed),
child: const Text('Fetch Feeds'), await SharePlus.instance.share(ShareParams(uri: tabState.url));
onPressed: () { },
showFeeds.value = true; child: const Text('Share Link'),
),
MenuItemButton(
leadingIcon: const Icon(Icons.qr_code),
onPressed: () async {
final tabState = ref.read(tabStateProvider(selectedTabId))!;
await showQrCode(context, tabState.url.toString());
controller.close();
},
child: const Text('Show QR Code'),
),
],
leadingIcon: const Icon(Icons.share),
child: const Text('Share'),
),
MenuItemButton(
leadingIcon: const Icon(MdiIcons.contentCopy),
child: const Text('Copy Address'),
onPressed: () async {
final tabState = ref.read(tabStateProvider(selectedTabId))!;
await Clipboard.setData(
ClipboardData(text: tabState.url.toString()),
);
}, },
), ),
child: WebsiteFeedMenuButton(selectedTabId), MenuItemButton(
onPressed: () async {
await ref
.read(tabRepositoryProvider.notifier)
.closeTab(selectedTabId);
if (context.mounted) {
ui_helper.showTabUndoClose(
context,
ref.read(tabRepositoryProvider.notifier).undoClose,
);
}
},
leadingIcon: const Icon(Icons.close),
child: const Text('Close Tab'),
), ),
], ],
child: child, child: child,