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

Add CCSync/Taskchampion support to the app #357

Merged
merged 26 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7d3d8e8
feat: add taskchampion sync
its-me-abhishek Jul 5, 2024
121596a
feat: add ccsync credentials to drawer
its-me-abhishek Jul 5, 2024
3aa305f
feat: add task views for taskc
its-me-abhishek Jul 5, 2024
5d59d03
feat: add task
its-me-abhishek Jul 5, 2024
1fd1c7a
feat: add reports and fix the broken reports tour
its-me-abhishek Jul 5, 2024
303ca10
fix: move reports_tour
its-me-abhishek Jul 5, 2024
373c8d8
feat: add project filter for taskc
its-me-abhishek Jul 5, 2024
07d9982
feat: add refresh tasks to the refresh button
its-me-abhishek Jul 5, 2024
0942a26
fix: api service
its-me-abhishek Jul 5, 2024
5193d44
feat: load tasks from Db anad sync tasks on init if enabled
its-me-abhishek Jul 5, 2024
d6a0a26
fix: update tasks without reload
its-me-abhishek Jul 5, 2024
06a71e7
feat: delete all tasks from DB
its-me-abhishek Jul 5, 2024
9246937
fix: reports tour
its-me-abhishek Jul 5, 2024
3e493df
fix: fixed linting issues
its-me-abhishek Jul 5, 2024
e5c9cce
fix: add languages for delete tasks
its-me-abhishek Jul 5, 2024
bdfbdbf
fix: fix merge conflict
its-me-abhishek Jul 5, 2024
0e9c5b5
fix: remove dependancy on redundant reports_tour_controller
its-me-abhishek Jul 6, 2024
7becfec
fix: make reports tour stateless
its-me-abhishek Jul 6, 2024
8aa5612
fix: fixed reports for taskc
its-me-abhishek Jul 6, 2024
1d09d36
fix: merge conflict
its-me-abhishek Jul 6, 2024
16722bf
feat: make taskchampion view stateless
its-me-abhishek Jul 6, 2024
1c2898f
fix: minor bug fix
its-me-abhishek Jul 6, 2024
5a7d7af
fix: move CredentialStorage
its-me-abhishek Jul 6, 2024
33a10cb
fix: make addtasktotaskc stateless
its-me-abhishek Jul 6, 2024
c190e1a
fix: complete and delete task logic
its-me-abhishek Jul 6, 2024
2d73068
feat: add confirmation dialog for task details
its-me-abhishek Jul 6, 2024
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
509 changes: 509 additions & 0 deletions lib/api_service.dart

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: depend_on_referenced_packages

