-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57f82c9
commit d109419
Showing
5 changed files
with
93 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 30 additions & 4 deletions
34
lib/features/timetable_page/state_holders/timetable_page_lessons.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,40 @@ | ||
import 'dart:collection'; | ||
|
||
import 'package:cube_system/models/app_box_names/app_box_names.dart'; | ||
import 'package:cube_system/models/lesson/lesson.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
||
import 'package:cube_system/core/state_notifiers/hive_state_notifier.dart'; | ||
|
||
typedef TimetableLessons = SplayTreeMap<DateTime, List<Lesson>>; | ||
|
||
final timetablePageDayLessons = | ||
Provider.family<List<Lesson>?, DateTime>((ref, date) { | ||
return ref.watch(timetablePageTimetable)[date]; | ||
return ref.watch(timetablePageLessons)[date]; | ||
}); | ||
|
||
final timetablePageTimetable = | ||
StateProvider<SplayTreeMap<DateTime, List<Lesson>>>((ref) { | ||
return SplayTreeMap(); | ||
// final timetablePageTimetable = StateProvider<TimetableLessons>((ref) { | ||
// return SplayTreeMap(); | ||
// }); | ||
|
||
final timetablePageLessons = | ||
StateNotifierProvider<TimetablePageLessonsNotifier, TimetableLessons>( | ||
(ref) { | ||
return TimetablePageLessonsNotifier( | ||
SplayTreeMap(), | ||
boxName: AppBoxNames.timetablePageLessons, | ||
converter: Converter<TimetableLessons, Map<DateTime, List<Lesson>>>( | ||
to: (data) => data, | ||
from: (data) => SplayTreeMap.from(data), | ||
), | ||
); | ||
}); | ||
|
||
class TimetablePageLessonsNotifier | ||
extends SingleHiveStateNotifier<TimetableLessons> { | ||
TimetablePageLessonsNotifier( | ||
super.state, { | ||
required super.boxName, | ||
required super.converter, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class AppBoxNames { | ||
static const appSettings = 'appSettings'; | ||
static const selectedTimetable = 'selectedTimetable'; | ||
static const timetablePageLessons = 'timetablePageLessons'; | ||
} |