2023-12-29 23:45:33 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-02-19 19:53:11 +00:00
|
|
|
import 'package:flutter/services.dart';
|
2023-12-29 23:45:33 +00:00
|
|
|
import 'package:flutter_svg/svg.dart';
|
2024-01-29 21:42:11 +00:00
|
|
|
import 'package:go_router/go_router.dart';
|
2023-12-29 23:45:33 +00:00
|
|
|
import '../../constants/color_constants.dart';
|
|
|
|
|
|
|
|
class SearchField extends StatelessWidget {
|
|
|
|
SearchField({
|
|
|
|
Key? key,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final controller = TextEditingController();
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-02-19 19:53:11 +00:00
|
|
|
return RawKeyboardListener(
|
|
|
|
focusNode: FocusNode(),
|
|
|
|
onKey: (event) {
|
|
|
|
if (event.runtimeType == RawKeyDownEvent &&
|
|
|
|
event.logicalKey == LogicalKeyboardKey.enter) {
|
|
|
|
context.push("/aur?query=${controller.text}");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: TextField(
|
|
|
|
controller: controller,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
hintText: "Search",
|
|
|
|
fillColor: secondaryColor,
|
|
|
|
filled: true,
|
|
|
|
border: const OutlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
|
|
|
),
|
|
|
|
suffixIcon: InkWell(
|
|
|
|
onTap: () async {
|
|
|
|
context.push("/aur?query=${controller.text}");
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: const EdgeInsets.all(defaultPadding * 0.75),
|
|
|
|
margin:
|
|
|
|
const EdgeInsets.symmetric(horizontal: defaultPadding / 2),
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
color: darkgreenColor,
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
|
|
|
),
|
|
|
|
child: SvgPicture.asset(
|
|
|
|
"assets/icons/Search.svg",
|
|
|
|
),
|
2023-12-29 23:45:33 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|