import 'package:built_collection/built_collection.dart';
import 'package:get/get.dart';
import 'package:taskwarrior/app/modules/home/controllers/home_controller.dart';
Expand Down Expand Up @@ -46,7 +48,7 @@ class DetailRouteController extends GetxController {
// 'status': controller.modify.draft.status,
// 'entry': controller.modify.draft.entry,
// 'modified': controller.modify.draft.modified,
// 'start': controller.modify.draft.start,
// 'start': controller.modify.draft.start,
// 'end': controller.modify.draft.end,
// 'due': controller.dueValue.value,
// 'wait': controller.modify.draft.wait,
Expand Down
2 changes: 2 additions & 0 deletions lib/app/modules/detailRoute/views/detail_route_view.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: depend_on_referenced_packages, deprecated_member_use

import 'package:built_collection/built_collection.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
Expand Down
55 changes: 52 additions & 3 deletions lib/app/modules/home/controllers/home_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:get/get.dart';
import 'package:home_widget/home_widget.dart';
import 'package:loggy/loggy.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:taskwarrior/api_service.dart';
import 'package:taskwarrior/app/models/filters.dart';

import 'package:taskwarrior/app/models/json/task.dart';
Expand All @@ -22,6 +23,7 @@ import 'package:taskwarrior/app/tour/filter_drawer_tour.dart';
import 'package:taskwarrior/app/tour/home_page_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';
import 'package:taskwarrior/app/utils/taskfunctions/comparator.dart';
import 'package:taskwarrior/app/utils/taskfunctions/projects.dart';
import 'package:taskwarrior/app/utils/taskfunctions/query.dart';
Expand Down Expand Up @@ -49,6 +51,8 @@ class HomeController extends GetxController {
final Rx<SupportedLanguage> selectedLanguage = SupportedLanguage.english.obs;
final ScrollController scrollController = ScrollController();
final RxBool showbtn = false.obs;
late TaskDatabase taskdb;
var tasks = <Tasks>[].obs;

@override
void onInit() {
Expand All @@ -66,6 +70,45 @@ class HomeController extends GetxController {
if (Platform.isAndroid) {
handleHomeWidgetClicked();
}
taskdb = TaskDatabase();
taskdb.open();
getUniqueProjects();
_loadTaskChampion();
fetchTasksFromDB();
}

Future<List<String>> getUniqueProjects() async {
var taskDatabase = TaskDatabase();
List<String> uniqueProjects = await taskDatabase.fetchUniqueProjects();
debugPrint('Unique projects: $uniqueProjects');
return uniqueProjects;
}

Future<void> deleteAllTasksInDB() async {
var taskDatabase = TaskDatabase();
await taskDatabase.deleteAllTasksInDB();
debugPrint('Deleted all tasks from db');
}

Future<void> refreshTasks(String clientId, String encryptionSecret) async {
TaskDatabase taskDatabase = TaskDatabase();
await taskDatabase.open();
List<Tasks> tasksFromServer = await fetchTasks(clientId, encryptionSecret);
await updateTasksInDatabase(tasksFromServer);
List<Tasks> fetchedTasks = await taskDatabase.fetchTasksFromDatabase();
tasks.value = fetchedTasks;
}

Future<void> fetchTasksFromDB() async {
TaskDatabase taskDatabase = TaskDatabase();
await taskDatabase.open();
List<Tasks> fetchedTasks = await taskDatabase.fetchTasksFromDatabase();
tasks.value = fetchedTasks;
}

Future<void> _loadTaskChampion() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
taskchampion.value = prefs.getBool('taskchampion') ?? false;
}

void addListenerToScrollController() {
Expand Down Expand Up @@ -425,21 +468,25 @@ class HomeController extends GetxController {
final SharedPreferences prefs = await SharedPreferences.getInstance();
bool? value;
value = prefs.getBool('sync-onStart') ?? false;

String? clientId, encryptionSecret;
clientId = await CredentialsStorage.getClientId();
encryptionSecret = await CredentialsStorage.getEncryptionSecret();
if (value) {
synchronize(context, false);
refreshTasks(clientId!, encryptionSecret!);
} else {}
}

RxBool syncOnStart = false.obs;
RxBool syncOnTaskCreate = false.obs;
RxBool delaytask = false.obs;
RxBool change24hr = false.obs;
RxBool taskchampion = false.obs;

// dialogue box

final formKey = GlobalKey<FormState>();
final namecontroller = TextEditingController();
final projectcontroller = TextEditingController();
var due = Rxn<DateTime>();
RxString dueString = ''.obs;
RxString priority = 'M'.obs;
Expand Down Expand Up @@ -505,7 +552,7 @@ class HomeController extends GetxController {
void initLanguageAndDarkMode() {
isDarkModeOn.value = AppSettings.isDarkMode;
selectedLanguage.value = AppSettings.selectedLanguage;
print("called and value is${isDarkModeOn.value}");
// print("called and value is${isDarkModeOn.value}");
}

final addKey = GlobalKey();
Expand Down Expand Up @@ -557,6 +604,7 @@ class HomeController extends GetxController {

final GlobalKey statusKey = GlobalKey();
final GlobalKey projectsKey = GlobalKey();
final GlobalKey projectsKeyTaskc = GlobalKey();
final GlobalKey filterTagKey = GlobalKey();
final GlobalKey sortByKey = GlobalKey();

Expand All @@ -565,6 +613,7 @@ class HomeController extends GetxController {
targets: filterDrawer(
statusKey: statusKey,
projectsKey: projectsKey,
projectsKeyTaskc: projectsKeyTaskc,
filterTagKey: filterTagKey,
sortByKey: sortByKey,
),
Expand Down
11 changes: 5 additions & 6 deletions lib/app/modules/home/views/add_task_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -269,21 +269,21 @@ class AddTaskBottomSheet extends StatelessWidget {
initialTime: TimeOfDay.fromDateTime(
homeController.due.value ?? DateTime.now()),
);
print("date$date Time : $time");
// print("date$date Time : $time");
if (time != null) {
var dateTime = date.add(
Duration(
hours: time.hour,
minutes: time.minute,
),
);
print(dateTime);
// print(dateTime);
homeController.due.value = dateTime.toUtc();

print("due value ${homeController.due}");
// print("due value ${homeController.due}");
homeController.dueString.value =
DateFormat("dd-MM-yyyy HH:mm").format(dateTime);
print(homeController.dueString.value);
// print(homeController.dueString.value);
if (dateTime.isBefore(DateTime.now())) {
//Try changing the color. in the settings and Due display.

Expand Down Expand Up @@ -391,7 +391,6 @@ class AddTaskBottomSheet extends StatelessWidget {
);

Widget buildAddButton(BuildContext context) {

return TextButton(
child: Text(
"Add",
Expand All @@ -402,7 +401,7 @@ class AddTaskBottomSheet extends StatelessWidget {
),
),
onPressed: () async {
print(homeController.formKey.currentState);
// print(homeController.formKey.currentState);
if (homeController.formKey.currentState!.validate()) {
try {
var task = taskParser(homeController.namecontroller.text)
Expand Down
Loading
Loading