mirror of
https://github.com/KRTirtho/spotube.git
synced 2026-06-20 18:08: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,61 +128,49 @@ class SearchPage extends HookConsumerWidget {
|
|||||||
)
|
)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
return KeyboardListener(
|
return AutoComplete(
|
||||||
focusNode: focusNode,
|
suggestions: suggestions.length <= 2
|
||||||
autofocus: true,
|
? [
|
||||||
onKeyEvent: (value) {
|
...suggestions,
|
||||||
final isEnter = value.logicalKey ==
|
"Twenty One Pilots",
|
||||||
LogicalKeyboardKey.enter;
|
"Linkin Park",
|
||||||
|
"d4vd"
|
||||||
if (isEnter) {
|
]
|
||||||
onSubmitted(controller.text);
|
: suggestions,
|
||||||
focusNode.unfocus();
|
completer: (suggestion) => suggestion,
|
||||||
}
|
mode: AutoCompleteMode.replaceAll,
|
||||||
},
|
child: TextField(
|
||||||
child: AutoComplete(
|
autofocus: true,
|
||||||
suggestions: suggestions.length <= 2
|
controller: controller,
|
||||||
? [
|
focusNode: focusNode,
|
||||||
...suggestions,
|
features: [
|
||||||
"Twenty One Pilots",
|
const InputFeature.leading(
|
||||||
"Linkin Park",
|
Icon(SpotubeIcons.search),
|
||||||
"d4vd"
|
),
|
||||||
]
|
InputFeature.trailing(
|
||||||
: suggestions,
|
AnimatedCrossFade(
|
||||||
completer: (suggestion) => suggestion,
|
duration:
|
||||||
mode: AutoCompleteMode.replaceAll,
|
const Duration(milliseconds: 300),
|
||||||
child: TextField(
|
crossFadeState:
|
||||||
autofocus: true,
|
controller.text.isNotEmpty
|
||||||
controller: controller,
|
? CrossFadeState.showFirst
|
||||||
features: [
|
: CrossFadeState.showSecond,
|
||||||
const InputFeature.leading(
|
firstChild: IconButton.ghost(
|
||||||
Icon(SpotubeIcons.search),
|
size: ButtonSize.small,
|
||||||
),
|
icon:
|
||||||
InputFeature.trailing(
|
const Icon(SpotubeIcons.close),
|
||||||
AnimatedCrossFade(
|
onPressed: () {
|
||||||
duration:
|
controller.clear();
|
||||||
const Duration(milliseconds: 300),
|
},
|
||||||
crossFadeState:
|
|
||||||
controller.text.isNotEmpty
|
|
||||||
? CrossFadeState.showFirst
|
|
||||||
: CrossFadeState.showSecond,
|
|
||||||
firstChild: IconButton.ghost(
|
|
||||||
size: ButtonSize.small,
|
|
||||||
icon:
|
|
||||||
const Icon(SpotubeIcons.close),
|
|
||||||
onPressed: () {
|
|
||||||
controller.clear();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
secondChild: const SizedBox.square(
|
|
||||||
dimension: 28),
|
|
||||||
),
|
),
|
||||||
)
|
secondChild: const SizedBox.square(
|
||||||
],
|
dimension: 28),
|
||||||
textInputAction: TextInputAction.search,
|
),
|
||||||
placeholder: Text(context.l10n.search),
|
)
|
||||||
onSubmitted: onSubmitted,
|
],
|
||||||
),
|
textInputAction: TextInputAction.search,
|
||||||
|
placeholder: Text(context.l10n.search),
|
||||||
|
onSubmitted: onSubmitted,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user