first commit
This commit is contained in:
commit
faf67cc6d8
148 changed files with 6580 additions and 0 deletions
120
lib/ui/add_page/widgets/add_page.dart
Normal file
120
lib/ui/add_page/widgets/add_page.dart
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.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/widgets/owner_popup.dart';
|
||||
import 'package:seshat/ui/core/ui/navigation_bar.dart';
|
||||
|
||||
class AddPage extends StatefulWidget {
|
||||
const AddPage({super.key, required this.viewModel});
|
||||
|
||||
final AddViewModel viewModel;
|
||||
|
||||
@override
|
||||
State<AddPage> createState() => _AddPageState();
|
||||
}
|
||||
|
||||
class _AddPageState extends State<AddPage> {
|
||||
bool askPrice = true;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final MobileScannerController controller = MobileScannerController(
|
||||
formats: [BarcodeFormat.ean13],
|
||||
detectionTimeoutMs: 1000,
|
||||
);
|
||||
// return Consumer<TabScreen>(
|
||||
// builder: (context, screen, child) {
|
||||
return Scaffold(
|
||||
bottomNavigationBar: AppNavigationBar(startIndex: 1),
|
||||
body: Stack(
|
||||
children: [
|
||||
ColoredBox(color: Colors.black),
|
||||
MobileScanner(
|
||||
controller: controller,
|
||||
onDetect: (barcodes) {
|
||||
onBarcodeScan(barcodes, controller);
|
||||
},
|
||||
),
|
||||
SafeArea(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: Card(
|
||||
margin: EdgeInsets.symmetric(horizontal: 50),
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: Icon(Icons.person),
|
||||
title: TextButton(
|
||||
child: Text("No"),
|
||||
onPressed: () => _ownerDialogBuilder(
|
||||
context,
|
||||
controller,
|
||||
widget.viewModel,
|
||||
),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.attach_money),
|
||||
title: TextButton(
|
||||
child: Text(
|
||||
(askPrice)
|
||||
? "Demander à chaque fois"
|
||||
: "Prix libre toujours",
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
askPrice = !askPrice;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(child: SizedBox()),
|
||||
SvgPicture.asset('assets/scan-overlay.svg'),
|
||||
Expanded(child: SizedBox()),
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: Text("Enregistrer manuellement"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
// },
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
void onBarcodeScan(
|
||||
BarcodeCapture barcodes,
|
||||
MobileScannerController controller,
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
Future<void> _ownerDialogBuilder(
|
||||
BuildContext context,
|
||||
MobileScannerController controller,
|
||||
AddViewModel viewModel,
|
||||
) {
|
||||
controller.stop();
|
||||
|
||||
void onPressAccept(BuildContext localContext) {
|
||||
controller.start();
|
||||
Navigator.of(localContext).pop();
|
||||
}
|
||||
|
||||
return showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) =>
|
||||
OwnerPopup(viewModel: viewModel, onPressAccept: onPressAccept),
|
||||
);
|
||||
}
|
||||
Reference in a new issue