feat: scan book to add to sell
This commit is contained in:
parent
3a013c829f
commit
07c7c98edb
11 changed files with 238 additions and 31 deletions
64
lib/ui/sell_page/widgets/sell_choice_popup.dart
Normal file
64
lib/ui/sell_page/widgets/sell_choice_popup.dart
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:seshat/domain/models/book_stack.dart';
|
||||
import 'package:seshat/ui/sell_page/view_model/sell_view_model.dart';
|
||||
|
||||
class SellChoicePopup extends StatelessWidget {
|
||||
const SellChoicePopup({super.key, required this.viewModel});
|
||||
|
||||
final SellViewModel viewModel;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListenableBuilder(
|
||||
listenable: viewModel,
|
||||
builder: (context, child) {
|
||||
return AlertDialog(
|
||||
title: Text("Choix du bon livre"),
|
||||
content: switch (viewModel.isScanLoaded) {
|
||||
false => SizedBox(
|
||||
height: 300,
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
true => SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
(viewModel.scannedBooks.isEmpty)
|
||||
? Text(
|
||||
"Ce livre n'a jamais été rentré, ou vous l'avez déjà mis dans cette vente.",
|
||||
)
|
||||
: SizedBox(),
|
||||
for (BookStack book in viewModel.scannedBooks)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||
child: Card(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
viewModel.sellBook(book);
|
||||
Navigator.of(context).pop();
|
||||
viewModel.showScan = false;
|
||||
},
|
||||
child: ListTile(
|
||||
leading: Text(
|
||||
"${book.instance.price.toString()}€",
|
||||
style: TextStyle(fontSize: 30),
|
||||
),
|
||||
title: Text(
|
||||
"${book.book.title} · ${book.book.author}",
|
||||
),
|
||||
subtitle: Text(
|
||||
"${book.owner.firstName} ${book.owner.lastName} (${book.shortId()})",
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in a new issue