Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : added task swipe tour #460

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions lib/app/modules/home/controllers/home_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import 'package:taskwarrior/app/routes/app_pages.dart';
import 'package:taskwarrior/app/services/tag_filter.dart';
import 'package:taskwarrior/app/tour/filter_drawer_tour.dart';
import 'package:taskwarrior/app/tour/home_page_tour.dart';
import 'package:taskwarrior/app/tour/task_swipe_tour.dart';
import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart';
import 'package:taskwarrior/app/utils/language/supported_language.dart';
import 'package:taskwarrior/app/utils/taskchampion/credentials_storage.dart';
Expand Down Expand Up @@ -676,6 +677,34 @@ class HomeController extends GetxController {
);
}

final taskItemKey = GlobalKey();

void initTaskSwipeTutorial() {
tutorialCoachMark = TutorialCoachMark(
targets: addTaskSwipeTutorialTargets(taskItemKey: taskItemKey),
colorShadow: TaskWarriorColors.black,
paddingFocus: 10,
opacityShadow: 1.00,
hideSkip: true,
onFinish: () {
SaveTourStatus.saveTaskSwipeTutorialStatus(true);
},
);
}

void showTaskSwipeTutorial(BuildContext context) {
SaveTourStatus.getTaskSwipeTutorialStatus().then((value) {
print("value is $value");
print("tasks is ${tasks.isNotEmpty}");
if (value == false) {
initTaskSwipeTutorial();
tutorialCoachMark.show(context: context);
} else {
debugPrint('User has already seen the task swipe tutorial');
}
});
}

late RxString uuid = "".obs;
late RxBool isHomeWidgetTaskTapped = false.obs;

