Refactor app to focus on match results instead of tasks
- Introduced MatchRepository and MatchResultsViewModel to handle match data. - Replaced task-related code with match-related functionality in the app. - Added match results view and updated navigation to reflect changes. - Removed task-related models, services, and view models. - Added JSON data for match results and integrated it into the app. - Updated tests to validate match results loading and UI behavior.
This commit is contained in:
1 parent
ffc2051e20
commit
4d377c1336
17 files changed
+500
-658
No files matched your search
@@ -1,82 +0,0 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../../../../data/repositories/task_repository.dart';
|
||||
import '../../../../domain/models/task_item.dart';
|
||||
|
||||
class DashboardViewModel extends ChangeNotifier {
|
||||
DashboardViewModel({required this._repository});
|
||||
|
||||
final TaskRepository _repository;
|
||||
|
||||
List<TaskItem> _tasks = [];
|
||||
bool _isLoading = false;
|
||||
String _selectedCategory = 'All';
|
||||
|
||||
List<TaskItem> get tasks {
|
||||
if (_selectedCategory == 'All') {
|
||||
return List.unmodifiable(_tasks);
|
||||
}
|
||||
return List.unmodifiable(
|
||||
_tasks.where((t) => t.category == _selectedCategory),
|
||||
);
|
||||
}
|
||||
|
||||
bool get isLoading => _isLoading;
|
||||
String get selectedCategory => _selectedCategory;
|
||||
|
||||
int get totalCount => _tasks.length;
|
||||
int get completedCount => _tasks.where((t) => t.isCompleted).length;
|
||||
double get completionProgress =>
|
||||
_tasks.isEmpty ? 0.0 : completedCount / totalCount;
|
||||
|
||||
List<String> get availableCategories => [
|
||||
'All',
|
||||
'Design',
|
||||
'Theme',
|
||||
'A11y',
|
||||
'General',
|
||||
];
|
||||
|
||||
Future<void> loadTasks() async {
|
||||
_isLoading = true;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
_tasks = await _repository.getTasks();
|
||||
} finally {
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void setCategoryFilter(String category) {
|
||||
if (_selectedCategory == category) return;
|
||||
_selectedCategory = category;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> toggleTaskCompletion(TaskItem item) async {
|
||||
await _repository.toggleTaskStatus(item);
|
||||
_tasks = await _repository.getTasks();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> addTask({
|
||||
required String title,
|
||||
required String description,
|
||||
required String category,
|
||||
}) async {
|
||||
await _repository.createTask(
|
||||
title: title,
|
||||
description: description,
|
||||
category: category,
|
||||
);
|
||||
_tasks = await _repository.getTasks();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> deleteTask(String id) async {
|
||||
await _repository.removeTask(id);
|
||||
_tasks = await _repository.getTasks();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../../../../data/repositories/match_repository.dart';
|
||||
import '../../../../domain/models/hockey_game.dart';
|
||||
|
||||
class MatchResultsViewModel extends ChangeNotifier {
|
||||
MatchResultsViewModel({required this.repository});
|
||||
|
||||
final MatchRepository repository;
|
||||
List<Match> _matches = [];
|
||||
bool _isLoading = false;
|
||||
String? _errorMessage;
|
||||
|
||||
List<Match> get matches => List.unmodifiable(_matches);
|
||||
bool get isLoading => _isLoading;
|
||||
String? get errorMessage => _errorMessage;
|
||||
|
||||
Future<void> loadMatches() async {
|
||||
_isLoading = true;
|
||||
_errorMessage = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
_matches = await repository.loadMatches();
|
||||
} catch (error) {
|
||||
_errorMessage = 'Unable to load match results.';
|
||||
} finally {
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user