diff --git a/lib/src/constants/db_keys.dart b/lib/src/constants/db_keys.dart index 0e3e06f1..282702ea 100644 --- a/lib/src/constants/db_keys.dart +++ b/lib/src/constants/db_keys.dart @@ -25,6 +25,7 @@ enum DBKeys { readerMagnifierSize(1.0), readerNavigationLayout(ReaderNavigationLayout.disabled), invertTap(false), + quickSearchToggle(true), swipeToggle(true), scrollAnimation(true), showNSFW(true), diff --git a/lib/src/features/about/presentation/about/widget/app_update_dialog.dart b/lib/src/features/about/presentation/about/widget/app_update_dialog.dart index 528c23b4..19d73342 100644 --- a/lib/src/features/about/presentation/about/widget/app_update_dialog.dart +++ b/lib/src/features/about/presentation/about/widget/app_update_dialog.dart @@ -21,7 +21,7 @@ void appUpdateDialog({ }) => showDialog( context: context, - builder: (_) { + builder: (context) { return AlertDialog( title: Text(context.l10n!.newUpdateAvailable), content: Text(context.l10n!.versionAvailable(title, newRelease)), diff --git a/lib/src/features/quick_open/presentation/quick_search/quick_search_screen.dart b/lib/src/features/quick_open/presentation/quick_search/quick_search_screen.dart index fd5fe1f9..207ac813 100644 --- a/lib/src/features/quick_open/presentation/quick_search/quick_search_screen.dart +++ b/lib/src/features/quick_open/presentation/quick_search/quick_search_screen.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:gap/gap.dart'; import '../../../../utils/extensions/custom_extensions.dart'; import 'widgets/quick_query_result.dart'; @@ -38,6 +39,7 @@ class QuickSearchScreen extends HookWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ + const Gap(32), QuickSearchBar(controller: controller), Flexible( child: QuickQueryResult( 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 e197540d..10043843 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 @@ -11,20 +11,24 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; import '../../../../utils/extensions/custom_extensions.dart'; +import '../../../settings/presentation/general/quick_search_toggle/quick_search_toggle_tile.dart'; import '../quick_search/quick_search_screen.dart'; class ShowQuickOpenIntent extends Intent {} class HideQuickOpenIntent extends Intent {} -class SearchStackScreen extends HookWidget { +class SearchStackScreen extends HookConsumerWidget { const SearchStackScreen({super.key, this.child}); final Widget? child; @override - Widget build(BuildContext context) { + Widget build(context, ref) { final visible = useState(false); + final isQuickSearchEnabled = ref.watch(quickSearchToggleProvider).ifNull(); + if (!isQuickSearchEnabled) return child!; return QuickSearchShortcutWrapper( visible: visible, child: Stack( diff --git a/lib/src/features/settings/presentation/general/general_screen.dart b/lib/src/features/settings/presentation/general/general_screen.dart index ec5fff05..4f2d46bd 100644 --- a/lib/src/features/settings/presentation/general/general_screen.dart +++ b/lib/src/features/settings/presentation/general/general_screen.dart @@ -14,6 +14,7 @@ import '../../../../global_providers/global_providers.dart'; import '../../../../utils/extensions/custom_extensions.dart'; import '../../../../utils/misc/toast/toast.dart'; import '../../../../widgets/radio_list_popup.dart'; +import 'quick_search_toggle/quick_search_toggle_tile.dart'; class GeneralScreen extends ConsumerWidget { const GeneralScreen({super.key}); @@ -56,6 +57,7 @@ class GeneralScreen extends ConsumerWidget { } }, ), + const QuickSearchToggleTile(), ], ), ); diff --git a/lib/src/features/settings/presentation/general/quick_search_toggle/quick_search_toggle_tile.dart b/lib/src/features/settings/presentation/general/quick_search_toggle/quick_search_toggle_tile.dart new file mode 100644 index 00000000..e1c76583 --- /dev/null +++ b/lib/src/features/settings/presentation/general/quick_search_toggle/quick_search_toggle_tile.dart @@ -0,0 +1,36 @@ +// Copyright (c) 2022 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/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; + +import '../../../../../constants/db_keys.dart'; +import '../../../../../utils/extensions/custom_extensions.dart'; +import '../../../../../utils/mixin/shared_preferences_client_mixin.dart'; + +part 'quick_search_toggle_tile.g.dart'; + +@riverpod +class QuickSearchToggle extends _$QuickSearchToggle + with SharedPreferenceClientMixin { + @override + bool? build() => initialize(DBKeys.quickSearchToggle); +} + +class QuickSearchToggleTile extends HookConsumerWidget { + const QuickSearchToggleTile({super.key}); + @override + Widget build(BuildContext context, WidgetRef ref) { + return SwitchListTile( + controlAffinity: ListTileControlAffinity.trailing, + secondary: const Icon(Icons.search_rounded), + title: Text(context.l10n!.quickSearch), + onChanged: ref.read(quickSearchToggleProvider.notifier).update, + value: ref.watch(quickSearchToggleProvider).ifNull(), + ); + } +} diff --git a/lib/src/features/settings/presentation/general/quick_search_toggle/quick_search_toggle_tile.g.dart b/lib/src/features/settings/presentation/general/quick_search_toggle/quick_search_toggle_tile.g.dart new file mode 100644 index 00000000..cb067edb --- /dev/null +++ b/lib/src/features/settings/presentation/general/quick_search_toggle/quick_search_toggle_tile.g.dart @@ -0,0 +1,26 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'quick_search_toggle_tile.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$quickSearchToggleHash() => r'1805371cc00c16e3156bc431adf9e5e1cb604f10'; + +/// See also [QuickSearchToggle]. +@ProviderFor(QuickSearchToggle) +final quickSearchToggleProvider = + AutoDisposeNotifierProvider.internal( + QuickSearchToggle.new, + name: r'quickSearchToggleProvider', + debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') + ? null + : _$quickSearchToggleHash, + dependencies: null, + allTransitiveDependencies: null, +); + +typedef _$QuickSearchToggle = AutoDisposeNotifier; +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/lib/src/features/settings/presentation/general/quick_search_toggle/reader_invert_tap_tile.g.dart b/lib/src/features/settings/presentation/general/quick_search_toggle/reader_invert_tap_tile.g.dart new file mode 100644 index 00000000..ba1770a3 --- /dev/null +++ b/lib/src/features/settings/presentation/general/quick_search_toggle/reader_invert_tap_tile.g.dart @@ -0,0 +1,25 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'reader_invert_tap_tile.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$invertTapHash() => r'c4bde6eb87d0f7ede8eff109d63056af85a2fdc7'; + +/// See also [InvertTap]. +@ProviderFor(InvertTap) +final invertTapProvider = + AutoDisposeNotifierProvider.internal( + InvertTap.new, + name: r'invertTapProvider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') ? null : _$invertTapHash, + dependencies: null, + allTransitiveDependencies: null, +); + +typedef _$InvertTap = AutoDisposeNotifier; +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/lib/src/l10n/app_en.arb b/lib/src/l10n/app_en.arb index 1af077d3..681db081 100644 --- a/lib/src/l10n/app_en.arb +++ b/lib/src/l10n/app_en.arb @@ -421,6 +421,9 @@ "@previousChapter": { "description": "Text for Previous Chapter button in Manga Reader Screen" }, + "@quickSearch": { + "description": "Screen title and Button text of Quick Search screen" + }, "@quickSearchCategory": { "description": "Quick Open Hint text for Category C with prefill '#C'" }, @@ -823,6 +826,7 @@ "pending": "Pending", "pinchToZoom": "Pinch to Zoom", "previousChapter": "Previous: {chapterTitle}", + "quickSearch": "Quick Search", "quickSearchCategory": "Go to Category 'C'", "quickSearchCategoryManga": "Go to Manga 'M' in Category 'C'", "quickSearchCategoryMangaChapter": "Go to Chapter Name 'CN' from Manga 'M' in Category 'C'", diff --git a/pubspec.yaml b/pubspec.yaml index 67e68351..f8dd5801 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.22+1 +version: 0.5.23+1 environment: sdk: ">=3.0.0 <4.0.0"