Compare commits
No commits in common. "19c4243273157d29831d839109f6505401562cd6" and "faf67cc6d8008b5e71c453e075a055a22703c4dc" have entirely different histories.
19c4243273
...
faf67cc6d8
6 changed files with 101 additions and 298 deletions
15
README.md
15
README.md
|
|
@ -1,3 +1,16 @@
|
||||||
# seshat
|
# seshat
|
||||||
|
|
||||||
Client android/iOS/web, écrit en dart x flutter, pour Alexandria.
|
A new Flutter project.
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
This project is a starting point for a Flutter application.
|
||||||
|
|
||||||
|
A few resources to get you started if this is your first Flutter project:
|
||||||
|
|
||||||
|
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
|
||||||
|
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
|
||||||
|
|
||||||
|
For help getting started with Flutter development, view the
|
||||||
|
[online documentation](https://docs.flutter.dev/), which offers tutorials,
|
||||||
|
samples, guidance on mobile development, and a full API reference.
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||||
import 'package:seshat/ui/add_page/view_model/add_view_model.dart';
|
import 'package:seshat/ui/add_page/view_model/add_view_model.dart';
|
||||||
import 'package:seshat/ui/add_page/widgets/form_popup.dart';
|
|
||||||
import 'package:seshat/ui/add_page/widgets/owner_popup.dart';
|
import 'package:seshat/ui/add_page/widgets/owner_popup.dart';
|
||||||
import 'package:seshat/ui/core/ui/navigation_bar.dart';
|
import 'package:seshat/ui/core/ui/navigation_bar.dart';
|
||||||
|
|
||||||
|
|
@ -23,8 +22,6 @@ class _AddPageState extends State<AddPage> {
|
||||||
formats: [BarcodeFormat.ean13],
|
formats: [BarcodeFormat.ean13],
|
||||||
detectionTimeoutMs: 1000,
|
detectionTimeoutMs: 1000,
|
||||||
);
|
);
|
||||||
|
|
||||||
final theme = Theme.of(context);
|
|
||||||
// return Consumer<TabScreen>(
|
// return Consumer<TabScreen>(
|
||||||
// builder: (context, screen, child) {
|
// builder: (context, screen, child) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
|
@ -47,21 +44,14 @@ class _AddPageState extends State<AddPage> {
|
||||||
margin: EdgeInsets.symmetric(horizontal: 50),
|
margin: EdgeInsets.symmetric(horizontal: 50),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
ListenableBuilder(
|
ListTile(
|
||||||
listenable: widget.viewModel,
|
leading: Icon(Icons.person),
|
||||||
builder: (context, child) => ListTile(
|
title: TextButton(
|
||||||
leading: Icon(Icons.person),
|
child: Text("No"),
|
||||||
title: TextButton(
|
onPressed: () => _ownerDialogBuilder(
|
||||||
child: Text(
|
context,
|
||||||
(widget.viewModel.currentOwner == null)
|
controller,
|
||||||
? "Aucun"
|
widget.viewModel,
|
||||||
: "${widget.viewModel.currentOwner!.firstName} ${widget.viewModel.currentOwner!.lastName}",
|
|
||||||
),
|
|
||||||
onPressed: () => _ownerDialogBuilder(
|
|
||||||
context,
|
|
||||||
controller,
|
|
||||||
widget.viewModel,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -88,11 +78,7 @@ class _AddPageState extends State<AddPage> {
|
||||||
SvgPicture.asset('assets/scan-overlay.svg'),
|
SvgPicture.asset('assets/scan-overlay.svg'),
|
||||||
Expanded(child: SizedBox()),
|
Expanded(child: SizedBox()),
|
||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
onPressed: () {},
|
||||||
backgroundColor: WidgetStatePropertyAll(theme.cardColor),
|
|
||||||
),
|
|
||||||
onPressed: () =>
|
|
||||||
_formDialogBuilder(context, controller, widget.viewModel),
|
|
||||||
child: Text("Enregistrer manuellement"),
|
child: Text("Enregistrer manuellement"),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
@ -113,25 +99,6 @@ void onBarcodeScan(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _formDialogBuilder(
|
|
||||||
BuildContext context,
|
|
||||||
MobileScannerController controller,
|
|
||||||
AddViewModel viewModel,
|
|
||||||
) {
|
|
||||||
controller.stop();
|
|
||||||
|
|
||||||
void exitPopup(BuildContext localContext) {
|
|
||||||
Navigator.of(localContext).pop();
|
|
||||||
controller.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
return showDialog(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (context) => FormPopup(viewModel: viewModel, exitPopup: exitPopup),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _ownerDialogBuilder(
|
Future<void> _ownerDialogBuilder(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
MobileScannerController controller,
|
MobileScannerController controller,
|
||||||
|
|
@ -140,8 +107,8 @@ Future<void> _ownerDialogBuilder(
|
||||||
controller.stop();
|
controller.stop();
|
||||||
|
|
||||||
void onPressAccept(BuildContext localContext) {
|
void onPressAccept(BuildContext localContext) {
|
||||||
Navigator.of(localContext).pop();
|
|
||||||
controller.start();
|
controller.start();
|
||||||
|
Navigator.of(localContext).pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
return showDialog(
|
return showDialog(
|
||||||
|
|
|
||||||
|
|
@ -1,252 +0,0 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:seshat/ui/add_page/view_model/add_view_model.dart';
|
|
||||||
|
|
||||||
class FormPopup extends StatelessWidget {
|
|
||||||
const FormPopup({
|
|
||||||
super.key,
|
|
||||||
required this.viewModel,
|
|
||||||
required this.exitPopup,
|
|
||||||
});
|
|
||||||
|
|
||||||
final AddViewModel viewModel;
|
|
||||||
final Function(BuildContext) exitPopup;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Center(child: Text("Type d'entrée")),
|
|
||||||
content: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Card(
|
|
||||||
clipBehavior: Clip.hardEdge,
|
|
||||||
child: InkWell(
|
|
||||||
splashColor: Colors.blue.withAlpha(30),
|
|
||||||
onTap: () {
|
|
||||||
debugPrint('Card tapped.');
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (context) {
|
|
||||||
return _ManualEANPopup(exitPopup: exitPopup);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const SizedBox(
|
|
||||||
width: 300,
|
|
||||||
height: 100,
|
|
||||||
child: Center(
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Icon(Icons.onetwothree),
|
|
||||||
SizedBox(width: 10),
|
|
||||||
Text('Entrer manuellement un EAN'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Card(
|
|
||||||
clipBehavior: Clip.hardEdge,
|
|
||||||
child: InkWell(
|
|
||||||
splashColor: Colors.blue.withAlpha(30),
|
|
||||||
onTap: () {
|
|
||||||
debugPrint('Card tapped.');
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (context) {
|
|
||||||
return _FullyManual(exitPopup: exitPopup);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const SizedBox(
|
|
||||||
width: 300,
|
|
||||||
height: 100,
|
|
||||||
child: Center(
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Icon(Icons.history_edu),
|
|
||||||
SizedBox(width: 10),
|
|
||||||
Text('Entrer manuellement un livre'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(onPressed: () => exitPopup(context), child: Text("Annuler")),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ManualEANPopup extends StatefulWidget {
|
|
||||||
const _ManualEANPopup({required this.exitPopup});
|
|
||||||
|
|
||||||
final Function(BuildContext) exitPopup;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<_ManualEANPopup> createState() => _ManualEANPopupState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ManualEANPopupState extends State<_ManualEANPopup> {
|
|
||||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
||||||
String? ean;
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text("Recherche par EAN"),
|
|
||||||
content: Form(
|
|
||||||
key: _formKey,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
TextFormField(
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: "EAN",
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
),
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
onSaved: (newValue) {
|
|
||||||
ean = newValue;
|
|
||||||
},
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null ||
|
|
||||||
value.length != 13 ||
|
|
||||||
int.tryParse(value) == null) {
|
|
||||||
return "L'entrée n'est pas un code EAN-13 valide";
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
widget.exitPopup(context);
|
|
||||||
},
|
|
||||||
child: Text("Annuler"),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
if (_formKey.currentState!.validate()) {
|
|
||||||
_formKey.currentState!.save();
|
|
||||||
widget.exitPopup(context);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text("Valider"),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FullyManual extends StatefulWidget {
|
|
||||||
const _FullyManual({required this.exitPopup});
|
|
||||||
|
|
||||||
final Function(BuildContext) exitPopup;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<_FullyManual> createState() => _FullyManualState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FullyManualState extends State<_FullyManual> {
|
|
||||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
||||||
String? ean = "";
|
|
||||||
String? title;
|
|
||||||
String? author;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text("Entrée manuelle"),
|
|
||||||
content: Form(
|
|
||||||
key: _formKey,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
TextFormField(
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: "EAN",
|
|
||||||
helperText: "Optionnel",
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
),
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null ||
|
|
||||||
(value.length != 13 && value.isNotEmpty) ||
|
|
||||||
int.tryParse(value) != null) {
|
|
||||||
return "Indiquez un EAN valide ou rien";
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
onSaved: (newValue) {
|
|
||||||
ean = newValue;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(height: 10),
|
|
||||||
TextFormField(
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: "Titre",
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
),
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null || value.isEmpty) {
|
|
||||||
return "Indiquez un titre";
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
onSaved: (newValue) {
|
|
||||||
title = newValue;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(height: 10),
|
|
||||||
TextFormField(
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: "Auteur·ice",
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
),
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null || value.isEmpty) {
|
|
||||||
return "Indiquez un·e auteur·ice";
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
onSaved: (newValue) {
|
|
||||||
author = newValue;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
widget.exitPopup(context);
|
|
||||||
},
|
|
||||||
child: Text("Annuler"),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
if (_formKey.currentState!.validate()) {
|
|
||||||
_formKey.currentState!.save();
|
|
||||||
widget.exitPopup(context);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text("Valider"),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
0
lib/ui/add_page/widgets/form_screen.dart
Normal file
0
lib/ui/add_page/widgets/form_screen.dart
Normal file
|
|
@ -143,9 +143,9 @@ class _OwnerPopupState extends State<OwnerPopup> {
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_formKey.currentState!.validate()) {
|
if (_formKey.currentState!.validate()) {
|
||||||
_formKey.currentState!.save();
|
_formKey.currentState!.save();
|
||||||
widget.viewModel.currentOwner = widget.viewModel
|
|
||||||
.addOwner(firstName!, lastName!, contact!);
|
|
||||||
setState(() {
|
setState(() {
|
||||||
|
widget.viewModel.currentOwner = widget.viewModel
|
||||||
|
.addOwner(firstName!, lastName!, contact!);
|
||||||
showNewOwner = false;
|
showNewOwner = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
75
lib/ui/add_page/widgets/scan_screen.dart
Normal file
75
lib/ui/add_page/widgets/scan_screen.dart
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
// class ScanPage extends StatefulWidget {
|
||||||
|
// const ScanPage({super.key});
|
||||||
|
|
||||||
|
// @override
|
||||||
|
// State<ScanPage> createState() => _ScanPage();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class _ScanPage extends State<ScanPage> {
|
||||||
|
// final MobileScannerController controller = MobileScannerController(
|
||||||
|
// detectionTimeoutMs: 1000,
|
||||||
|
// );
|
||||||
|
// @override
|
||||||
|
// Widget build(BuildContext context) {
|
||||||
|
// return Stack(
|
||||||
|
// children: <Widget>[
|
||||||
|
// MobileScanner(
|
||||||
|
// controller: controller,
|
||||||
|
// onDetect: (result) {
|
||||||
|
// print(result.barcodes.first.rawValue);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// SafeArea(
|
||||||
|
// child: Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
// children: [
|
||||||
|
// Center(
|
||||||
|
// child: Card(
|
||||||
|
// margin: EdgeInsets.symmetric(horizontal: 50),
|
||||||
|
// child: Column(
|
||||||
|
// children: [
|
||||||
|
// Consumer<TabScreen>(
|
||||||
|
// builder: (context, screen, child) {
|
||||||
|
// return ListTile(
|
||||||
|
// leading: Icon(Icons.person),
|
||||||
|
// title: TextButton(
|
||||||
|
// child: Text("No"),
|
||||||
|
// onPressed: () {
|
||||||
|
// screen.change("ownerPage");
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ListTile(
|
||||||
|
// leading: Icon(Icons.attach_money),
|
||||||
|
// title: TextButton(
|
||||||
|
// child: Text("Demander à chaque fois"),
|
||||||
|
// onPressed: () {
|
||||||
|
// return;
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// Expanded(child: SizedBox()),
|
||||||
|
// SvgPicture.asset('assets/scan-overlay.svg'),
|
||||||
|
// Expanded(child: SizedBox()),
|
||||||
|
// TextButton(
|
||||||
|
// onPressed: () {},
|
||||||
|
// child: Text("Enregistrer manuellement"),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
Reference in a new issue