-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtutorial.util.dart
53 lines (43 loc) · 1.67 KB
/
tutorial.util.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import 'package:safe/core.dart';
import 'package:safe/services/analytics/helper_classes/analytics_log_model.service.dart';
class TutorialUtil {
void _log(Core core, bool isSuccess) {
core.services.analytics.log(AnalyticsLog(
channel: "user-register",
event: "tutorial-finished-${isSuccess ? "success" : "missing-contacts"}",
description:
"User has finished their tutorial ${isSuccess ? "successfully" : "without contacts"}.",
icon: isSuccess ? "🎉" : "💥",
tags: {
"userid": core.services.auth.currentUser!.uid,
"datetime": DateTime.now().toIso8601String(),
},
));
}
// Used to take user to home screen if during tutorial and show success message
Future<void> handleOnLeave(Core core) async {
if (!core.state.preferences.isFirstTime) return;
if (core.state.preferences.tutorialCalled) return;
if (!core.state.preferences.seenWidgetPreview) {
core.state.incident.widgetShowcasePopupController.open();
core.state.preferences.setSeenWidgetPreview(true);
return;
}
await core.state.incidentLog.controller.close();
if (core.state.capture.limErrState != null) {
_log(core, false);
return;
}
_log(core, true);
// Trigger fireworks and success message
core.state.preferences.confettiController.play();
core.state.preferences.tutorialBannerController.open();
core.state.preferences.setTutorialCalled(true);
}
void handleCaptureTutorial(Core core) {
core.utils.capture.tutorial();
core.state.preferences.setIsFirstTime(false);
core.state.preferences.tutorialBannerController.close();
core.state.capture.controller.open();
}
}