mirror of
https://github.com/KRTirtho/spotube.git
synced 2026-06-22 10:58:04 +00:00
SearchFix Assisted-By:Gemini
This commit is contained in:
parent
2cc8d2620d
commit
5f94461071
@ -59,6 +59,7 @@ class SearchPage extends HookConsumerWidget {
|
|||||||
|
|
||||||
void onSubmitted(String value) {
|
void onSubmitted(String value) {
|
||||||
ref.read(searchTermStateProvider.notifier).state = value;
|
ref.read(searchTermStateProvider.notifier).state = value;
|
||||||
|
focusNode.unfocus();
|
||||||
if (value.trim().isEmpty) {
|
if (value.trim().isEmpty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -127,19 +128,7 @@ class SearchPage extends HookConsumerWidget {
|
|||||||
)
|
)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
return KeyboardListener(
|
return AutoComplete(
|
||||||
focusNode: focusNode,
|
|
||||||
autofocus: true,
|
|
||||||
onKeyEvent: (value) {
|
|
||||||
final isEnter = value.logicalKey ==
|
|
||||||
LogicalKeyboardKey.enter;
|
|
||||||
|
|
||||||
if (isEnter) {
|
|
||||||
onSubmitted(controller.text);
|
|
||||||
focusNode.unfocus();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: AutoComplete(
|
|
||||||
suggestions: suggestions.length <= 2
|
suggestions: suggestions.length <= 2
|
||||||
? [
|
? [
|
||||||
...suggestions,
|
...suggestions,
|
||||||
@ -153,6 +142,7 @@ class SearchPage extends HookConsumerWidget {
|
|||||||
child: TextField(
|
child: TextField(
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
|
focusNode: focusNode,
|
||||||
features: [
|
features: [
|
||||||
const InputFeature.leading(
|
const InputFeature.leading(
|
||||||
Icon(SpotubeIcons.search),
|
Icon(SpotubeIcons.search),
|
||||||
@ -182,7 +172,6 @@ class SearchPage extends HookConsumerWidget {
|
|||||||
placeholder: Text(context.l10n.search),
|
placeholder: Text(context.l10n.search),
|
||||||
onSubmitted: onSubmitted,
|
onSubmitted: onSubmitted,
|
||||||
),
|
),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user