Files
hockeyUmpire/mobile_app/lib/app.dart
T
kejaro 4d377c1336 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.
2026-09-27 19:34:46 +01:00

95 lines
3.1 KiB
Dart

import 'package:flutter/material.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/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 {
const MobileApp({super.key});
@override
State<MobileApp> createState() => _MobileAppState();
}
class _MobileAppState extends State<MobileApp> {
late final ThemeController _themeController;
late final MatchResultsViewModel _matchResultsViewModel;
int _currentTabIndex = 0;
@override
void initState() {
super.initState();
_themeController = ThemeController();
_matchResultsViewModel = MatchResultsViewModel(
repository: MatchRepository(),
);
_matchResultsViewModel.loadMatches();
}
@override
void dispose() {
_matchResultsViewModel.dispose();
_themeController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ListenableBuilder(
listenable: _themeController,
builder: (context, _) {
return MaterialApp(
title: 'Mobile App',
debugShowCheckedModeBanner: false,
theme: AppTheme.lightTheme,
darkTheme: AppTheme.darkTheme,
themeMode: _themeController.themeMode,
home: Builder(
builder: (context) {
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
return ResponsiveScaffold(
selectedIndex: _currentTabIndex,
onDestinationSelected: (index) {
setState(() => _currentTabIndex = index);
},
appBarTitle: Text(
_currentTabIndex == 0 ? 'Match Results' : 'Settings',
style: const TextStyle(fontWeight: FontWeight.bold),
),
actions: [
IconButton(
icon: Icon(
isDarkMode ? Icons.light_mode : Icons.dark_mode,
),
tooltip: isDarkMode ? 'Switch to light mode' : 'Switch to dark mode',
onPressed: _themeController.toggleTheme,
),
],
destinations: const [
NavigationDestinationItem(
icon: Icon(Icons.sports_hockey_outlined),
selectedIcon: Icon(Icons.sports_hockey),
label: 'Results',
),
NavigationDestinationItem(
icon: Icon(Icons.settings_outlined),
selectedIcon: Icon(Icons.settings),
label: 'Settings',
),
],
body: _currentTabIndex == 0
? MatchResultsView(viewModel: _matchResultsViewModel)
: SettingsView(themeController: _themeController),
);
},
),
);
},
);
}
}