2021-03-05 22:12:04 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2021-12-01 23:09:53 +01:00
|
|
|
|
2022-01-23 21:00:45 +01:00
|
|
|
import '../../models/themes/theme.dart';
|
2022-01-19 02:10:05 +01:00
|
|
|
import '../../routing/routes.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 {
|
2022-01-23 21:00:45 +01:00
|
|
|
final TextEditingController controller = TextEditingController();
|
|
|
|
|
|
|
|
SearchBar({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
void _search(BuildContext context, String text) => Navigator.pushNamed(
|
|
|
|
context,
|
|
|
|
Routes.search,
|
|
|
|
arguments: text,
|
|
|
|
);
|
2021-08-03 22:13:50 +02:00
|
|
|
|
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(
|
2022-01-23 21:00:45 +01:00
|
|
|
onSubmitted: (text) => _search(context, text),
|
|
|
|
controller: controller,
|
2021-03-05 22:12:04 +01:00
|
|
|
decoration: InputDecoration(
|
|
|
|
labelText: 'Search',
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
borderRadius: BorderRadius.circular(10.0),
|
|
|
|
),
|
2022-01-23 21:00:45 +01:00
|
|
|
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
|
|
|
),
|
|
|
|
),
|
2022-01-23 21:00:45 +01:00
|
|
|
const SizedBox(height: 20),
|
2021-12-01 23:09:53 +01:00
|
|
|
const LanguageSelector()
|
2021-03-05 22:12:04 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2021-09-07 00:05:33 +02:00
|
|
|
}
|