fix: formatting
This commit is contained in:
@@ -10,10 +10,7 @@ class BarScreenViewModel extends ChangeNotifier {
|
||||
final BarTabService barTabService;
|
||||
final InventoryViewModel inventory;
|
||||
|
||||
BarScreenViewModel({
|
||||
required this.barTabService,
|
||||
required this.inventory,
|
||||
});
|
||||
BarScreenViewModel({required this.barTabService, required this.inventory});
|
||||
|
||||
List<BarTab> _tabs = [];
|
||||
String? _selectedTabId;
|
||||
@@ -91,10 +88,7 @@ class BarScreenViewModel extends ChangeNotifier {
|
||||
throw Exception('Product is out of stock.');
|
||||
}
|
||||
|
||||
await barTabService.addProductToTab(
|
||||
tabId: tab.id,
|
||||
product: product,
|
||||
);
|
||||
await barTabService.addProductToTab(tabId: tab.id, product: product);
|
||||
|
||||
await inventory.decreaseStock(product.id, 1);
|
||||
|
||||
|
||||
@@ -6,9 +6,7 @@ import '../services/bar_tab_service.dart';
|
||||
class HistoryViewModel extends ChangeNotifier {
|
||||
final BarTabService barTabService;
|
||||
|
||||
HistoryViewModel({
|
||||
required this.barTabService,
|
||||
});
|
||||
HistoryViewModel({required this.barTabService});
|
||||
|
||||
List<ClosedTab> _closedTabs = [];
|
||||
bool _isLoading = false;
|
||||
@@ -20,8 +18,11 @@ class HistoryViewModel extends ChangeNotifier {
|
||||
if (_searchQuery.isEmpty) return _closedTabs;
|
||||
|
||||
return _closedTabs
|
||||
.where((tab) =>
|
||||
tab.customerName.toLowerCase().contains(_searchQuery.toLowerCase()))
|
||||
.where(
|
||||
(tab) => tab.customerName.toLowerCase().contains(
|
||||
_searchQuery.toLowerCase(),
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -59,4 +60,4 @@ class HistoryViewModel extends ChangeNotifier {
|
||||
_searchQuery = query;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,7 @@ import '../services/product_service.dart';
|
||||
class InventoryViewModel extends ChangeNotifier {
|
||||
final ProductService productService;
|
||||
|
||||
InventoryViewModel({
|
||||
required this.productService,
|
||||
});
|
||||
InventoryViewModel({required this.productService});
|
||||
|
||||
List<Product> _products = [];
|
||||
|
||||
@@ -19,43 +17,31 @@ class InventoryViewModel extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> decreaseStock(
|
||||
String productId,
|
||||
int amount,
|
||||
) async {
|
||||
Future<void> decreaseStock(String productId, int amount) async {
|
||||
await productService.decreaseStock(productId, amount);
|
||||
|
||||
final index = _products.indexWhere(
|
||||
(product) => product.id == productId,
|
||||
);
|
||||
final index = _products.indexWhere((product) => product.id == productId);
|
||||
|
||||
if (index != -1) {
|
||||
_products[index] = _products[index].copyWith(
|
||||
stockQuantity:
|
||||
_products[index].stockQuantity - amount,
|
||||
stockQuantity: _products[index].stockQuantity - amount,
|
||||
);
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> increaseStock(
|
||||
String productId,
|
||||
int amount,
|
||||
) async {
|
||||
Future<void> increaseStock(String productId, int amount) async {
|
||||
await productService.increaseStock(productId, amount);
|
||||
|
||||
final index = _products.indexWhere(
|
||||
(product) => product.id == productId,
|
||||
);
|
||||
final index = _products.indexWhere((product) => product.id == productId);
|
||||
|
||||
if (index != -1) {
|
||||
_products[index] = _products[index].copyWith(
|
||||
stockQuantity:
|
||||
_products[index].stockQuantity + amount,
|
||||
stockQuantity: _products[index].stockQuantity + amount,
|
||||
);
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,4 +131,4 @@ class PinLockViewModel extends ChangeNotifier {
|
||||
_isUnlocked = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,7 @@ class ProductListViewModel extends ChangeNotifier {
|
||||
final ProductService productService;
|
||||
final InventoryViewModel inventory;
|
||||
|
||||
ProductListViewModel({
|
||||
required this.productService,
|
||||
required this.inventory,
|
||||
});
|
||||
ProductListViewModel({required this.productService, required this.inventory});
|
||||
|
||||
static const List<String> _defaultCategories = [
|
||||
'Bier',
|
||||
@@ -120,4 +117,4 @@ class ProductListViewModel extends ChangeNotifier {
|
||||
|
||||
return categories;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,11 @@ class SettingsViewModel extends ChangeNotifier {
|
||||
bool get checkingForUpdates => _checkingForUpdates;
|
||||
|
||||
AppSettings get settings => _settings;
|
||||
|
||||
bool get isLoading => _isLoading;
|
||||
|
||||
bool get hasLoaded => _hasLoaded;
|
||||
|
||||
String? get errorMessage => _errorMessage;
|
||||
|
||||
Future<void> ensureLoaded() async {
|
||||
@@ -66,10 +69,9 @@ class SettingsViewModel extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> installUpdate(
|
||||
UpdateInfo update, {
|
||||
void Function(double progress)? onProgress,
|
||||
}) async {
|
||||
|
||||
UpdateInfo update, {
|
||||
void Function(double progress)? onProgress,
|
||||
}) async {
|
||||
final url = update.download.startsWith("http")
|
||||
? update.download
|
||||
: "https://updater.brammie15.dev${update.download}";
|
||||
@@ -83,28 +85,20 @@ class SettingsViewModel extends ChangeNotifier {
|
||||
);
|
||||
|
||||
await for (final event in stream) {
|
||||
|
||||
debugPrint(
|
||||
"OTA: ${event.status} ${event.value}",
|
||||
);
|
||||
debugPrint("OTA: ${event.status} ${event.value}");
|
||||
|
||||
if (event.status == OtaStatus.DOWNLOADING) {
|
||||
final progress =
|
||||
double.tryParse(event.value ?? "0") ?? 0;
|
||||
final progress = double.tryParse(event.value ?? "0") ?? 0;
|
||||
|
||||
onProgress?.call(progress / 100);
|
||||
}
|
||||
|
||||
if (event.status == OtaStatus.DOWNLOAD_ERROR) {
|
||||
throw Exception(
|
||||
"Download failed: ${event.value}",
|
||||
);
|
||||
throw Exception("Download failed: ${event.value}");
|
||||
}
|
||||
|
||||
if (event.status == OtaStatus.INSTALLATION_ERROR) {
|
||||
throw Exception(
|
||||
"Installation failed: ${event.value}",
|
||||
);
|
||||
throw Exception("Installation failed: ${event.value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,4 +125,4 @@ class SettingsViewModel extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user