2022-05-13 06:02:53 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
2022-05-16 08:39:02 +02:00
|
|
|
import 'package:nekoya_flutter/components/search_page.dart';
|
2022-05-13 06:02:53 +02:00
|
|
|
|
2022-05-16 02:51:47 +02:00
|
|
|
import 'package:nekoya_flutter/utils/utils.dart';
|
2022-05-13 06:02:53 +02:00
|
|
|
|
|
|
|
const OutlineInputBorder outlineInputBorder = OutlineInputBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(12)),
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
);
|
|
|
|
|
2022-05-16 08:39:02 +02:00
|
|
|
class SearchForm extends StatefulWidget {
|
|
|
|
const SearchForm({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<SearchForm> createState() => _SearchFormState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SearchFormState extends State<SearchForm> {
|
|
|
|
TextEditingController searchController = TextEditingController();
|
2022-05-13 06:02:53 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Form(
|
|
|
|
child: TextFormField(
|
2022-05-16 15:30:32 +02:00
|
|
|
style: const TextStyle(color: Colors.white),
|
2022-05-16 08:39:02 +02:00
|
|
|
controller: searchController,
|
2022-05-13 06:02:53 +02:00
|
|
|
decoration: InputDecoration(
|
|
|
|
filled: true,
|
2022-05-15 11:34:17 +02:00
|
|
|
fillColor: const Color(0xff212226),
|
2022-05-13 06:02:53 +02:00
|
|
|
hintText: "Search items...",
|
2022-05-16 02:42:29 +02:00
|
|
|
hintStyle: const TextStyle(color: Colors.white),
|
2022-05-13 06:02:53 +02:00
|
|
|
border: outlineInputBorder,
|
|
|
|
enabledBorder: outlineInputBorder,
|
|
|
|
focusedBorder: outlineInputBorder,
|
|
|
|
errorBorder: outlineInputBorder,
|
|
|
|
prefixIcon: Padding(
|
|
|
|
padding: const EdgeInsets.all(14),
|
2022-05-15 11:34:17 +02:00
|
|
|
child: SvgPicture.asset("assets/icons/Search.svg",
|
|
|
|
color: Colors.white),
|
2022-05-13 06:02:53 +02:00
|
|
|
),
|
|
|
|
suffixIcon: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: defaultPadding, vertical: defaultPadding / 2),
|
|
|
|
child: SizedBox(
|
2022-05-15 16:08:26 +02:00
|
|
|
width: 100,
|
2022-05-13 06:02:53 +02:00
|
|
|
height: 48,
|
|
|
|
child: ElevatedButton(
|
|
|
|
style: ElevatedButton.styleFrom(
|
2022-05-15 20:54:40 +02:00
|
|
|
primary: const Color(0xff8B0000),
|
2022-05-13 06:02:53 +02:00
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(12)),
|
|
|
|
),
|
|
|
|
),
|
2022-05-16 08:39:02 +02:00
|
|
|
onPressed: () {
|
2022-05-17 10:31:25 +02:00
|
|
|
var searchQuery = searchController.text;
|
2022-05-16 11:01:20 +02:00
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) =>
|
2022-05-17 10:31:25 +02:00
|
|
|
SearchPage(query: searchQuery)));
|
2022-05-16 16:03:50 +02:00
|
|
|
searchController.clear();
|
2022-05-21 18:26:10 +02:00
|
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
2022-05-16 08:39:02 +02:00
|
|
|
},
|
2022-05-15 16:08:26 +02:00
|
|
|
child: const Text('Search'),
|
2022-05-13 06:02:53 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|