Add search button
This commit is contained in:
parent
28f900c02e
commit
6aab6d57bc
|
@ -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