Skip to content

Commit a41a427

Browse files
committed
Tour of details page
1 parent 3d8aaa6 commit a41a427

File tree

7 files changed

+225
-1
lines changed

7 files changed

+225
-1
lines changed

lib/app/modules/detailRoute/controllers/detail_route_controller.dart

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import 'package:built_collection/built_collection.dart';
2+
import 'package:flutter/material.dart';
23
import 'package:get/get.dart';
34
import 'package:taskwarrior/app/modules/home/controllers/home_controller.dart';
5+
import 'package:taskwarrior/app/tour/details_page_tour.dart';
6+
import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart';
47
import 'package:taskwarrior/app/utils/taskfunctions/modify.dart';
58
import 'package:taskwarrior/app/utils/taskfunctions/urgency.dart';
9+
import 'package:taskwarrior/app/utils/theme/app_settings.dart';
10+
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';
611

712
class DetailRouteController extends GetxController {
813
late String uuid;
@@ -46,7 +51,7 @@ class DetailRouteController extends GetxController {
4651
// 'status': controller.modify.draft.status,
4752
// 'entry': controller.modify.draft.entry,
4853
// 'modified': controller.modify.draft.modified,
49-
// 'start': controller.modify.draft.start,
54+
// 'start': controller.modify.draft.start,
5055
// 'end': controller.modify.draft.end,
5156
// 'due': controller.dueValue.value,
5257
// 'wait': controller.modify.draft.wait,
@@ -85,4 +90,49 @@ class DetailRouteController extends GetxController {
8590
tagsValue?.value = modify.draft.tags;
8691
urgencyValue.value = urgency(modify.draft);
8792
}
93+
94+
late TutorialCoachMark tutorialCoachMark;
95+
96+
final GlobalKey dueKey = GlobalKey();
97+
final GlobalKey untilKey = GlobalKey();
98+
99+
final GlobalKey waitKey = GlobalKey();
100+
final GlobalKey priorityKey = GlobalKey();
101+
102+
void initDetailsPageTour() {
103+
tutorialCoachMark = TutorialCoachMark(
104+
targets: addDetailsPage(
105+
dueKey: dueKey,
106+
waitKey: waitKey,
107+
untilKey: untilKey,
108+
priorityKey: priorityKey,
109+
),
110+
colorShadow: TaskWarriorColors.black,
111+
paddingFocus: 10,
112+
opacityShadow: 1.00,
113+
hideSkip: true,
114+
onFinish: () {
115+
SaveTourStatus.saveDetailsTourStatus(true);
116+
},
117+
);
118+
}
119+
120+
void showDetailsPageTour(BuildContext context) {
121+
Future.delayed(
122+
const Duration(milliseconds: 500),
123+
() {
124+
SaveTourStatus.getDetailsTourStatus().then((value) => {
125+
if (value == false)
126+
{
127+
tutorialCoachMark.show(context: context),
128+
}
129+
else
130+
{
131+
// ignore: avoid_print
132+
print('User has seen this page'),
133+
}
134+
});
135+
},
136+
);
137+
}
88138
}

lib/app/modules/detailRoute/views/dateTimePicker.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ class DateTimeWidget extends StatelessWidget {
1414
required this.name,
1515
required this.value,
1616
required this.callback,
17+
required this.globalKey,
1718
});
1819

1920
final String name;
2021

2122
final dynamic value;
2223
final void Function(dynamic) callback;
24+
final GlobalKey globalKey;
2325

