feat: initial commit - Habo habit tracking app
- Complete MVP with Repository Pattern, SQLite storage - Provider + ChangeNotifier state management - Navigation 2.0 with deep link support - Habit CRUD with twoDayRule, notifications, categories - Backup/Restore via JSON - Statistics with streak tracking - Material You theme support - Biometric lock support - Desktop widget support - 27 languages i18n structure - Comprehensive test suite (87/89 passing)
This commit is contained in:
105
lib/navigation/app_router.dart
Normal file
105
lib/navigation/app_router.dart
Normal file
@@ -0,0 +1,105 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:habo/navigation/app_state_manager.dart';
|
||||
import 'package:habo/navigation/routes.dart';
|
||||
import 'package:habo/habits/habits_screen.dart';
|
||||
import 'package:habo/statistics/statistics_screen.dart';
|
||||
import 'package:habo/settings/settings_screen.dart';
|
||||
import 'package:habo/onboarding/onboarding.dart';
|
||||
import 'package:habo/habits/create_habit.dart';
|
||||
import 'package:habo/habits/edit_habit.dart';
|
||||
|
||||
class AppRouter extends RouterDelegate<HaboRouteConfiguration>
|
||||
with ChangeNotifier, PopNavigatorRouterDelegateMixin<HaboRouteConfiguration> {
|
||||
final AppStateManager appStateManager;
|
||||
|
||||
AppRouter(this.appStateManager) {
|
||||
appStateManager.addListener(notifyListeners);
|
||||
}
|
||||
|
||||
@override
|
||||
GlobalKey<NavigatorState> get navigatorKey => GlobalKey<NavigatorState>();
|
||||
|
||||
@override
|
||||
HaboRouteConfiguration? get currentConfiguration {
|
||||
if (appStateManager.onboarding) return HaboRouteConfiguration(path: RouteConstants.onboardingPath);
|
||||
if (appStateManager.statistics) return HaboRouteConfiguration(path: RouteConstants.statisticsPath);
|
||||
if (appStateManager.settings) return HaboRouteConfiguration(path: RouteConstants.settingsPath);
|
||||
if (appStateManager.createHabit) return HaboRouteConfiguration(path: RouteConstants.createHabitPath);
|
||||
if (appStateManager.editHabit) return HaboRouteConfiguration(path: RouteConstants.editHabitPath);
|
||||
return HaboRouteConfiguration(path: RouteConstants.habitsPath);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final pages = <Page<dynamic>>[];
|
||||
|
||||
// Always start with habits screen
|
||||
pages.add(
|
||||
const MaterialPage<dynamic>(
|
||||
child: HabitsScreen(),
|
||||
key: ValueKey('habits'),
|
||||
),
|
||||
);
|
||||
|
||||
if (appStateManager.statistics) {
|
||||
pages.add(
|
||||
const MaterialPage<dynamic>(
|
||||
child: StatisticsScreen(),
|
||||
key: ValueKey('statistics'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (appStateManager.settings) {
|
||||
pages.add(
|
||||
const MaterialPage<dynamic>(
|
||||
child: SettingsScreen(),
|
||||
key: ValueKey('settings'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (appStateManager.onboarding) {
|
||||
pages.add(
|
||||
const MaterialPage<dynamic>(
|
||||
child: OnboardingScreen(),
|
||||
key: ValueKey('onboarding'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (appStateManager.createHabit) {
|
||||
pages.add(
|
||||
const MaterialPage<dynamic>(
|
||||
child: CreateHabitScreen(),
|
||||
key: ValueKey('create'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (appStateManager.editHabit) {
|
||||
pages.add(
|
||||
const MaterialPage<dynamic>(
|
||||
child: EditHabitScreen(),
|
||||
key: ValueKey('edit'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Navigator(
|
||||
key: navigatorKey,
|
||||
pages: pages,
|
||||
onDidRemovePage: (page) {},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setNewRoutePath(HaboRouteConfiguration configuration) async {
|
||||
// Handle deep links
|
||||
}
|
||||
}
|
||||
|
||||
class HaboRouteConfiguration {
|
||||
final String path;
|
||||
HaboRouteConfiguration({required this.path});
|
||||
}
|
||||
Reference in New Issue
Block a user