This repository has been archived on 2025-08-25. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Seshat/lib/ui/sell_page/widgets/manual_search_popup.dart
2025-08-15 23:23:43 +02:00

75 lines
2 KiB
Dart

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"),
),
],
);
}
}