Expand Down
81 changes: 41 additions & 40 deletions lib/app/modules/home/views/add_task_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class AddTaskBottomSheet extends StatelessWidget {
},
fieldHintText: "Month/Date/Year",
context: context,
initialDate: homeController.due.value?? DateTime.now(),
initialDate: homeController.due.value ?? DateTime.now(),
firstDate: DateTime.now(),
lastDate: DateTime(2037, 12, 31),
);
Expand Down Expand Up @@ -355,10 +355,7 @@ class AddTaskBottomSheet extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"${SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskPriority} :",
"${SentenceManager(currentLanguage: homeController.selectedLanguage.value).sentences.addTaskPriority} :",
style: GoogleFonts.poppins(
fontWeight: TaskWarriorFonts.bold,
color: AppSettings.isDarkMode
Expand All @@ -367,51 +364,54 @@ class AddTaskBottomSheet extends StatelessWidget {
),
textAlign: TextAlign.left,
),
const SizedBox(width: 2,),
const SizedBox(
width: 2,
),
Obx(
() => Row(
children: [
for(int i=0;i<homeController.priorityList.length;i++)
for (int i = 0; i < homeController.priorityList.length; i++)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 2.5),
child: GestureDetector(
onTap: () {
homeController.priority.value = homeController.priorityList[i];
homeController.priority.value =
homeController.priorityList[i];
debugPrint(homeController.priority.value);
},
child: AnimatedContainer(
duration: const Duration(milliseconds: 100),
height: 30,
width: 37,
decoration: BoxDecoration(

borderRadius: BorderRadius.circular(8),
border: Border.all(
color: homeController.priority.value == homeController.priorityList[i]
? AppSettings.isDarkMode
? TaskWarriorColors.kLightPrimaryBackgroundColor
: TaskWarriorColors.kprimaryBackgroundColor
: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor,
)
),
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: homeController.priority.value ==
homeController.priorityList[i]
? AppSettings.isDarkMode
? TaskWarriorColors
.kLightPrimaryBackgroundColor
: TaskWarriorColors
.kprimaryBackgroundColor
: AppSettings.isDarkMode
? TaskWarriorColors
.kprimaryBackgroundColor
: TaskWarriorColors
.kLightPrimaryBackgroundColor,
)),
child: Center(
child: Text(
homeController.priorityList[i],
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
fontWeight: FontWeight.bold,
fontSize: 17,
color: homeController.priorityColors[i]
),
fontWeight: FontWeight.bold,
fontSize: 17,
color: homeController.priorityColors[i]),
),
),
),

),
)

],
),
)
Expand Down Expand Up @@ -448,8 +448,7 @@ class AddTaskBottomSheet extends StatelessWidget {
Widget buildAddButton(BuildContext context) {
return TextButton(
child: Text(
SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
SentenceManager(currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskAdd,
style: TextStyle(
Expand All @@ -460,12 +459,12 @@ class AddTaskBottomSheet extends StatelessWidget {
),
onPressed: () async {
// print(homeController.formKey.currentState);
if(homeController.due.value!=null&&DateTime.now().isAfter(homeController.due.value!)){
if (homeController.due.value != null &&
DateTime.now().isAfter(homeController.due.value!)) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
SentenceManager(
currentLanguage:
homeController.selectedLanguage.value)
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskTimeInPast,
style: TextStyle(
Expand All @@ -476,8 +475,7 @@ class AddTaskBottomSheet extends StatelessWidget {
),
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.ksecondaryBackgroundColor
: TaskWarriorColors
.kLightSecondaryBackgroundColor,
: TaskWarriorColors.kLightSecondaryBackgroundColor,
duration: const Duration(seconds: 2)));
return;
}
Expand All @@ -501,13 +499,12 @@ class AddTaskBottomSheet extends StatelessWidget {
homeController.priority.value = 'M';
homeController.tagcontroller.text = '';
homeController.tags.value = [];
homeController.due.value=null;
homeController.due.value = null;
homeController.update();
// Navigator.of(context).pop();
Get.back();
if (Platform.isAndroid) {
WidgetController widgetController =
Get.put(WidgetController());
WidgetController widgetController = Get.put(WidgetController());
widgetController.fetchAllData();

widgetController.update();
Expand All @@ -518,7 +515,8 @@ class AddTaskBottomSheet extends StatelessWidget {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
currentLanguage:
homeController.selectedLanguage.value)
.sentences
.addTaskTaskAddedSuccessfully,
style: TextStyle(
Expand All @@ -542,6 +540,7 @@ class AddTaskBottomSheet extends StatelessWidget {
if (value) {
storageWidget.synchronize(context, true);
}
homeController.showTaskSwipeTutorial(context);
} on FormatException catch (e) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
Expand All @@ -567,18 +566,20 @@ class AddTaskBottomSheet extends StatelessWidget {
if (tag.isNotEmpty) {
String trimmedString = tag.trim();
List<String> tags = trimmedString.split(" ");
for(tag in tags){
if(checkTagIfExists(tag)) {
for (tag in tags) {
if (checkTagIfExists(tag)) {
removeTag(tag);
}
homeController.tags.add(tag);
}
homeController.tagcontroller.text = '';
}
}
bool checkTagIfExists(String tag){

bool checkTagIfExists(String tag) {
return homeController.tags.contains(tag);
}

void removeTag(String tag) {
homeController.tags.remove(tag);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ class AddTaskToTaskcBottomSheet extends StatelessWidget {
end: '',
modified: 'r');
await homeController.taskdb.insertTask(task);
homeController.showTaskSwipeTutorial(context);
homeController.namecontroller.text = '';
homeController.due.value = null;
homeController.priority.value = 'M';
Expand Down
10 changes: 6 additions & 4 deletions lib/app/modules/home/views/tasks_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ class TasksBuilder extends StatelessWidget {
action: SnackBarAction(
label: 'Undo',
onPressed: () {
undoChanges(
context, id, 'pending');

undoChanges(context, id, 'pending');
},
),
));
Expand Down Expand Up @@ -180,9 +178,13 @@ class TasksBuilder extends StatelessWidget {
primary: false,
itemBuilder: (context, index) {
var task = taskData[index];
final itemKey = index == 0
? storageWidget.taskItemKey
: ValueKey(task.uuid);

return pendingFilter
? Slidable(
key: ValueKey(task.uuid),
key: itemKey,
startActionPane: ActionPane(
motion: const BehindMotion(),
children: [
Expand Down
100 changes: 100 additions & 0 deletions lib/app/tour/task_swipe_tour.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';

List<TargetFocus> addTaskSwipeTutorialTargets({
required GlobalKey taskItemKey,
}) {
List<TargetFocus> targets = [];

targets.add(
TargetFocus(
identify: "taskSwipeTutorial",
keyTarget: taskItemKey,
alignSkip: Alignment.bottomRight,
radius: 10,
shape: ShapeLightFocus.RRect,
contents: [
TargetContent(
align: ContentAlign.bottom,
builder: (context, controller) {
return Container(
alignment: Alignment.center,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Task Swipe Actions",
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 22.0,
),
),
const SizedBox(height: 8),
Text(
"This is how you manage your tasks quickly : ",
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
color: Colors.white,
fontStyle: FontStyle.italic,
fontSize: 16.0,
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.arrow_right_alt,
color: Colors.green, size: 28),
const SizedBox(width: 8),
Flexible(
child: Text(
"Swipe RIGHT to COMPLETE",
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.arrow_right_alt,
textDirection: TextDirection.rtl,
color: Colors.red,
size: 28),
const SizedBox(width: 8),
Flexible(
child: Text(
"Swipe LEFT to DELETE",
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
),
],
),
),
],
),
);
},
),
],
),
);

return targets;
}
8 changes: 8 additions & 0 deletions lib/app/utils/app_settings/save_tour_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ class SaveTourStatus {
static Future<bool> getManageTaskServerTourStatus() async {
return _preferences?.getBool('manage_task_server_tour') ?? false;
}

static Future saveTaskSwipeTutorialStatus(bool status) async {
await _preferences?.setBool('task_swipe_tutorial_completed', status);
}

static Future<bool> getTaskSwipeTutorialStatus() async {
return _preferences?.getBool('task_swipe_tutorial_completed') ?? false;
}
}
2 changes: 1 addition & 1 deletion macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import flutter_timezone
import package_info_plus
import path_provider_foundation
import shared_preferences_foundation
import sqflite_darwin
import sqflite
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
Expand Down
Loading
Loading