2426
@override
2527
Widget build(BuildContext context) {
2628
return Card(
29+
key: globalKey,
2730
color: AppSettings.isDarkMode
2831
? const Color.fromARGB(255, 57, 57, 57)
2932
: Colors.white,

lib/app/modules/detailRoute/views/detail_route_view.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class DetailRouteView extends GetView<DetailRouteController> {
1818

1919
@override
2020
Widget build(BuildContext context) {
21+
controller.initDetailsPageTour();
22+
controller.showDetailsPageTour(context);
2123
return WillPopScope(
2224
onWillPop: () async {
2325
if (!controller.onEdit.value) {
@@ -133,6 +135,10 @@ class DetailRouteView extends GetView<DetailRouteController> {
133135
value: entry.value,
134136
callback: (newValue) =>
135137
controller.setAttribute(entry.key, newValue),
138+
waitKey: controller.waitKey,
139+
dueKey: controller.dueKey,
140+
untilKey: controller.untilKey,
141+
priorityKey: controller.priorityKey,
136142
),
137143
],
138144
),
@@ -223,12 +229,20 @@ class AttributeWidget extends StatelessWidget {
223229
required this.name,
224230
required this.value,
225231
required this.callback,
232+
required this.waitKey,
233+
required this.dueKey,
234+
required this.priorityKey,
235+
required this.untilKey,
226236
super.key,
227237
});
228238

229239
final String name;
230240
final dynamic value;
231241
final void Function(dynamic) callback;
242+
final GlobalKey waitKey;
243+
final GlobalKey dueKey;
244+
final GlobalKey untilKey;
245+
final GlobalKey priorityKey;
232246

233247
@override
234248
Widget build(BuildContext context) {
@@ -260,24 +274,28 @@ class AttributeWidget extends StatelessWidget {
260274
name: name,
261275
value: localValue,
262276
callback: callback,
277+
globalKey: dueKey,
263278
);
264279
case 'wait':
265280
return DateTimeWidget(
266281
name: name,
267282
value: localValue,
268283
callback: callback,
284+
globalKey: waitKey,
269285
);
270286
case 'until':
271287
return DateTimeWidget(
272288
name: name,
273289
value: localValue,
274290
callback: callback,
291+
globalKey: untilKey,
275292
);
276293
case 'priority':
277294
return PriorityWidget(
278295
name: name,
279296
value: localValue,
280297
callback: callback,
298+
globalKey: priorityKey,
281299
);
282300
case 'project':
283301
return ProjectWidget(

lib/app/modules/detailRoute/views/priority_widget.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ class PriorityWidget extends StatelessWidget {
88
{required this.name,
99
required this.value,
1010
required this.callback,
11+
required this.globalKey,
1112
super.key});
1213

1314
final String name;
1415
final dynamic value;
1516
final void Function(dynamic) callback;
17+
final GlobalKey globalKey;
1618

1719
@override
1820
Widget build(BuildContext context) {
1921
return Card(
22+
key: globalKey,
2023
color: AppSettings.isDarkMode
2124
? const Color.fromARGB(255, 57, 57, 57)
2225
: Colors.white,
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:google_fonts/google_fonts.dart';
3+
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';
4+
5+
List<TargetFocus> addDetailsPage({
6+
required GlobalKey dueKey,
7+
required GlobalKey waitKey,
8+
required GlobalKey untilKey,
9+
required GlobalKey priorityKey,
10+
}) {
11+
List<TargetFocus> targets = [];
12+
13+
targets.add(
14+
TargetFocus(
15+
keyTarget: dueKey,
16+
alignSkip: Alignment.topRight,
17+
shape: ShapeLightFocus.RRect,
18+
contents: [
19+
TargetContent(
20+
align: ContentAlign.top,
21+
builder: (context, controller) {
22+
return Container(
23+
alignment: Alignment.center,
24+
child: Column(
25+
crossAxisAlignment: CrossAxisAlignment.center,
26+
mainAxisAlignment: MainAxisAlignment.center,
27+
children: <Widget>[
28+
Text(
29+
"This signifies the due date of the task",
30+
textAlign: TextAlign.center,
31+
style: GoogleFonts.poppins(
32+
color: Colors.white,
33+
),
34+
),
35+
],
36+
),
37+
);
38+
},
39+
),
40+
],
41+
),
42+
);
43+
44+
targets.add(
45+
TargetFocus(
46+
keyTarget: waitKey,
47+
alignSkip: Alignment.topRight,
48+
shape: ShapeLightFocus.RRect,
49+
contents: [
50+
TargetContent(
51+
align: ContentAlign.bottom,
52+
builder: (context, controller) {
53+
return Container(
54+
alignment: Alignment.center,
55+
child: Column(
56+
crossAxisAlignment: CrossAxisAlignment.center,
57+
mainAxisAlignment: MainAxisAlignment.center,
58+
children: <Widget>[
59+
Text(
60+
"This signifies the waiting date of the task \n Task will be visible after this date",
61+
textAlign: TextAlign.center,
62+
style: GoogleFonts.poppins(
63+
color: Colors.white,
64+
),
65+
),
66+
],
67+
),
68+
);
69+
},
70+
),
71+
],
72+
),
73+
);
74+
75+
targets.add(
76+
TargetFocus(
77+
keyTarget: untilKey,
78+
alignSkip: Alignment.topRight,
79+
shape: ShapeLightFocus.RRect,
80+
contents: [
81+
TargetContent(
82+
align: ContentAlign.bottom,
83+
builder: (context, controller) {
84+
return Container(
85+
alignment: Alignment.center,
86+
child: Column(
87+
crossAxisAlignment: CrossAxisAlignment.center,
88+
mainAxisAlignment: MainAxisAlignment.center,
89+
children: <Widget>[
90+
Text(
91+
"This shows the last date of the task",
92+
textAlign: TextAlign.center,
93+
style: GoogleFonts.poppins(
94+
color: Colors.white,
95+
),
96+
),
97+
],
98+
),
99+
);
100+
},
101+
),
102+
],
103+
),
104+
);
105+
106+
targets.add(
107+
TargetFocus(
108+
keyTarget: priorityKey,
109+
alignSkip: Alignment.topRight,
110+
shape: ShapeLightFocus.RRect,
111+
contents: [
112+
TargetContent(
113+
align: ContentAlign.bottom,
114+
builder: (context, controller) {
115+
return Container(
116+
alignment: Alignment.center,
117+
child: Column(
118+
crossAxisAlignment: CrossAxisAlignment.center,
119+
mainAxisAlignment: MainAxisAlignment.center,
120+
children: <Widget>[
121+
Text(
122+
"This is the priority of the Tasks \n L -> Low \n M -> Medium \n H -> Hard",
123+
textAlign: TextAlign.center,
124+
style: GoogleFonts.poppins(
125+
color: Colors.white,
126+
),
127+
),
128+
],
129+
),
130+
);
131+
},
132+
),
133+
],
134+
),
135+
);
136+
137+
return targets;
138+
}

lib/app/utils/theme/app_settings.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ class SaveTourStatus {
7272
static Future<bool> getProfileTourStatus() async {
7373
return _preferences?.getBool('profile_tour') ?? false;
7474
}
75+
76+
static Future saveDetailsTourStatus(bool status) async {
77+
await _preferences?.setBool('details_tour', status);
78+
}
79+
80+
static Future<bool> getDetailsTourStatus() async {
81+
return _preferences?.getBool('details_tour') ?? false;
82+
}
7583
}
7684

7785
class AppSettings {

lib/main.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ import 'package:flutter/material.dart';
22

33
import 'package:get/get.dart';
44
import 'package:permission_handler/permission_handler.dart';
5+
import 'package:shared_preferences/shared_preferences.dart';
56
import 'package:taskwarrior/app/utils/theme/app_settings.dart';
67

78
import 'app/routes/app_pages.dart';
89

910
void main() async {
1011
WidgetsFlutterBinding.ensureInitialized();
12+
SharedPreferences pref = await SharedPreferences.getInstance();
13+
pref.setBool('details_tour', false);
14+
1115
await AppSettings.init();
1216
await Permission.notification.isDenied.then((value) {
1317
if (value) {

0 commit comments

Comments
 (0)