Jisho-Study-Tool/lib/components/search/search_bar.dart

61 lines
1.8 KiB
Dart
Raw Permalink Normal View History

2021-03-05 22:12:04 +01:00
import 'package:flutter/material.dart';
2021-12-01 23:09:53 +01:00
import '../../models/themes/theme.dart';
2022-01-19 02:10:05 +01:00
import '../../routing/routes.dart';
2022-01-23 23:56:26 +01:00
import '../../settings.dart';
2021-12-01 23:09:53 +01:00
import 'language_selector.dart';
2021-03-05 22:12:04 +01:00
class SearchBar extends StatelessWidget {
final TextEditingController controller = TextEditingController();
SearchBar({Key? key}) : super(key: key);
void _search(BuildContext context, String text) => Navigator.pushNamed(
context,
Routes.search,
arguments: text,
);
2021-03-05 22:12:04 +01:00
@override
Widget build(BuildContext context) {
return Container(
2021-12-01 23:09:53 +01:00
padding: const EdgeInsets.symmetric(horizontal: 20.0),
2021-03-05 22:12:04 +01:00
child: Column(
children: [
TextField(
onSubmitted: (text) => _search(context, text),
controller: controller,
2022-01-23 23:56:26 +01:00
style: japaneseFont.textStyle,
2021-03-05 22:12:04 +01:00
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,
),
),
),
2021-03-05 22:12:04 +01:00
),
),
const SizedBox(height: 20),
2021-12-01 23:09:53 +01:00
const LanguageSelector()
2021-03-05 22:12:04 +01:00
],
),
);
}
}