feat: add an owner + sell screen
This commit is contained in:
parent
d2cbb43bcb
commit
073f8bd334
15 changed files with 354 additions and 82 deletions
39
lib/ui/sell_page/view_model/sell_view_model.dart
Normal file
39
lib/ui/sell_page/view_model/sell_view_model.dart
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
import 'package:seshat/domain/models/book_instance.dart';
|
||||
|
||||
class SellViewModel extends ChangeNotifier {
|
||||
SellViewModel();
|
||||
|
||||
bool _showScan = false;
|
||||
bool get showScan => _showScan;
|
||||
set showScan(bool newValue) {
|
||||
_showScan = newValue;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
final List<BookInstance> _scannedBooks = [];
|
||||
get scannedBooks => _scannedBooks;
|
||||
void scanBook(BarcodeCapture barcode) {
|
||||
final addedBook = BookInstance(
|
||||
balId: 5,
|
||||
bookId: 5,
|
||||
id: _scannedBooks.length,
|
||||
ownerId: 5,
|
||||
price: 5,
|
||||
status: true,
|
||||
);
|
||||
_scannedBooks.add(addedBook);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void sendSell() {
|
||||
_scannedBooks.clear();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void deleteBook(int id) {
|
||||
_scannedBooks.removeWhere((book) => book.id == id);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
Reference in a new issue