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
+16
-106
@@ -1,11 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'data/repositories/task_repository.dart';
|
||||
import 'data/services/mock_task_service.dart';
|
||||
import 'data/repositories/match_repository.dart';
|
||||
import 'ui/core/theme/app_theme.dart';
|
||||
import 'ui/core/theme/theme_controller.dart';
|
||||
import 'ui/core/widgets/responsive_scaffold.dart';
|
||||
import 'ui/features/dashboard/view_models/dashboard_view_model.dart';
|
||||
import 'ui/features/dashboard/views/dashboard_view.dart';
|
||||
import 'ui/features/dashboard/view_models/match_results_view_model.dart';
|
||||
import 'ui/features/dashboard/views/match_results_view.dart';
|
||||
import 'ui/features/settings/views/settings_view.dart';
|
||||
|
||||
class MobileApp extends StatefulWidget {
|
||||
@@ -17,107 +16,26 @@ class MobileApp extends StatefulWidget {
|
||||
|
||||
class _MobileAppState extends State<MobileApp> {
|
||||
late final ThemeController _themeController;
|
||||
late final TaskRepository _taskRepository;
|
||||
late final DashboardViewModel _dashboardViewModel;
|
||||
late final MatchResultsViewModel _matchResultsViewModel;
|
||||
int _currentTabIndex = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_themeController = ThemeController();
|
||||
_taskRepository = TaskRepository(service: MockTaskService());
|
||||
_dashboardViewModel = DashboardViewModel(repository: _taskRepository);
|
||||
_dashboardViewModel.loadTasks();
|
||||
_matchResultsViewModel = MatchResultsViewModel(
|
||||
repository: MatchRepository(),
|
||||
);
|
||||
_matchResultsViewModel.loadMatches();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_dashboardViewModel.dispose();
|
||||
_matchResultsViewModel.dispose();
|
||||
_themeController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _showAddTaskDialog(BuildContext context) {
|
||||
final titleController = TextEditingController();
|
||||
final descriptionController = TextEditingController();
|
||||
String selectedCategory = 'General';
|
||||
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setDialogState) {
|
||||
return AlertDialog(
|
||||
title: const Text('New Task'),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(
|
||||
controller: titleController,
|
||||
autofocus: true,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Title',
|
||||
hintText: 'Enter task title',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextField(
|
||||
controller: descriptionController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Description',
|
||||
hintText: 'Optional details',
|
||||
),
|
||||
maxLines: 2,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
DropdownButtonFormField<String>(
|
||||
initialValue: selectedCategory,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Category',
|
||||
),
|
||||
items: const [
|
||||
DropdownMenuItem(value: 'General', child: Text('General')),
|
||||
DropdownMenuItem(value: 'Design', child: Text('Design')),
|
||||
DropdownMenuItem(value: 'Theme', child: Text('Theme')),
|
||||
DropdownMenuItem(value: 'A11y', child: Text('A11y')),
|
||||
],
|
||||
onChanged: (val) {
|
||||
if (val != null) {
|
||||
setDialogState(() => selectedCategory = val);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
final title = titleController.text.trim();
|
||||
if (title.isNotEmpty) {
|
||||
_dashboardViewModel.addTask(
|
||||
title: title,
|
||||
description: descriptionController.text.trim(),
|
||||
category: selectedCategory,
|
||||
);
|
||||
Navigator.of(dialogContext).pop();
|
||||
}
|
||||
},
|
||||
child: const Text('Add Task'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListenableBuilder(
|
||||
@@ -130,8 +48,8 @@ class _MobileAppState extends State<MobileApp> {
|
||||
darkTheme: AppTheme.darkTheme,
|
||||
themeMode: _themeController.themeMode,
|
||||
home: Builder(
|
||||
builder: (innerContext) {
|
||||
final isDarkMode = Theme.of(innerContext).brightness == Brightness.dark;
|
||||
builder: (context) {
|
||||
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return ResponsiveScaffold(
|
||||
selectedIndex: _currentTabIndex,
|
||||
@@ -139,7 +57,7 @@ class _MobileAppState extends State<MobileApp> {
|
||||
setState(() => _currentTabIndex = index);
|
||||
},
|
||||
appBarTitle: Text(
|
||||
_currentTabIndex == 0 ? 'Dashboard' : 'Settings',
|
||||
_currentTabIndex == 0 ? 'Match Results' : 'Settings',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
actions: [
|
||||
@@ -151,19 +69,11 @@ class _MobileAppState extends State<MobileApp> {
|
||||
onPressed: _themeController.toggleTheme,
|
||||
),
|
||||
],
|
||||
floatingActionButton: _currentTabIndex == 0
|
||||
? FloatingActionButton.extended(
|
||||
onPressed: () => _showAddTaskDialog(innerContext),
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('Add Task'),
|
||||
tooltip: 'Create a new task',
|
||||
)
|
||||
: null,
|
||||
destinations: const [
|
||||
NavigationDestinationItem(
|
||||
icon: Icon(Icons.dashboard_outlined),
|
||||
selectedIcon: Icon(Icons.dashboard),
|
||||
label: 'Dashboard',
|
||||
icon: Icon(Icons.sports_hockey_outlined),
|
||||
selectedIcon: Icon(Icons.sports_hockey),
|
||||
label: 'Results',
|
||||
),
|
||||
NavigationDestinationItem(
|
||||
icon: Icon(Icons.settings_outlined),
|
||||
@@ -172,7 +82,7 @@ class _MobileAppState extends State<MobileApp> {
|
||||
),
|
||||
],
|
||||
body: _currentTabIndex == 0
|
||||
? DashboardView(viewModel: _dashboardViewModel)
|
||||
? MatchResultsView(viewModel: _matchResultsViewModel)
|
||||
: SettingsView(themeController: _themeController),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user