Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
onTime
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
onTime InnoLab
onTime
Commits
2be33a66
Commit
2be33a66
authored
1 year ago
by
doodlezucc
Browse files
Options
Downloads
Patches
Plain Diff
introduce views/lesson providers
parent
91ebf683
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/main.dart
+8
-12
8 additions, 12 deletions
lib/main.dart
lib/views/mixed_class_view.dart
+30
-0
30 additions, 0 deletions
lib/views/mixed_class_view.dart
lib/views/view.dart
+11
-0
11 additions, 0 deletions
lib/views/view.dart
with
49 additions
and
12 deletions
lib/main.dart
+
8
−
12
View file @
2be33a66
...
@@ -9,11 +9,12 @@ import 'dialogs/error_dialog.dart';
...
@@ -9,11 +9,12 @@ import 'dialogs/error_dialog.dart';
import
'drawer/drawer.dart'
;
import
'drawer/drawer.dart'
;
import
'timetable/timetable.dart'
;
import
'timetable/timetable.dart'
;
import
'toolbar/toolbar.dart'
;
import
'toolbar/toolbar.dart'
;
import
'untis/element_type.dart'
;
import
'untis/fetch.dart'
;
import
'untis/fetch.dart'
;
import
'untis/timetable.dart'
;
import
'untis/timetable.dart'
;
import
'user/save_state.dart'
;
import
'user/save_state.dart'
;
import
'util/listenable.dart'
;
import
'util/listenable.dart'
;
import
'views/mixed_class_view.dart'
;
import
'views/view.dart'
;
void
main
()
{
void
main
()
{
runApp
(
const
MyApp
());
runApp
(
const
MyApp
());
...
@@ -57,9 +58,11 @@ class MyHomePage extends StatefulWidget {
...
@@ -57,9 +58,11 @@ class MyHomePage extends StatefulWidget {
}
}
class
_MyHomePageState
extends
State
<
MyHomePage
>
{
class
_MyHomePageState
extends
State
<
MyHomePage
>
{
Timetable
Data
?
timetable
;
late
Timetable
View
view
;
late
List
<
StreamSubscription
>
_subscriptions
;
late
List
<
StreamSubscription
>
_subscriptions
;
TimetableData
?
timetable
;
AppContext
get
appContext
=
>
widget
.
appContext
;
AppContext
get
appContext
=
>
widget
.
appContext
;
UntisFetch
get
untis
=
>
appContext
.
untis
;
UntisFetch
get
untis
=
>
appContext
.
untis
;
...
@@ -109,18 +112,11 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -109,18 +112,11 @@ class _MyHomePageState extends State<MyHomePage> {
final
profile
=
await
appContext
.
profile
.
firstNotNull
;
final
profile
=
await
appContext
.
profile
.
firstNotNull
;
final
selectedClasses
=
profile
.
selectedClasses
;
final
selectedClasses
=
profile
.
selectedClasses
;
final
allTimetables
=
await
Future
.
wait
(
selectedClasses
.
map
((
classId
)
{
view
=
MixedClassView
(
classIds:
selectedClasses
);
final
cacheable
=
untis
.
timetableOf
(
final
fetchedTimetable
=
await
view
.
timetableOf
(
date
,
untis:
untis
);
type:
ElementType
.
classGroup
,
elementId:
classId
,
date:
date
,
);
return
Future
(()
=
>
cacheable
.
fetched
);
}));
setState
(()
{
setState
(()
{
timetable
=
TimetableData
.
mergeAll
(
all
Timetable
s
)
;
timetable
=
fetched
Timetable
;
});
});
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/views/mixed_class_view.dart
0 → 100644
+
30
−
0
View file @
2be33a66
import
'../untis/element_type.dart'
;
import
'../untis/fetch.dart'
;
import
'../untis/timetable.dart'
;
import
'dart:async'
;
import
'view.dart'
;
class
MixedClassView
extends
TimetableView
{
final
Set
<
int
>
classIds
;
MixedClassView
({
required
this
.
classIds
});
@override
FutureOr
<
TimetableData
?
>
timetableOf
(
DateTime
date
,
{
required
UntisFetch
untis
,
})
async
{
final
allTimetables
=
await
Future
.
wait
(
classIds
.
map
((
classId
)
{
final
cacheable
=
untis
.
timetableOf
(
type:
ElementType
.
classGroup
,
elementId:
classId
,
date:
date
,
);
return
Future
(()
=
>
cacheable
.
fetched
);
}));
return
TimetableData
.
mergeAll
(
allTimetables
);
}
}
This diff is collapsed.
Click to expand it.
lib/views/view.dart
0 → 100644
+
11
−
0
View file @
2be33a66
import
'dart:async'
;
import
'../untis/fetch.dart'
;
import
'../untis/timetable.dart'
;
abstract
class
TimetableView
{
FutureOr
<
TimetableData
?
>
timetableOf
(
DateTime
date
,
{
required
UntisFetch
untis
,
});
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment