Skip to content

Commit

Permalink
Merge pull request #255 from its-me-abhishek/tutorial
Browse files Browse the repository at this point in the history
Added a home tour for the app
  • Loading branch information
Pavel401 authored Jan 27, 2024
2 parents 2cfc767 + ecb1542 commit 7af206d
Show file tree
Hide file tree
Showing 5 changed files with 272 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/controller/home_tour_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:shared_preferences/shared_preferences.dart';

class SaveInAppTour {
Future<SharedPreferences> data = SharedPreferences.getInstance();

void saveTourStatus() async {
final value = await data;
value.setBool('tour', true);
}

Future<bool> getTourStatus() async {
final value = await data;
if (value.containsKey('tour')) {
bool? getData = value.getBool('tour');
return getData!;
} else {
return false;
}
}
}
63 changes: 63 additions & 0 deletions lib/views/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import 'package:google_fonts/google_fonts.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'package:taskwarrior/config/app_settings.dart';
import 'package:taskwarrior/controller/home_tour_controller.dart';
import 'package:taskwarrior/drawer/filter_drawer.dart';
import 'package:taskwarrior/drawer/nav_drawer.dart';
import 'package:taskwarrior/model/storage/storage_widget.dart';
import 'package:taskwarrior/taskserver/ntaskserver.dart';
import 'package:taskwarrior/views/home/home_tour.dart';
import 'package:taskwarrior/widgets/add_Task.dart';
import 'package:taskwarrior/widgets/buildTasks.dart';
import 'package:taskwarrior/widgets/pallete.dart';
Expand All @@ -20,6 +22,7 @@ import 'package:taskwarrior/model/storage.dart';

import 'package:taskwarrior/widgets/home_paths.dart' as rc;
import 'package:taskwarrior/widgets/taskserver.dart';
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';

class Filters {
const Filters({
Expand Down Expand Up @@ -48,6 +51,60 @@ class HomePage extends StatefulWidget {
}

class _HomePageState extends State<HomePage> {
final addKey = GlobalKey();
final searchKey = GlobalKey();
final filterKey = GlobalKey();
final menuKey = GlobalKey();
final refreshKey = GlobalKey();

bool isSaved = false;
late TutorialCoachMark tutorialCoachMark;

void _initInAppTour() {
tutorialCoachMark = TutorialCoachMark(
targets: addTargetsPage(
addKey: addKey,
searchKey: searchKey,
filterKey: filterKey,
menuKey: menuKey,
refreshKey: refreshKey,
),
colorShadow: Colors.black,
paddingFocus: 10,
opacityShadow: 0.8,
hideSkip: true,
onFinish: () {
SaveInAppTour().saveTourStatus();
});
}

void _showInAppTour() {
Future.delayed(
const Duration(seconds: 2),
() {
SaveInAppTour().getTourStatus().then((value) => {
if (value == false)
{
tutorialCoachMark.show(context: context),
}
else
{
// ignore: avoid_print
print('User has seen this page'),
// User has seen this page
}
});
},
);
}

@override
void initState() {
super.initState();
_initInAppTour();
_showInAppTour();
}

late InheritedStorage storageWidget;
late Storage storage;
Server? server;
Expand Down Expand Up @@ -149,6 +206,7 @@ class _HomePageState extends State<HomePage> {
Text('Home Page', style: GoogleFonts.poppins(color: Colors.white)),
actions: [
IconButton(
key: searchKey,
icon: (storageWidget.searchVisible)
? const Tooltip(
message: 'Cancel',
Expand All @@ -160,6 +218,7 @@ class _HomePageState extends State<HomePage> {
),
Builder(
builder: (context) => IconButton(
key: refreshKey,
icon: const Icon(Icons.refresh, color: Colors.white),
onPressed: () {
if (server != null || credentials != null) {
Expand Down Expand Up @@ -189,6 +248,7 @@ class _HomePageState extends State<HomePage> {
),
Builder(
builder: (context) => IconButton(
key: filterKey,
icon: const Tooltip(
message: 'Filters',
child: Icon(Icons.filter_list, color: Colors.white),
Expand All @@ -199,6 +259,7 @@ class _HomePageState extends State<HomePage> {
],
leading: Builder(
builder: (context) => IconButton(
key: menuKey,
icon: const Tooltip(
message: 'Menu', child: Icon(Icons.menu, color: Colors.white)),
onPressed: () => Scaffold.of(context).openDrawer(),
Expand All @@ -217,6 +278,7 @@ class _HomePageState extends State<HomePage> {
children: <Widget>[
if (storageWidget.searchVisible)
Container(
key: searchKey,
margin: const EdgeInsets.symmetric(
horizontal: 10, vertical: 10),
child: SearchBar(
Expand Down Expand Up @@ -262,6 +324,7 @@ class _HomePageState extends State<HomePage> {
),
endDrawer: FilterDrawer(filters),
floatingActionButton: FloatingActionButton(
key: addKey,
heroTag: "btn3",
backgroundColor:
AppSettings.isDarkMode ? Colors.white : Palette.kToDark.shade200,
Expand Down
180 changes: 180 additions & 0 deletions lib/views/home/home_tour.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';

List<TargetFocus> addTargetsPage({
required GlobalKey addKey,
required GlobalKey searchKey,
required GlobalKey filterKey,
required GlobalKey menuKey,
required GlobalKey refreshKey,
}) {
List<TargetFocus> targets = [];

// add
targets.add(
TargetFocus(
keyTarget: addKey,
alignSkip: Alignment.topRight,
radius: 10,
shape: ShapeLightFocus.Circle,
contents: [
TargetContent(
align: ContentAlign.top,
builder: (context, controller) {
return Container(
alignment: Alignment.center,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Add a new task",
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
color: Colors.white,
),
),
],
),
);
},
),
],
),
);

//search
targets.add(
TargetFocus(
keyTarget: searchKey,
alignSkip: Alignment.topRight,
radius: 10,
shape: ShapeLightFocus.Circle,
contents: [
TargetContent(
align: ContentAlign.bottom,
builder: (context, controller) {
return Container(
alignment: Alignment.center,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Search for tasks",
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
color: Colors.white,
),
),
],
),
);
},
),
],
),
);

//refresh
targets.add(
TargetFocus(
keyTarget: refreshKey,
alignSkip: Alignment.topCenter,
radius: 10,
shape: ShapeLightFocus.Circle,
contents: [
TargetContent(
align: ContentAlign.bottom,
builder: (context, controller) {
return Container(
alignment: Alignment.center,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Refresh or sync your tasks",
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
color: Colors.white,
),
),
],
),
);
},
),
],
),
);

//filter
targets.add(
TargetFocus(
keyTarget: filterKey,
alignSkip: Alignment.topCenter,
radius: 10,
shape: ShapeLightFocus.Circle,
contents: [
TargetContent(
align: ContentAlign.bottom,
builder: (context, controller) {
return Container(
alignment: Alignment.center,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Add filters to sort your tasks and projects",
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
color: Colors.white,
),
),
],
),
);
},
),
],
),
);

//menu
targets.add(
TargetFocus(
keyTarget: menuKey,
alignSkip: Alignment.bottomRight,
radius: 10,
shape: ShapeLightFocus.Circle,
contents: [
TargetContent(
align: ContentAlign.bottom,
builder: (context, controller) {
return Container(
alignment: Alignment.center,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Access additional settings here",
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
color: Colors.white,
),
),
],
),
);
},
),
],
),
);

return targets;
}
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.2"
tutorial_coach_mark:
dependency: "direct main"
description:
name: tutorial_coach_mark
sha256: "1f1fd234790afb929dec7391a4d90aa54ffe8c8e4d278d9283df8e3f5ac5d63e"
url: "https://pub.dev"
source: hosted
version: "1.2.11"
typed_data:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies:
syncfusion_flutter_charts: ^23.2.7
timezone: ^0.9.2
tuple: ^2.0.0
tutorial_coach_mark: ^1.2.11
url_launcher: ^6.1.14
uuid: ^4.2.2

Expand Down

0 comments on commit 7af206d

Please sign in to comment.