Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
app
Manage
Activity
Members
Labels
Plan
Issues
18
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Car App
app
Commits
01bf3aa2
Commit
01bf3aa2
authored
11 months ago
by
Andri Joos
Browse files
Options
Downloads
Patches
Plain Diff
calendar error handling
parent
32a6dce9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!10
Resolve "Add icon"
Pipeline
#5916
passed with stage
in 7 minutes and 37 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
car_app/lib/main.dart
+1
-0
1 addition, 0 deletions
car_app/lib/main.dart
car_app/lib/viewmodel/calendar.dart
+26
-5
26 additions, 5 deletions
car_app/lib/viewmodel/calendar.dart
with
27 additions
and
5 deletions
car_app/lib/main.dart
+
1
−
0
View file @
01bf3aa2
...
...
@@ -80,6 +80,7 @@ class App extends StatelessWidget {
ChangeNotifierProvider
(
create:
(
context
)
=
>
CalendarViewModel
(
calendarEventService:
Provider
.
of
(
context
,
listen:
false
),
authenticationService:
Provider
.
of
(
context
,
listen:
false
),
loggingService:
Provider
.
of
(
context
,
listen:
false
),
)),
],
child:
MaterialApp
(
...
...
This diff is collapsed.
Click to expand it.
car_app/lib/viewmodel/calendar.dart
+
26
−
5
View file @
01bf3aa2
import
'package:car_app/exception/server.dart'
;
import
'package:car_app/model/calendar_event.dart'
;
import
'package:car_app/model/user.dart'
;
import
'package:car_app/service/interface/authentication.dart'
;
import
'package:car_app/service/interface/calendar_event.dart'
;
import
'package:car_app/service/interface/logging.dart'
;
import
'package:flutter/foundation.dart'
;
class
CalendarViewModel
extends
ChangeNotifier
{
final
CalendarEventService
calendarEventService
;
final
AuthenticationService
authenticationService
;
final
LoggingService
loggingService
;
final
List
<
CalendarEvent
>
events
=
[];
User
?
currentUser
;
CalendarViewModel
({
required
this
.
calendarEventService
,
required
this
.
authenticationService
})
{
CalendarViewModel
({
required
this
.
calendarEventService
,
required
this
.
authenticationService
,
required
this
.
loggingService
})
{
authenticationService
.
isLoggedIn
()
.
then
((
isLoggedIn
)
async
{
if
(
isLoggedIn
)
{
currentUser
=
await
authenticationService
.
user
;
}
});
})
.
catchError
(
test:
(
e
)
=
>
e
is
ServerException
,
(
e
,
s
)
=
>
loggingService
.
error
(
e
.
toString
(),
exception:
e
,
trace:
s
),
);
}
void
addNewlyAddedCalendarEvent
(
CalendarEvent
event
)
{
...
...
@@ -38,7 +45,10 @@ class CalendarViewModel extends ChangeNotifier {
_addEvent
(
event
);
});
}
});
})
.
catchError
(
test:
(
e
)
=
>
e
is
ServerException
,
(
e
,
s
)
=
>
loggingService
.
error
(
e
.
toString
(),
exception:
e
,
trace:
s
),
);
}
String
avatarTextFromName
(
String
name
)
{
...
...
@@ -104,7 +114,11 @@ class CalendarViewModel extends ChangeNotifier {
calendarEventService
.
delete
(
event
)
.
then
((
event
)
{
_removeEvent
(
event
);
undoToast
(
event
);
});
})
.
catchError
(
test:
(
e
)
=
>
e
is
ServerException
,
(
e
,
s
)
=
>
loggingService
.
error
(
e
.
toString
(),
exception:
e
,
trace:
s
),
);
}
}
...
...
@@ -118,7 +132,14 @@ class CalendarViewModel extends ChangeNotifier {
calendarEventService
.
add
(
event
)
.
then
((
eventFromServer
)
{
_removeEvent
(
event
);
_addEvent
(
eventFromServer
);
});
})
.
catchError
(
test:
(
e
)
=
>
e
is
ServerException
,
(
e
,
s
)
{
loggingService
.
error
(
e
.
toString
(),
exception:
e
,
trace:
s
);
_removeEvent
(
event
);
},
);
}
bool
isEventFromCurrentUser
(
CalendarEvent
event
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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