fix theme / add history

This commit is contained in:
2026-07-12 02:49:08 +02:00
parent 6587779a58
commit ae3d2dd302
15 changed files with 3025 additions and 362 deletions
+62
View File
@@ -0,0 +1,62 @@
import 'package:flutter/foundation.dart';
import '../models/closed_tab.dart';
import '../services/bar_tab_service.dart';
class HistoryViewModel extends ChangeNotifier {
final BarTabService barTabService;
HistoryViewModel({
required this.barTabService,
});
List<ClosedTab> _closedTabs = [];
bool _isLoading = false;
bool _hasLoaded = false;
String? _errorMessage;
String _searchQuery = '';
List<ClosedTab> get closedTabs {
if (_searchQuery.isEmpty) return _closedTabs;
return _closedTabs
.where((tab) =>
tab.customerName.toLowerCase().contains(_searchQuery.toLowerCase()))
.toList();
}
bool get isLoading => _isLoading;
bool get hasLoaded => _hasLoaded;
String? get errorMessage => _errorMessage;
Future<void> ensureLoaded() async {
if (_hasLoaded || _isLoading) return;
await load();
}
Future<void> load() async {
if (_isLoading) return;
_isLoading = true;
_errorMessage = null;
notifyListeners();
try {
_closedTabs = await barTabService.getClosedTabs();
} catch (_) {
_errorMessage = 'Could not load tab history.';
} finally {
_hasLoaded = true;
_isLoading = false;
notifyListeners();
}
}
void search(String query) {
_searchQuery = query;
notifyListeners();
}
}