From f04a3a0ebefb97a1ee29bcd412c05578ecbcff69 Mon Sep 17 00:00:00 2001 From: DattatreyaReddy Panta <58727124+DattatreyaReddy@users.noreply.github.com> Date: Sun, 15 Oct 2023 10:58:33 +0530 Subject: [PATCH] fixed conflict b/w zoom and quick open --- .../search_stack/search_stack_screen.dart | 5 +- lib/src/routes/router_config.dart | 105 +++--- lib/src/routes/router_config.g.dart | 315 +++++++++--------- lib/src/sorayomi.dart | 16 +- lib/src/widgets/two_finger_pointer.dart | 113 ------- pubspec.yaml | 2 +- 6 files changed, 212 insertions(+), 344 deletions(-) delete mode 100644 lib/src/widgets/two_finger_pointer.dart diff --git a/lib/src/features/quick_open/presentation/search_stack/search_stack_screen.dart b/lib/src/features/quick_open/presentation/search_stack/search_stack_screen.dart index 36ce19fa..e197540d 100644 --- a/lib/src/features/quick_open/presentation/search_stack/search_stack_screen.dart +++ b/lib/src/features/quick_open/presentation/search_stack/search_stack_screen.dart @@ -13,7 +13,6 @@ import 'package:flutter/services.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import '../../../../utils/extensions/custom_extensions.dart'; -import '../../../../widgets/two_finger_pointer.dart'; import '../quick_search/quick_search_screen.dart'; class ShowQuickOpenIntent extends Intent {} @@ -87,8 +86,8 @@ class QuickSearchShortcutWrapper extends StatelessWidget { }, ), }, - child: TwoFingerPointerWidget( - onUpdate: (details) => visible.value = (true), + child: GestureDetector( + onLongPress: () => visible.value = (true), child: child, ), ), diff --git a/lib/src/routes/router_config.dart b/lib/src/routes/router_config.dart index 15eab9b0..b0f7361f 100644 --- a/lib/src/routes/router_config.dart +++ b/lib/src/routes/router_config.dart @@ -22,7 +22,6 @@ import '../features/manga_book/presentation/manga_details/manga_details_screen.d import '../features/manga_book/presentation/reader/reader_screen.dart'; import '../features/manga_book/presentation/updates/updates_screen.dart'; import '../features/manga_book/widgets/update_status_summary_sheet.dart'; -import '../features/quick_open/presentation/search_stack/search_stack_screen.dart'; import '../features/settings/presentation/appearance/appearance_screen.dart'; import '../features/settings/presentation/backup/backup_screen.dart'; import '../features/settings/presentation/browse/browse_settings_screen.dart'; @@ -40,9 +39,6 @@ part 'router_config.g.dart'; final GlobalKey _rootNavigatorKey = GlobalKey(debugLabel: 'root'); -final GlobalKey _quickOpenNavigatorKey = - GlobalKey(debugLabel: 'Quick Open'); - final GlobalKey _shellNavigatorKey = GlobalKey(debugLabel: 'shell'); @@ -83,52 +79,17 @@ GoRouter routerConfig(ref) { ); } -@TypedShellRoute( +// Shell Routes +@TypedShellRoute( routes: [ - TypedShellRoute( - routes: [ - TypedGoRoute(path: Routes.home), - TypedGoRoute(path: Routes.library), - TypedGoRoute(path: Routes.updates), - TypedGoRoute(path: Routes.browse), - TypedGoRoute(path: Routes.downloads), - TypedGoRoute(path: Routes.more), - ], - ), - TypedGoRoute(path: Routes.manga), - TypedGoRoute(path: Routes.updateStatus), - TypedGoRoute(path: Routes.globalSearch), - TypedGoRoute(path: Routes.sourcePreference), - TypedGoRoute(path: Routes.sourceManga), - TypedGoRoute(path: Routes.about), - TypedGoRoute(path: Routes.reader), - TypedGoRoute(path: Routes.settings, routes: [ - TypedGoRoute( - path: Routes.librarySettings, - routes: [ - TypedGoRoute(path: Routes.editCategories) - ], - ), - TypedGoRoute(path: Routes.serverSettings), - TypedGoRoute(path: Routes.readerSettings), - TypedGoRoute(path: Routes.appearanceSettings), - TypedGoRoute(path: Routes.generalSettings), - TypedGoRoute(path: Routes.browseSettings), - TypedGoRoute(path: Routes.backup), - ]) + TypedGoRoute(path: Routes.home), + TypedGoRoute(path: Routes.library), + TypedGoRoute(path: Routes.updates), + TypedGoRoute(path: Routes.browse), + TypedGoRoute(path: Routes.downloads), + TypedGoRoute(path: Routes.more), ], ) -class QuickSearchRoute extends ShellRouteData { - const QuickSearchRoute(); - - static final $navigatorKey = _quickOpenNavigatorKey; - - @override - Widget builder(context, state, navigator) => - SearchStackScreen(child: navigator); -} - -// Shell Routes class ShellRoute extends ShellRouteData { const ShellRoute(); @@ -181,40 +142,43 @@ class MoreRoute extends GoRouteData { const NoTransitionPage(child: MoreScreen()); } -// +@TypedGoRoute(path: Routes.manga) class MangaRoute extends GoRouteData { const MangaRoute({required this.mangaId, this.categoryId}); final int mangaId; final int? categoryId; - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Widget build(BuildContext context, GoRouterState state) => MangaDetailsScreen(mangaId: mangaId, categoryId: categoryId); } +@TypedGoRoute(path: Routes.updateStatus) class UpdateStatusRoute extends GoRouteData { const UpdateStatusRoute(); - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Widget build(BuildContext context, GoRouterState state) => const UpdateStatusSummaryDialog(); } +@TypedGoRoute(path: Routes.globalSearch) class GlobalSearchRoute extends GoRouteData { const GlobalSearchRoute({this.query}); final String? query; - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Widget build(BuildContext context, GoRouterState state) => GlobalSearchScreen(key: ValueKey(query), initialQuery: query); } +@TypedGoRoute(path: Routes.sourceManga) class SourceMangaRoute extends GoRouteData { const SourceMangaRoute({ required this.sourceId, @@ -227,7 +191,7 @@ class SourceMangaRoute extends GoRouteData { final String? query; final List? $extra; - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Widget build(BuildContext context, GoRouterState state) => @@ -240,11 +204,12 @@ class SourceMangaRoute extends GoRouteData { ); } +@TypedGoRoute(path: Routes.sourcePreference) class SourcePreferenceRoute extends GoRouteData { final String sourceId; const SourcePreferenceRoute({required this.sourceId}); - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Widget build(BuildContext context, GoRouterState state) { @@ -252,16 +217,18 @@ class SourcePreferenceRoute extends GoRouteData { } } +@TypedGoRoute(path: Routes.about) class AboutRoute extends GoRouteData { const AboutRoute(); - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Widget build(BuildContext context, GoRouterState state) => const AboutScreen(); } +@TypedGoRoute(path: Routes.reader) class ReaderRoute extends GoRouteData { const ReaderRoute({ required this.mangaId, @@ -276,7 +243,7 @@ class ReaderRoute extends GoRouteData { final bool? toPrev; final bool showReaderLayoutAnimation; - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Page buildPage(BuildContext context, GoRouterState state) { @@ -309,10 +276,22 @@ class ReaderRoute extends GoRouteData { } } +@TypedGoRoute(path: Routes.settings, routes: [ + TypedGoRoute( + path: Routes.librarySettings, + routes: [TypedGoRoute(path: Routes.editCategories)], + ), + TypedGoRoute(path: Routes.serverSettings), + TypedGoRoute(path: Routes.readerSettings), + TypedGoRoute(path: Routes.appearanceSettings), + TypedGoRoute(path: Routes.generalSettings), + TypedGoRoute(path: Routes.browseSettings), + TypedGoRoute(path: Routes.backup), +]) class SettingsRoute extends GoRouteData { const SettingsRoute(); - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Widget build(BuildContext context, GoRouterState state) => @@ -322,7 +301,7 @@ class SettingsRoute extends GoRouteData { class LibrarySettingsRoute extends GoRouteData { const LibrarySettingsRoute(); - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Widget build(BuildContext context, GoRouterState state) => @@ -332,7 +311,7 @@ class LibrarySettingsRoute extends GoRouteData { class EditCategoriesRoute extends GoRouteData { const EditCategoriesRoute(); - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Widget build(BuildContext context, GoRouterState state) => @@ -342,7 +321,7 @@ class EditCategoriesRoute extends GoRouteData { class ServerSettingsRoute extends GoRouteData { const ServerSettingsRoute(); - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Widget build(BuildContext context, GoRouterState state) => @@ -352,7 +331,7 @@ class ServerSettingsRoute extends GoRouteData { class ReaderSettingsRoute extends GoRouteData { const ReaderSettingsRoute(); - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Widget build(BuildContext context, GoRouterState state) => @@ -362,7 +341,7 @@ class ReaderSettingsRoute extends GoRouteData { class AppearanceSettingsRoute extends GoRouteData { const AppearanceSettingsRoute(); - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Widget build(BuildContext context, GoRouterState state) => @@ -372,7 +351,7 @@ class AppearanceSettingsRoute extends GoRouteData { class GeneralSettingsRoute extends GoRouteData { const GeneralSettingsRoute(); - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Widget build(BuildContext context, GoRouterState state) => @@ -382,7 +361,7 @@ class GeneralSettingsRoute extends GoRouteData { class BrowseSettingsRoute extends GoRouteData { const BrowseSettingsRoute(); - static final $parentNavigatorKey = _quickOpenNavigatorKey; + static final $parentNavigatorKey = _rootNavigatorKey; @override Widget build(BuildContext context, GoRouterState state) => diff --git a/lib/src/routes/router_config.g.dart b/lib/src/routes/router_config.g.dart index 419a6622..47fb8349 100644 --- a/lib/src/routes/router_config.g.dart +++ b/lib/src/routes/router_config.g.dart @@ -7,135 +7,48 @@ part of 'router_config.dart'; // ************************************************************************** List get $appRoutes => [ - $quickSearchRoute, + $shellRoute, + $mangaRoute, + $updateStatusRoute, + $globalSearchRoute, + $sourceMangaRoute, + $sourcePreferenceRoute, + $aboutRoute, + $readerRoute, + $settingsRoute, ]; -RouteBase get $quickSearchRoute => ShellRouteData.$route( - navigatorKey: QuickSearchRoute.$navigatorKey, - factory: $QuickSearchRouteExtension._fromState, +RouteBase get $shellRoute => ShellRouteData.$route( + navigatorKey: ShellRoute.$navigatorKey, + factory: $ShellRouteExtension._fromState, routes: [ - ShellRouteData.$route( - navigatorKey: ShellRoute.$navigatorKey, - factory: $ShellRouteExtension._fromState, - routes: [ - GoRouteData.$route( - path: '/', - factory: $HomeRouteExtension._fromState, - ), - GoRouteData.$route( - path: '/library', - factory: $LibraryRouteExtension._fromState, - ), - GoRouteData.$route( - path: '/updates', - factory: $UpdatesRouteExtension._fromState, - ), - GoRouteData.$route( - path: '/browse', - factory: $BrowseRouteExtension._fromState, - ), - GoRouteData.$route( - path: '/downloads', - factory: $DownloadsRouteExtension._fromState, - ), - GoRouteData.$route( - path: '/more', - factory: $MoreRouteExtension._fromState, - ), - ], - ), - GoRouteData.$route( - path: '/manga/:mangaId', - parentNavigatorKey: MangaRoute.$parentNavigatorKey, - factory: $MangaRouteExtension._fromState, - ), GoRouteData.$route( - path: '/update-status', - parentNavigatorKey: UpdateStatusRoute.$parentNavigatorKey, - factory: $UpdateStatusRouteExtension._fromState, + path: '/', + factory: $HomeRouteExtension._fromState, ), GoRouteData.$route( - path: '/global-search', - parentNavigatorKey: GlobalSearchRoute.$parentNavigatorKey, - factory: $GlobalSearchRouteExtension._fromState, + path: '/library', + factory: $LibraryRouteExtension._fromState, ), GoRouteData.$route( - path: '/source/:sourceId/preference', - parentNavigatorKey: SourcePreferenceRoute.$parentNavigatorKey, - factory: $SourcePreferenceRouteExtension._fromState, + path: '/updates', + factory: $UpdatesRouteExtension._fromState, ), GoRouteData.$route( - path: '/source/:sourceId/:sourceType', - parentNavigatorKey: SourceMangaRoute.$parentNavigatorKey, - factory: $SourceMangaRouteExtension._fromState, + path: '/browse', + factory: $BrowseRouteExtension._fromState, ), GoRouteData.$route( - path: '/about', - parentNavigatorKey: AboutRoute.$parentNavigatorKey, - factory: $AboutRouteExtension._fromState, + path: '/downloads', + factory: $DownloadsRouteExtension._fromState, ), GoRouteData.$route( - path: '/manga/:mangaId/chapter/:chapterIndex', - parentNavigatorKey: ReaderRoute.$parentNavigatorKey, - factory: $ReaderRouteExtension._fromState, - ), - GoRouteData.$route( - path: '/settings', - parentNavigatorKey: SettingsRoute.$parentNavigatorKey, - factory: $SettingsRouteExtension._fromState, - routes: [ - GoRouteData.$route( - path: 'library', - parentNavigatorKey: LibrarySettingsRoute.$parentNavigatorKey, - factory: $LibrarySettingsRouteExtension._fromState, - routes: [ - GoRouteData.$route( - path: 'edit-categories', - parentNavigatorKey: EditCategoriesRoute.$parentNavigatorKey, - factory: $EditCategoriesRouteExtension._fromState, - ), - ], - ), - GoRouteData.$route( - path: 'server', - parentNavigatorKey: ServerSettingsRoute.$parentNavigatorKey, - factory: $ServerSettingsRouteExtension._fromState, - ), - GoRouteData.$route( - path: 'reader', - parentNavigatorKey: ReaderSettingsRoute.$parentNavigatorKey, - factory: $ReaderSettingsRouteExtension._fromState, - ), - GoRouteData.$route( - path: 'appearance', - parentNavigatorKey: AppearanceSettingsRoute.$parentNavigatorKey, - factory: $AppearanceSettingsRouteExtension._fromState, - ), - GoRouteData.$route( - path: 'general', - parentNavigatorKey: GeneralSettingsRoute.$parentNavigatorKey, - factory: $GeneralSettingsRouteExtension._fromState, - ), - GoRouteData.$route( - path: 'browse', - parentNavigatorKey: BrowseSettingsRoute.$parentNavigatorKey, - factory: $BrowseSettingsRouteExtension._fromState, - ), - GoRouteData.$route( - path: 'backup', - parentNavigatorKey: BackupRoute.$parentNavigatorKey, - factory: $BackupRouteExtension._fromState, - ), - ], + path: '/more', + factory: $MoreRouteExtension._fromState, ), ], ); -extension $QuickSearchRouteExtension on QuickSearchRoute { - static QuickSearchRoute _fromState(GoRouterState state) => - const QuickSearchRoute(); -} - extension $ShellRouteExtension on ShellRoute { static ShellRoute _fromState(GoRouterState state) => const ShellRoute(); } @@ -250,6 +163,21 @@ extension $MoreRouteExtension on MoreRoute { void replace(BuildContext context) => context.replace(location); } +T? _$convertMapValue( + String key, + Map map, + T Function(String) converter, +) { + final value = map[key]; + return value == null ? null : converter(value); +} + +RouteBase get $mangaRoute => GoRouteData.$route( + path: '/manga/:mangaId', + parentNavigatorKey: MangaRoute.$parentNavigatorKey, + factory: $MangaRouteExtension._fromState, + ); + extension $MangaRouteExtension on MangaRoute { static MangaRoute _fromState(GoRouterState state) => MangaRoute( mangaId: int.parse(state.pathParameters['mangaId']!), @@ -274,6 +202,12 @@ extension $MangaRouteExtension on MangaRoute { void replace(BuildContext context) => context.replace(location); } +RouteBase get $updateStatusRoute => GoRouteData.$route( + path: '/update-status', + parentNavigatorKey: UpdateStatusRoute.$parentNavigatorKey, + factory: $UpdateStatusRouteExtension._fromState, + ); + extension $UpdateStatusRouteExtension on UpdateStatusRoute { static UpdateStatusRoute _fromState(GoRouterState state) => const UpdateStatusRoute(); @@ -292,6 +226,12 @@ extension $UpdateStatusRouteExtension on UpdateStatusRoute { void replace(BuildContext context) => context.replace(location); } +RouteBase get $globalSearchRoute => GoRouteData.$route( + path: '/global-search', + parentNavigatorKey: GlobalSearchRoute.$parentNavigatorKey, + factory: $GlobalSearchRouteExtension._fromState, + ); + extension $GlobalSearchRouteExtension on GlobalSearchRoute { static GlobalSearchRoute _fromState(GoRouterState state) => GlobalSearchRoute( query: state.uri.queryParameters['query'], @@ -314,25 +254,11 @@ extension $GlobalSearchRouteExtension on GlobalSearchRoute { void replace(BuildContext context) => context.replace(location); } -extension $SourcePreferenceRouteExtension on SourcePreferenceRoute { - static SourcePreferenceRoute _fromState(GoRouterState state) => - SourcePreferenceRoute( - sourceId: state.pathParameters['sourceId']!, - ); - - String get location => GoRouteData.$location( - '/source/${Uri.encodeComponent(sourceId)}/preference', - ); - - void go(BuildContext context) => context.go(location); - - Future push(BuildContext context) => context.push(location); - - void pushReplacement(BuildContext context) => - context.pushReplacement(location); - - void replace(BuildContext context) => context.replace(location); -} +RouteBase get $sourceMangaRoute => GoRouteData.$route( + path: '/source/:sourceId/:sourceType', + parentNavigatorKey: SourceMangaRoute.$parentNavigatorKey, + factory: $SourceMangaRouteExtension._fromState, + ); extension $SourceMangaRouteExtension on SourceMangaRoute { static SourceMangaRoute _fromState(GoRouterState state) => SourceMangaRoute( @@ -368,6 +294,43 @@ const _$SourceTypeEnumMap = { SourceType.filter: 'filter', }; +extension on Map { + T _$fromName(String value) => + entries.singleWhere((element) => element.value == value).key; +} + +RouteBase get $sourcePreferenceRoute => GoRouteData.$route( + path: '/source/:sourceId/preference', + parentNavigatorKey: SourcePreferenceRoute.$parentNavigatorKey, + factory: $SourcePreferenceRouteExtension._fromState, + ); + +extension $SourcePreferenceRouteExtension on SourcePreferenceRoute { + static SourcePreferenceRoute _fromState(GoRouterState state) => + SourcePreferenceRoute( + sourceId: state.pathParameters['sourceId']!, + ); + + String get location => GoRouteData.$location( + '/source/${Uri.encodeComponent(sourceId)}/preference', + ); + + void go(BuildContext context) => context.go(location); + + Future push(BuildContext context) => context.push(location); + + void pushReplacement(BuildContext context) => + context.pushReplacement(location); + + void replace(BuildContext context) => context.replace(location); +} + +RouteBase get $aboutRoute => GoRouteData.$route( + path: '/about', + parentNavigatorKey: AboutRoute.$parentNavigatorKey, + factory: $AboutRouteExtension._fromState, + ); + extension $AboutRouteExtension on AboutRoute { static AboutRoute _fromState(GoRouterState state) => const AboutRoute(); @@ -385,6 +348,12 @@ extension $AboutRouteExtension on AboutRoute { void replace(BuildContext context) => context.replace(location); } +RouteBase get $readerRoute => GoRouteData.$route( + path: '/manga/:mangaId/chapter/:chapterIndex', + parentNavigatorKey: ReaderRoute.$parentNavigatorKey, + factory: $ReaderRouteExtension._fromState, + ); + extension $ReaderRouteExtension on ReaderRoute { static ReaderRoute _fromState(GoRouterState state) => ReaderRoute( mangaId: int.parse(state.pathParameters['mangaId']!), @@ -422,6 +391,67 @@ extension $ReaderRouteExtension on ReaderRoute { void replace(BuildContext context) => context.replace(location); } +bool _$boolConverter(String value) { + switch (value) { + case 'true': + return true; + case 'false': + return false; + default: + throw UnsupportedError('Cannot convert "$value" into a bool.'); + } +} + +RouteBase get $settingsRoute => GoRouteData.$route( + path: '/settings', + parentNavigatorKey: SettingsRoute.$parentNavigatorKey, + factory: $SettingsRouteExtension._fromState, + routes: [ + GoRouteData.$route( + path: 'library', + parentNavigatorKey: LibrarySettingsRoute.$parentNavigatorKey, + factory: $LibrarySettingsRouteExtension._fromState, + routes: [ + GoRouteData.$route( + path: 'edit-categories', + parentNavigatorKey: EditCategoriesRoute.$parentNavigatorKey, + factory: $EditCategoriesRouteExtension._fromState, + ), + ], + ), + GoRouteData.$route( + path: 'server', + parentNavigatorKey: ServerSettingsRoute.$parentNavigatorKey, + factory: $ServerSettingsRouteExtension._fromState, + ), + GoRouteData.$route( + path: 'reader', + parentNavigatorKey: ReaderSettingsRoute.$parentNavigatorKey, + factory: $ReaderSettingsRouteExtension._fromState, + ), + GoRouteData.$route( + path: 'appearance', + parentNavigatorKey: AppearanceSettingsRoute.$parentNavigatorKey, + factory: $AppearanceSettingsRouteExtension._fromState, + ), + GoRouteData.$route( + path: 'general', + parentNavigatorKey: GeneralSettingsRoute.$parentNavigatorKey, + factory: $GeneralSettingsRouteExtension._fromState, + ), + GoRouteData.$route( + path: 'browse', + parentNavigatorKey: BrowseSettingsRoute.$parentNavigatorKey, + factory: $BrowseSettingsRouteExtension._fromState, + ), + GoRouteData.$route( + path: 'backup', + parentNavigatorKey: BackupRoute.$parentNavigatorKey, + factory: $BackupRouteExtension._fromState, + ), + ], + ); + extension $SettingsRouteExtension on SettingsRoute { static SettingsRoute _fromState(GoRouterState state) => const SettingsRoute(); @@ -582,31 +612,6 @@ extension $BackupRouteExtension on BackupRoute { void replace(BuildContext context) => context.replace(location); } -T? _$convertMapValue( - String key, - Map map, - T Function(String) converter, -) { - final value = map[key]; - return value == null ? null : converter(value); -} - -extension on Map { - T _$fromName(String value) => - entries.singleWhere((element) => element.value == value).key; -} - -bool _$boolConverter(String value) { - switch (value) { - case 'true': - return true; - case 'false': - return false; - default: - throw UnsupportedError('Cannot convert "$value" into a bool.'); - } -} - // ************************************************************************** // RiverpodGenerator // ************************************************************************** diff --git a/lib/src/sorayomi.dart b/lib/src/sorayomi.dart index dac36958..3c713d36 100644 --- a/lib/src/sorayomi.dart +++ b/lib/src/sorayomi.dart @@ -35,15 +35,13 @@ class Sorayomi extends ConsumerWidget { routeInformationProvider: routes.routeInformationProvider, routeInformationParser: routes.routeInformationParser, routerDelegate: routes.routerDelegate, - builder: (context, child) { - return Overlay( - initialEntries: [ - OverlayEntry( - builder: (context) => SearchStackScreen(child: child), - ), - ], - ); - }, + builder: (context, child) => Overlay( + initialEntries: [ + OverlayEntry( + builder: (context) => SearchStackScreen(child: child), + ), + ], + ), ); } } diff --git a/lib/src/widgets/two_finger_pointer.dart b/lib/src/widgets/two_finger_pointer.dart deleted file mode 100644 index 657f9a30..00000000 --- a/lib/src/widgets/two_finger_pointer.dart +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) 2023 Contributors to the Suwayomi project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -import 'package:flutter/gestures.dart'; -import 'package:flutter/material.dart'; - -class TwoFingerPointerWidget extends StatelessWidget { - final Widget child; - final OnUpdate onUpdate; - - const TwoFingerPointerWidget({ - Key? key, - required this.child, - required this.onUpdate, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return RawGestureDetector( - gestures: { - CustomVerticalMultiDragGestureRecognizer: - GestureRecognizerFactoryWithHandlers< - CustomVerticalMultiDragGestureRecognizer>( - () => CustomVerticalMultiDragGestureRecognizer(debugOwner: null), - (CustomVerticalMultiDragGestureRecognizer instance) { - instance.onStart = (Offset position) { - return CustomDrag( - events: instance.events, - onUpdate: onUpdate, - ); - }; - }, - ), - }, - child: child, - ); - } -} - -typedef OnUpdate = Function(DragUpdateDetails details); - -class CustomDrag extends Drag { - final List events; - - final OnUpdate onUpdate; - - CustomDrag({required this.events, required this.onUpdate}); - - @override - void update(DragUpdateDetails details) { - super.update(details); - final delta = details.delta; - if (delta.dy.abs() > 0 && events.length == 2) { - onUpdate.call(DragUpdateDetails( - sourceTimeStamp: details.sourceTimeStamp, - delta: Offset(0, delta.dy), - primaryDelta: details.primaryDelta, - globalPosition: details.globalPosition, - localPosition: details.localPosition, - )); - } - } -} - -class CustomVerticalMultiDragGestureRecognizer - extends MultiDragGestureRecognizer { - final List events = []; - - CustomVerticalMultiDragGestureRecognizer({required Object? debugOwner}) - : super(debugOwner: debugOwner); - - @override - createNewPointerState(PointerDownEvent event) { - events.add(event); - return _CustomVerticalPointerState(event.position, onDisposeState: () { - events.remove(event); - }); - } - - @override - String get debugDescription => 'custom vertical multi drag'; -} - -typedef OnDisposeState = Function(); - -class _CustomVerticalPointerState extends MultiDragPointerState { - final OnDisposeState onDisposeState; - - _CustomVerticalPointerState(Offset initialPosition, - {required this.onDisposeState}) - : super(initialPosition, PointerDeviceKind.touch, null); - - @override - void checkForResolutionAfterMove() { - if (pendingDelta!.dy.abs() > kTouchSlop) { - resolve(GestureDisposition.accepted); - } - } - - @override - void accepted(GestureMultiDragStartCallback starter) { - starter(initialPosition); - } - - @override - void dispose() { - onDisposeState.call(); - super.dispose(); - } -} diff --git a/pubspec.yaml b/pubspec.yaml index 4818680b..256d6362 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: tachidesk_sorayomi description: A new Flutter frontend for Tachidesk. publish_to: "none" -version: 0.5.12+1 +version: 0.5.14+1 environment: sdk: ">=3.0.0 <4.0.0"