new setting to define tab bar swipe action
This commit is contained in:
+24
-1
@@ -42,6 +42,7 @@ import 'package:weblibre/features/geckoview/features/browser/presentation/widget
|
||||
import 'package:weblibre/features/geckoview/features/find_in_page/presentation/controllers/find_in_page.dart';
|
||||
import 'package:weblibre/features/geckoview/features/readerview/presentation/controllers/readerable.dart';
|
||||
import 'package:weblibre/features/geckoview/features/readerview/presentation/widgets/reader_button.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/icons/tor_icons.dart';
|
||||
@@ -93,7 +94,29 @@ class BrowserBottomAppBar extends HookConsumerWidget {
|
||||
final distance = dragStartPosition.value - details.globalPosition;
|
||||
|
||||
if (distance.dx.abs() > 50) {
|
||||
await ref.read(tabRepositoryProvider.notifier).selectPreviousTab();
|
||||
final selectedTab = ref.read(selectedTabProvider);
|
||||
final setting = await ref
|
||||
.read(generalSettingsRepositoryProvider.notifier)
|
||||
.fetchSettings();
|
||||
|
||||
if (selectedTab != null) {
|
||||
switch (setting.tabBarSwipeAction) {
|
||||
case TabBarSwipeAction.switchLastOpened:
|
||||
await ref
|
||||
.read(tabRepositoryProvider.notifier)
|
||||
.selectPreviouslyOpenedTab(selectedTab);
|
||||
case TabBarSwipeAction.navigateOrderedTabs:
|
||||
if (distance.dx < 0) {
|
||||
await ref
|
||||
.read(tabRepositoryProvider.notifier)
|
||||
.selectPreviousTab(selectedTab);
|
||||
} else {
|
||||
await ref
|
||||
.read(tabRepositoryProvider.notifier)
|
||||
.selectNextTab(selectedTab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
child: AppBar(
|
||||
|
||||
@@ -240,4 +240,34 @@ unorderedTabDescendants:
|
||||
JOIN descendants d ON t.parent_id = d.id
|
||||
)
|
||||
SELECT id, parent_id
|
||||
FROM descendants;
|
||||
FROM descendants;
|
||||
|
||||
previousTabByTimestamp:
|
||||
WITH ranked_tabs AS (
|
||||
SELECT id, timestamp,
|
||||
LAG(id) OVER (ORDER BY timestamp) as prev_tab_id
|
||||
FROM tab
|
||||
)
|
||||
SELECT prev_tab_id
|
||||
FROM ranked_tabs
|
||||
WHERE id = :tab_id;
|
||||
|
||||
previousTabByOrderKey:
|
||||
WITH ranked_tabs AS (
|
||||
SELECT id, order_key,
|
||||
LAG(id) OVER (ORDER BY order_key) as prev_tab_id
|
||||
FROM tab
|
||||
)
|
||||
SELECT prev_tab_id
|
||||
FROM ranked_tabs
|
||||
WHERE id = :tab_id;
|
||||
|
||||
nextTabByOrderKey:
|
||||
WITH ranked_tabs AS (
|
||||
SELECT id, order_key,
|
||||
LEAD(id) OVER (ORDER BY order_key) as next_tab_id
|
||||
FROM tab
|
||||
)
|
||||
SELECT next_tab_id
|
||||
FROM ranked_tabs
|
||||
WHERE id = :tab_id;
|
||||
|
||||
@@ -1256,6 +1256,30 @@ abstract class _$TabDatabase extends GeneratedDatabase {
|
||||
);
|
||||
}
|
||||
|
||||
Selectable<String> previousTabByTimestamp({required String tabId}) {
|
||||
return customSelect(
|
||||
'WITH ranked_tabs AS (SELECT id, timestamp, LAG(id)OVER (ORDER BY timestamp RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE NO OTHERS) AS prev_tab_id FROM tab) SELECT prev_tab_id FROM ranked_tabs WHERE id = ?1',
|
||||
variables: [Variable<String>(tabId)],
|
||||
readsFrom: {tab},
|
||||
).map((QueryRow row) => row.read<String>('prev_tab_id'));
|
||||
}
|
||||
|
||||
Selectable<String> previousTabByOrderKey({required String tabId}) {
|
||||
return customSelect(
|
||||
'WITH ranked_tabs AS (SELECT id, order_key, LAG(id)OVER (ORDER BY order_key RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE NO OTHERS) AS prev_tab_id FROM tab) SELECT prev_tab_id FROM ranked_tabs WHERE id = ?1',
|
||||
variables: [Variable<String>(tabId)],
|
||||
readsFrom: {tab},
|
||||
).map((QueryRow row) => row.read<String>('prev_tab_id'));
|
||||
}
|
||||
|
||||
Selectable<String> nextTabByOrderKey({required String tabId}) {
|
||||
return customSelect(
|
||||
'WITH ranked_tabs AS (SELECT id, order_key, LEAD(id)OVER (ORDER BY order_key RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE NO OTHERS) AS next_tab_id FROM tab) SELECT next_tab_id FROM ranked_tabs WHERE id = ?1',
|
||||
variables: [Variable<String>(tabId)],
|
||||
readsFrom: {tab},
|
||||
).map((QueryRow row) => row.read<String>('next_tab_id'));
|
||||
}
|
||||
|
||||
@override
|
||||
Iterable<TableInfo<Table, Object?>> get allTables =>
|
||||
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'tab.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$tabDataRepositoryHash() => r'be1bb8a8118c7bfd90d0f1ac89a04c0a2149a0b0';
|
||||
String _$tabDataRepositoryHash() => r'295c1718ecf41202709517fb2c5b31527e885dfa';
|
||||
|
||||
/// See also [TabDataRepository].
|
||||
@ProviderFor(TabDataRepository)
|
||||
|
||||
Reference in New Issue
Block a user