search field redirect to aur page
This commit is contained in:
parent
c924a151cb
commit
0bb180f464
@ -1,5 +1,6 @@
|
|||||||
import 'package:aurcache/components/dashboard/search_field.dart';
|
import 'package:aurcache/components/dashboard/search_field.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
import '../../constants/color_constants.dart';
|
import '../../constants/color_constants.dart';
|
||||||
import '../../utils/responsive.dart';
|
import '../../utils/responsive.dart';
|
||||||
|
|
||||||
@ -46,7 +47,9 @@ class Header extends StatelessWidget {
|
|||||||
vertical: defaultPadding / (Responsive.isMobile(context) ? 2 : 1),
|
vertical: defaultPadding / (Responsive.isMobile(context) ? 2 : 1),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
|
context.push("/aur");
|
||||||
|
},
|
||||||
icon: const Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
label: const Text(
|
label: const Text(
|
||||||
"Add New",
|
"Add New",
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
import 'package:aurcache/api/packages.dart';
|
|
||||||
import 'package:aurcache/providers/builds_provider.dart';
|
|
||||||
import 'package:aurcache/providers/stats_provider.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
import '../../api/API.dart';
|
|
||||||
import '../../constants/color_constants.dart';
|
import '../../constants/color_constants.dart';
|
||||||
import '../../providers/packages_provider.dart';
|
|
||||||
|
|
||||||
class SearchField extends StatelessWidget {
|
class SearchField extends StatelessWidget {
|
||||||
SearchField({
|
SearchField({
|
||||||
@ -30,17 +24,11 @@ class SearchField extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
suffixIcon: InkWell(
|
suffixIcon: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
// todo this is only temporary -> add this to a proper page
|
context.push("/aur?query=${controller.text}");
|
||||||
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);
|
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.all(defaultPadding * 0.75),
|
padding: const EdgeInsets.all(defaultPadding * 0.75),
|
||||||
margin: EdgeInsets.symmetric(horizontal: defaultPadding / 2),
|
margin: const EdgeInsets.symmetric(horizontal: defaultPadding / 2),
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
color: darkgreenColor,
|
color: darkgreenColor,
|
||||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||||
|
@ -43,7 +43,9 @@ final appRouter = GoRouter(
|
|||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/aur',
|
path: '/aur',
|
||||||
builder: (context, state) => AurScreen(),
|
builder: (context, state) {
|
||||||
|
return AurScreen(initalQuery: state.uri.queryParameters["query"]);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/package/:id',
|
path: '/package/:id',
|
||||||
|
@ -11,7 +11,9 @@ import '../constants/color_constants.dart';
|
|||||||
import '../providers/packages_provider.dart';
|
import '../providers/packages_provider.dart';
|
||||||
|
|
||||||
class AurScreen extends StatefulWidget {
|
class AurScreen extends StatefulWidget {
|
||||||
const AurScreen({super.key});
|
const AurScreen({super.key, this.initalQuery});
|
||||||
|
|
||||||
|
final String? initalQuery;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AurScreen> createState() => _AurScreenState();
|
State<AurScreen> createState() => _AurScreenState();
|
||||||
@ -22,6 +24,15 @@ class _AurScreenState extends State<AurScreen> {
|
|||||||
String query = "";
|
String query = "";
|
||||||
Timer? timer;
|
Timer? timer;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
if (widget.initalQuery != null) {
|
||||||
|
query = widget.initalQuery!;
|
||||||
|
controller.text = widget.initalQuery!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
Loading…
Reference in New Issue
Block a user