-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrates to a modal-based search to avoid quirks related to fullscree…
…n search
- Loading branch information
1 parent
840c2db
commit 9529853
Showing
6 changed files
with
143 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:kotobaten/consts/colors.dart'; | ||
import 'package:kotobaten/consts/paddings.dart'; | ||
import 'package:kotobaten/views/organisms/search/search_results.dart'; | ||
import 'package:kotobaten/views/screens/search.model.dart'; | ||
import 'package:kotobaten/views/screens/search.viewmodel.dart'; | ||
|
||
class UniversalSearchV3 extends HookConsumerWidget { | ||
const UniversalSearchV3({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final viewModel = ref.read(searchViewModelProvider.notifier); | ||
final model = ref.watch(searchViewModelProvider); | ||
|
||
var loadedCounter = "No results"; | ||
if (model is SearchModelLoaded) { | ||
if (model.dictionaryCards.isNotEmpty && model.cards.isEmpty) { | ||
loadedCounter = "${model.dictionaryCards.length} dictionary results"; | ||
} | ||
|
||
if (model.cards.isNotEmpty && model.dictionaryCards.isEmpty) { | ||
loadedCounter = "${model.cards.length} collection results"; | ||
} | ||
|
||
if (model.cards.isNotEmpty && model.dictionaryCards.isNotEmpty) { | ||
loadedCounter = | ||
"${model.cards.length} collection + ${model.dictionaryCards.length} dictionary results"; | ||
} | ||
} | ||
|
||
return Column( | ||
children: [ | ||
Padding( | ||
padding: bottomPadding(PaddingType.standard), | ||
child: TextField( | ||
autofocus: true, | ||
controller: viewModel.searchTermController, | ||
decoration: InputDecoration( | ||
counter: viewModel is SearchModelLoading | ||
? SizedBox.fromSize( | ||
size: const Size(12, 12), | ||
child: const CircularProgressIndicator(strokeWidth: 1), | ||
) | ||
: (viewModel is SearchModelInitial | ||
? null | ||
: Text(loadedCounter)), | ||
labelText: "Universal search", | ||
border: const UnderlineInputBorder(), | ||
suffixIcon: const Icon(Icons.search), | ||
), | ||
onSubmitted: (value) { | ||
// Implement your search function here | ||
}, | ||
), | ||
), | ||
Expanded( | ||
child: viewModel.searchTermController.text.isNotEmpty | ||
? (model is SearchModelLoaded && | ||
(model.cards.isNotEmpty || | ||
model.dictionaryCards.isNotEmpty) | ||
? const SearchResults() | ||
: Center( | ||
child: Text( | ||
"No results.", | ||
style: TextStyle(color: getDescriptionColor(context)), | ||
))) | ||
: Center( | ||
child: Text( | ||
"Search the dictionary and your collection, all at once.", | ||
style: TextStyle(color: getDescriptionColor(context)), | ||
))) | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters