feat: added search

This commit is contained in:
alzalia1 2025-08-15 23:23:43 +02:00
parent b54b825dad
commit 166ee5b389
7 changed files with 193 additions and 60 deletions

View file

@ -0,0 +1,75 @@
import 'package:flutter/material.dart';
import 'package:seshat/ui/sell_page/view_model/sell_view_model.dart';
import 'package:seshat/ui/sell_page/widgets/sell_choice_popup.dart';
class ManualSearchPopup extends StatefulWidget {
const ManualSearchPopup({super.key, required this.viewModel});
final SellViewModel viewModel;
@override
State<ManualSearchPopup> createState() => _ManualSearchPopupState();
}
class _ManualSearchPopupState extends State<ManualSearchPopup> {
String? title = "";
String? author = "";
@override
Widget build(BuildContext context) {
GlobalKey<FormState> _form = GlobalKey<FormState>();
return AlertDialog(
title: Text("Recherche manuelle"),
content: Form(
key: _form,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextFormField(
decoration: InputDecoration(
labelText: "Titre",
border: OutlineInputBorder(),
),
onSaved: (newValue) => setState(() {
title = newValue;
}),
),
SizedBox(height: 10),
TextFormField(
decoration: InputDecoration(
labelText: "Auteur",
border: OutlineInputBorder(),
),
onSaved: (newValue) => setState(() {
author = newValue;
}),
),
],
),
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text("Annuler"),
),
ElevatedButton(
onPressed: () {
_form.currentState!.save();
Navigator.of(context).pop();
showDialog(
context: context,
builder: (context) =>
SellChoicePopup(viewModel: widget.viewModel),
);
widget.viewModel.searchBook(title ?? "", author ?? "");
},
child: Text("Rechercher"),
),
],
);
}
}