double tap previous tab

This commit is contained in:
Fabian Freund
2025-03-13 22:05:51 +01:00
parent b9def5c694
commit 8f9091376d
3 changed files with 23 additions and 4 deletions
@@ -27,6 +27,8 @@ part 'tab.g.dart';
class TabRepository extends _$TabRepository { class TabRepository extends _$TabRepository {
final _tabsService = GeckoTabService(); final _tabsService = GeckoTabService();
String? _previousTabId;
Future<String> addTab({ Future<String> addTab({
Uri? url, Uri? url,
bool selectTab = true, bool selectTab = true,
@@ -83,6 +85,14 @@ class TabRepository extends _$TabRepository {
); );
} }
Future<bool> selectPreviousTab() async {
if (_previousTabId != null) {
return selectTab(_previousTabId!);
}
return false;
}
Future<bool> selectTab(String tabId) async { Future<bool> selectTab(String tabId) async {
final containerId = await ref final containerId = await ref
.read(tabDataRepositoryProvider.notifier) .read(tabDataRepositoryProvider.notifier)
@@ -227,6 +237,7 @@ class TabRepository extends _$TabRepository {
ref.listen(selectedTabProvider, (previous, tabId) async { ref.listen(selectedTabProvider, (previous, tabId) async {
if (tabId != null) { if (tabId != null) {
_previousTabId = previous;
await db.tabDao.touchTab(tabId, timestamp: DateTime.now()); await db.tabDao.touchTab(tabId, timestamp: DateTime.now());
} }
}); });
@@ -118,6 +118,11 @@ class BrowserBottomAppBar extends HookConsumerWidget {
.show(ViewTabsSheet()); .show(ViewTabsSheet());
} }
}, },
onDoubleTap: () async {
await ref
.read(tabRepositoryProvider.notifier)
.selectPreviousTab();
},
onLongPress: () { onLongPress: () {
if (tabMenuController.isOpen) { if (tabMenuController.isOpen) {
tabMenuController.close(); tabMenuController.close();
@@ -4,12 +4,14 @@ import 'package:lensai/features/geckoview/domain/providers/tab_list.dart';
class TabsActionButton extends HookConsumerWidget { class TabsActionButton extends HookConsumerWidget {
final bool isActive; final bool isActive;
final VoidCallback onTap; final VoidCallback? onTap;
final VoidCallback onLongPress; final VoidCallback? onDoubleTap;
final VoidCallback? onLongPress;
const TabsActionButton({ const TabsActionButton({
required this.onTap, this.onTap,
required this.onLongPress, this.onDoubleTap,
this.onLongPress,
this.isActive = false, this.isActive = false,
super.key, super.key,
}); });
@@ -24,6 +26,7 @@ class TabsActionButton extends HookConsumerWidget {
return InkWell( return InkWell(
onTap: onTap, onTap: onTap,
onDoubleTap: onDoubleTap,
onLongPress: onLongPress, onLongPress: onLongPress,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 15.0), padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 15.0),