app/lib/components/search_form.dart
2022-05-16 13:39:02 +07:00

67 lines
2.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:nekoya_flutter/components/search_page.dart';
import 'package:nekoya_flutter/utils/utils.dart';
const OutlineInputBorder outlineInputBorder = OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
borderSide: BorderSide.none,
);
class SearchForm extends StatefulWidget {
const SearchForm({Key? key}) : super(key: key);
@override
State<SearchForm> createState() => _SearchFormState();
}
class _SearchFormState extends State<SearchForm> {
TextEditingController searchController = TextEditingController();
@override
Widget build(BuildContext context) {
return Form(
child: TextFormField(
controller: searchController,
decoration: InputDecoration(
filled: true,
fillColor: const Color(0xff212226),
hintText: "Search items...",
hintStyle: const TextStyle(color: Colors.white),
border: outlineInputBorder,
enabledBorder: outlineInputBorder,
focusedBorder: outlineInputBorder,
errorBorder: outlineInputBorder,
prefixIcon: Padding(
padding: const EdgeInsets.all(14),
child: SvgPicture.asset("assets/icons/Search.svg",
color: Colors.white),
),
suffixIcon: Padding(
padding: const EdgeInsets.symmetric(
horizontal: defaultPadding, vertical: defaultPadding / 2),
child: SizedBox(
width: 100,
height: 48,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: const Color(0xff8B0000),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
),
onPressed: () {
Navigator.push(context, MaterialPageRoute(
builder: (context) => SearchPage(query: searchController.text)
));
},
child: const Text('Search'),
),
),
),
),
),
);
}
}