64 lines
		
	
	
	
		
			2.3 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			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é, il a déjà été vendu 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: 15),
 | |
|                             ),
 | |
|                             title: Text(
 | |
|                               "${book.book.title} · ${book.book.author}",
 | |
|                             ),
 | |
|                             subtitle: Text(
 | |
|                               "${book.owner.firstName} ${book.owner.lastName} (${book.shortId()})",
 | |
|                             ),
 | |
|                           ),
 | |
|                         ),
 | |
|                       ),
 | |
|                     ),
 | |
|                 ],
 | |
|               ),
 | |
|             ),
 | |
|           },
 | |
|         );
 | |
|       },
 | |
|     );
 | |
|   }
 | |
| }
 | 
