feat: added search
This commit is contained in:
parent
b54b825dad
commit
166ee5b389
7 changed files with 193 additions and 60 deletions
|
|
@ -1,46 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
import 'package:seshat/ui/sell_page/view_model/sell_view_model.dart';
|
||||
|
||||
class ManualScanPopup extends StatelessWidget {
|
||||
const ManualScanPopup({
|
||||
super.key,
|
||||
required this.viewModel,
|
||||
required this.controller,
|
||||
});
|
||||
|
||||
final SellViewModel viewModel;
|
||||
final MobileScannerController controller;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text("Recherche manuelle"),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
labelText: "Rechercher",
|
||||
suffixIcon: IconButton(
|
||||
onPressed: () {},
|
||||
icon: Icon(Icons.arrow_forward),
|
||||
),
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 200),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
controller.start();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text("Annuler"),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
75
lib/ui/sell_page/widgets/manual_search_popup.dart
Normal file
75
lib/ui/sell_page/widgets/manual_search_popup.dart
Normal 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"),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
import 'package:seshat/ui/sell_page/view_model/sell_view_model.dart';
|
||||
import 'package:seshat/ui/sell_page/widgets/manual_scan_popup.dart';
|
||||
import 'package:seshat/ui/sell_page/widgets/manual_search_popup.dart';
|
||||
import 'package:seshat/ui/sell_page/widgets/sell_choice_popup.dart';
|
||||
|
||||
class ScanScreen extends StatefulWidget {
|
||||
|
|
@ -78,10 +78,8 @@ class _ScanScreenState extends State<ScanScreen> {
|
|||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => ManualScanPopup(
|
||||
viewModel: widget.viewModel,
|
||||
controller: controller,
|
||||
),
|
||||
builder: (context) =>
|
||||
ManualSearchPopup(viewModel: widget.viewModel),
|
||||
);
|
||||
},
|
||||
child: Text("Vendre un livre sans scanner"),
|
||||
|
|
|
|||
Reference in a new issue