start new search when no results
This commit is contained in:
+9
-2
@@ -28,13 +28,20 @@ class FindInPageController extends _$FindInPageController {
|
|||||||
return service.findAll(text);
|
return service.findAll(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> findNext({bool forward = true}) {
|
Future<void> findNext({required String fallbackText, bool forward = true}) {
|
||||||
final tabId = ref.read(selectedTabProvider);
|
final tabId = ref.read(selectedTabProvider);
|
||||||
final service = ref.read(findInPageRepositoryProvider(tabId).notifier);
|
final service = ref.read(findInPageRepositoryProvider(tabId).notifier);
|
||||||
|
|
||||||
|
final hasMatches =
|
||||||
|
ref.read(selectedTabStateProvider)?.findResultState.hasMatches == true;
|
||||||
|
|
||||||
state = state.copyWith.visible(true);
|
state = state.copyWith.visible(true);
|
||||||
|
|
||||||
return service.findNext(forward);
|
if (hasMatches) {
|
||||||
|
return service.findNext(forward);
|
||||||
|
} else {
|
||||||
|
return service.findAll(fallbackText);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> clearMatches() {
|
Future<void> clearMatches() {
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ part of 'find_in_page.dart';
|
|||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$findInPageControllerHash() =>
|
String _$findInPageControllerHash() =>
|
||||||
r'ab421be931406325bf6b22dd9f545117ea426665';
|
r'fd335be9345b405856cf2aa68312d4d1535d8c5e';
|
||||||
|
|
||||||
/// See also [FindInPageController].
|
/// See also [FindInPageController].
|
||||||
@ProviderFor(FindInPageController)
|
@ProviderFor(FindInPageController)
|
||||||
|
|||||||
+9
-10
@@ -61,21 +61,20 @@ class FindInPageWidget extends HookConsumerWidget {
|
|||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.arrow_upward),
|
icon: const Icon(Icons.arrow_upward),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (searchResult?.hasMatches ?? false) {
|
await ref
|
||||||
await ref
|
.read(findInPageControllerProvider.notifier)
|
||||||
.read(findInPageControllerProvider.notifier)
|
.findNext(
|
||||||
.findNext(forward: false);
|
forward: false,
|
||||||
}
|
fallbackText: textController.text,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.arrow_downward),
|
icon: const Icon(Icons.arrow_downward),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (searchResult?.hasMatches ?? false) {
|
await ref
|
||||||
await ref
|
.read(findInPageControllerProvider.notifier)
|
||||||
.read(findInPageControllerProvider.notifier)
|
.findNext(fallbackText: textController.text);
|
||||||
.findNext();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
|
|||||||
Reference in New Issue
Block a user