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:
kejaro committed 2026-09-27 19:34:46 +01:00
1 parent ffc2051e20
commit 4d377c1336
17 files changed
+500 -658

No files matched your search

@@ -0,0 +1,18 @@
import 'dart:convert';
import 'package:flutter/services.dart';
import '../../domain/models/hockey_game.dart';
class MatchRepository {
MatchRepository({AssetBundle? bundle}) : _bundle = bundle ?? rootBundle;
final AssetBundle _bundle;
Future<List<Match>> loadMatches() async {
final contents = await _bundle.loadString('lib/data/results.json');
final data = jsonDecode(contents) as Map<String, dynamic>;
return (data['games'] as List<dynamic>)
.map((game) => Match.fromJson(game as Map<String, dynamic>))
.toList();
}
}
@@ -1,53 +0,0 @@
import '../../domain/models/task_item.dart';
import '../models/task_item_model.dart';
import '../services/mock_task_service.dart';
class TaskRepository {
TaskRepository({required this._service});
final MockTaskService _service;
List<TaskItem>? _cachedTasks;
Future<List<TaskItem>> getTasks({bool forceRefresh = false}) async {
if (!forceRefresh && _cachedTasks != null) {
return _cachedTasks!;
}
final models = await _service.fetchTasks();
_cachedTasks = models.map((m) => m.toDomain()).toList();
return _cachedTasks!;
}
Future<TaskItem> createTask({
required String title,
required String description,
required String category,
}) async {
final newItem = TaskItem(
id: DateTime.now().millisecondsSinceEpoch.toString(),
title: title,
description: description,
category: category,
createdAt: DateTime.now(),
);
await _service.addTask(TaskItemModel.fromDomain(newItem));
_cachedTasks?.insert(0, newItem);
return newItem;
}
Future<void> toggleTaskStatus(TaskItem item) async {
final updated = item.copyWith(isCompleted: !item.isCompleted);
await _service.updateTask(TaskItemModel.fromDomain(updated));
if (_cachedTasks != null) {
final index = _cachedTasks!.indexWhere((t) => t.id == item.id);
if (index != -1) {
_cachedTasks![index] = updated;
}
}
}
Future<void> removeTask(String id) async {
await _service.deleteTask(id);
_cachedTasks?.removeWhere((t) => t.id == id);
}
}