2023-12-29 23:45:33 +00:00
|
|
|
import 'package:aurcache/api/packages.dart';
|
2023-12-30 21:23:42 +00:00
|
|
|
import 'package:aurcache/providers/builds_provider.dart';
|
|
|
|
import 'package:aurcache/providers/stats_provider.dart';
|
2023-12-29 23:45:33 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
2023-12-30 21:23:42 +00:00
|
|
|
import 'package:provider/provider.dart';
|
2023-12-29 23:45:33 +00:00
|
|
|
|
|
|
|
import '../../api/API.dart';
|
|
|
|
import '../../constants/color_constants.dart';
|
2023-12-30 21:23:42 +00:00
|
|
|
import '../../providers/packages_provider.dart';
|
2023-12-29 23:45:33 +00:00
|
|
|
|
|
|
|
class SearchField extends StatelessWidget {
|
|
|
|
SearchField({
|
|
|
|
Key? key,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final controller = TextEditingController();
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return 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(
|
2023-12-30 21:23:42 +00:00
|
|
|
onTap: () async {
|
2023-12-29 23:45:33 +00:00
|
|
|
// todo this is only temporary -> add this to a proper page
|
2023-12-30 21:23:42 +00:00
|
|
|
await API.addPackage(name: controller.text, force: true);
|
|
|
|
Provider.of<PackagesProvider>(context, listen: false)
|
|
|
|
.refresh(context);
|
|
|
|
Provider.of<BuildsProvider>(context, listen: false)
|
|
|
|
.refresh(context);
|
|
|
|
Provider.of<StatsProvider>(context, listen: false).refresh(context);
|
2023-12-29 23:45:33 +00:00
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.all(defaultPadding * 0.75),
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: defaultPadding / 2),
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
color: darkgreenColor,
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
|
|
|
),
|
|
|
|
child: SvgPicture.asset(
|
|
|
|
"assets/icons/Search.svg",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|