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:
47
lib/repositories/sqlite_event_repository.dart
Normal file
47
lib/repositories/sqlite_event_repository.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
import 'dart:collection';
|
||||
import 'package:habo/constants.dart';
|
||||
import 'package:habo/model/habo_model.dart';
|
||||
import 'package:habo/repositories/event_repository.dart';
|
||||
|
||||
class SqliteEventRepository implements EventRepository {
|
||||
final HaboModel _model;
|
||||
|
||||
SqliteEventRepository(this._model);
|
||||
|
||||
@override
|
||||
Future<List<List>> getEventsForHabit(int habitId) async {
|
||||
return _model.getEventsForHabit(habitId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<SplayTreeMap<DateTime, List>> getEventsMapForHabit(int habitId) async {
|
||||
return _model.getEventsMapForHabit(habitId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> insertEvent(int habitId, DateTime date, List event) async {
|
||||
await _model.insertEvent(habitId, date, event);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteEvent(int habitId, DateTime date) async {
|
||||
await _model.deleteEvent(habitId, date);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteAllEventsForHabit(int habitId) async {
|
||||
await _model.deleteAllEventsForHabit(habitId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> insertEventsForHabit(int habitId, Map<DateTime, List> events) async {
|
||||
for (final entry in events.entries) {
|
||||
await _model.insertEvent(habitId, entry.key, entry.value);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteAllEvents() async {
|
||||
await _model.deleteAllEvents();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user