This repository has been archived on 2025-08-25. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Seshat/lib/ui/sell_page/widgets/sell_choice_popup.dart
2025-08-15 12:51:36 +02:00

64 lines
2.3 KiB
Dart

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()})",
),
),
),
),
),
],
),
),
},
);
},
);
}
}