mirror of
https://github.com/h7x4/Jisho-Study-Tool.git
synced 2024-12-21 13:37:29 +01:00
Add search buttons and explanations (#32)
* Add search button * Add search tip to kanji search
This commit is contained in:
parent
28f900c02e
commit
3d30a81205
@ -93,9 +93,17 @@ class _KanjiSearchBodyState extends State<KanjiSearchBody>
|
||||
AnimatedSizeAndFade(
|
||||
fadeDuration: const Duration(milliseconds: 200),
|
||||
sizeDuration: const Duration(milliseconds: 300),
|
||||
child: _controller.value == 1
|
||||
child: (_controller.value == 1 && suggestions.isNotEmpty)
|
||||
? KanjiGrid(suggestions: suggestions)
|
||||
: const KanjiSearchOptionsBar(),
|
||||
: (_controller.value == 1)
|
||||
? const Text(
|
||||
'Type a kanji to start searching',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
)
|
||||
: const KanjiSearchOptionsBar(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -53,7 +53,6 @@ class KanjiSearchBarState extends State<KanjiSearchBar> {
|
||||
onChanged: (text) => onChanged(),
|
||||
onSubmitted: (_) => {},
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: const Icon(Icons.search),
|
||||
hintText: 'Search',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
|
@ -1,10 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../models/themes/theme.dart';
|
||||
import '../../routing/routes.dart';
|
||||
import 'language_selector.dart';
|
||||
|
||||
class SearchBar extends StatelessWidget {
|
||||
const SearchBar({Key? key}) : super(key: key);
|
||||
final TextEditingController controller = TextEditingController();
|
||||
|
||||
SearchBar({Key? key}) : super(key: key);
|
||||
|
||||
void _search(BuildContext context, String text) => Navigator.pushNamed(
|
||||
context,
|
||||
Routes.search,
|
||||
arguments: text,
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -13,17 +22,34 @@ class SearchBar extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
TextField(
|
||||
onSubmitted: (text) =>
|
||||
Navigator.pushNamed(context, Routes.search, arguments: text),
|
||||
controller: TextEditingController(),
|
||||
onSubmitted: (text) => _search(context, text),
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Search',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
suffixIconConstraints: const BoxConstraints.tightFor(height: 60),
|
||||
suffixIcon: Material(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topRight: Radius.circular(10.0),
|
||||
bottomRight: Radius.circular(10.0),
|
||||
),
|
||||
color: AppTheme.jishoGreen.background,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
if (controller.text.isNotEmpty)
|
||||
_search(context, controller.text);
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.search,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
const SizedBox(height: 20),
|
||||
const LanguageSelector()
|
||||
],
|
||||
),
|
||||
|
@ -8,9 +8,7 @@ class SearchView extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
SearchBar(),
|
||||
],
|
||||
children: <Widget>[SearchBar()],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ packages:
|
||||
name: flutter_svg
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
version: "1.0.3"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@ -407,7 +407,7 @@ packages:
|
||||
name: just_audio_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.2"
|
||||
version: "0.4.3"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
Loading…
Reference in New Issue
Block a user