feat: add an owner + sell screen
This commit is contained in:
parent
d2cbb43bcb
commit
073f8bd334
15 changed files with 354 additions and 82 deletions
116
lib/ui/sell_page/widgets/sell_page.dart
Normal file
116
lib/ui/sell_page/widgets/sell_page.dart
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:seshat/domain/models/book_instance.dart';
|
||||
import 'package:seshat/ui/core/ui/navigation_bar.dart';
|
||||
import 'package:seshat/ui/sell_page/view_model/sell_view_model.dart';
|
||||
import 'package:seshat/ui/sell_page/widgets/scan_screen.dart';
|
||||
|
||||
class SellPage extends StatefulWidget {
|
||||
const SellPage({super.key, required this.viewModel});
|
||||
|
||||
final SellViewModel viewModel;
|
||||
|
||||
@override
|
||||
State<SellPage> createState() => _SellPageState();
|
||||
}
|
||||
|
||||
class _SellPageState extends State<SellPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
bottomNavigationBar: AppNavigationBar(startIndex: 2),
|
||||
body: ListenableBuilder(
|
||||
listenable: widget.viewModel,
|
||||
builder: (context, child) {
|
||||
return Stack(
|
||||
children: [
|
||||
SafeArea(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: 6),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
for (BookInstance bookInstance
|
||||
in widget.viewModel.scannedBooks)
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Text(
|
||||
"${bookInstance.price.toString()}€",
|
||||
style: TextStyle(fontSize: 30),
|
||||
),
|
||||
title: Text(
|
||||
"Les chiens et la charrue · Patrick K. Dewdney ${bookInstance.id}",
|
||||
),
|
||||
subtitle: Text("Union Étudiante Auvergne"),
|
||||
trailing: IconButton(
|
||||
onPressed: () {
|
||||
widget.viewModel.deleteBook(
|
||||
bookInstance.id,
|
||||
);
|
||||
},
|
||||
icon: Icon(Icons.delete),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
Text("Somme minimum requise : 20€"),
|
||||
SizedBox(
|
||||
width: 400,
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
labelText: "Argent reçu",
|
||||
helperText:
|
||||
"L'argent reçu sera réparti automatiquement",
|
||||
suffixText: "€",
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.viewModel.sendSell();
|
||||
},
|
||||
icon: Icon(Icons.check),
|
||||
style: ButtonStyle(
|
||||
iconSize: WidgetStatePropertyAll(70),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 70),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.viewModel.showScan = true;
|
||||
},
|
||||
icon: Icon(Icons.add),
|
||||
style: ButtonStyle(
|
||||
iconSize: WidgetStatePropertyAll(70),
|
||||
elevation: WidgetStatePropertyAll(50),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
(widget.viewModel.showScan)
|
||||
? ScanScreen(viewModel: widget.viewModel)
|
||||
: SizedBox(),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
// return Center(child: Text("Sell page."));
|
||||
}
|
||||
}
|
||||
Reference in a new issue