Skip to content

Commit 464c33a

Browse files
authored
Merge branch 'main' into add-api-url-manually-issue
2 parents 94447d3 + 7bb38b1 commit 464c33a

34 files changed

+1206
-218
lines changed

CONTRIBUTING.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ flutter doctor
3535
flutter pub get
3636
```
3737

38-
%. Run the app:
38+
5. Run the app:
3939

4040
```bash
4141
flutter run
@@ -60,9 +60,17 @@ ___
6060
## Contributing
6161

6262
1. Fork the Project
63-
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
64-
2. Create your Fix Branch (`git checkout -b fix/BugFix`)
65-
3. Add all files(`git add .`)
66-
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
67-
4. Push to the Branch (`git push origin feature/AmazingFeature`)
68-
5. Open a Pull Request in the **develop branch**
63+
2. Clone the Forked Repo. `git clone https://github.com/[username]/taskwarrior-flutter.git`
64+
3. Create a branch
65+
- For your Feature Branch (`git checkout -b feature/AmazingFeature`)
66+
- For your Fix Branch (`git checkout -b fix/BugFix`)
67+
4. Do the changes in that branch
68+
5. Add all files (`git add .`)
69+
- Do Not add files generated by code editor of Android Studio IDE
70+
- Only add files that related to your feature
71+
6. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
72+
7. Make sure branch is synced with main branch of `CCExtractor/taskwarrior-flutter`
73+
- If not, please sync it and test again
74+
- If any conflict, resolve according to feature and test again
75+
7. Push to the Branch (`git push origin feature/AmazingFeature`)
76+
8. Open a Pull Request for the `main` branch.

lib/api_service.dart

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,23 @@ String origin = 'http://localhost:8080';
7070

7171
Future<List<Tasks>> fetchTasks(String uuid, String encryptionSecret) async {
7272
var baseUrl = await CredentialsStorage.getApiUrl();
73-
String url =
74-
'$baseUrl/tasks?email=email&origin=$origin&UUID=$uuid&encryptionSecret=$encryptionSecret';
75-
76-
var response = await http.get(Uri.parse(url), headers: {
77-
"Content-Type": "application/json",
78-
}).timeout(const Duration(seconds: 10000));
79-
if (response.statusCode == 200) {
80-
List<dynamic> allTasks = jsonDecode(response.body);
81-
debugPrint(allTasks.toString());
82-
return allTasks.map((task) => Tasks.fromJson(task)).toList();
83-
} else {
84-
throw Exception('Failed to load tasks');
73+
try {
74+
String url =
75+
'$baseUrl/tasks?email=email&origin=$origin&UUID=$uuid&encryptionSecret=$encryptionSecret';
76+
77+
var response = await http.get(Uri.parse(url), headers: {
78+
"Content-Type": "application/json",
79+
}).timeout(const Duration(seconds: 10000));
80+
if (response.statusCode == 200) {
81+
List<dynamic> allTasks = jsonDecode(response.body);
82+
debugPrint(allTasks.toString());
83+
return allTasks.map((task) => Tasks.fromJson(task)).toList();
84+
} else {
85+
throw Exception('Failed to load tasks');
86+
}
87+
} catch (e) {
88+
debugPrint('Error fetching tasks: $e');
89+
return [];
8590
}
8691
}
8792

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class DetailRouteController extends GetxController {
3434
void setAttribute(String name, dynamic newValue) {
3535
modify.set(name, newValue);
3636
onEdit.value = true;
37+
if(name == 'start'){
38+
debugPrint('Start Value Changed to $newValue');
39+
startValue.value = newValue;
40+
}
3741
initValues();
3842
}
3943

@@ -82,7 +86,7 @@ class DetailRouteController extends GetxController {
8286
statusValue.value = modify.draft.status;
8387
entryValue.value = modify.draft.entry;
8488
modifiedValue.value = modify.draft.modified;
85-
startValue.value = modify.draft.start;
89+
startValue.value ??= null;
8690
endValue.value = modify.draft.end;
8791
dueValue.value = modify.draft.due;
8892
waitValue.value = modify.draft.wait;

lib/app/modules/home/controllers/home_controller.dart

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class HomeController extends GetxController {
5656
final RxBool showbtn = false.obs;
5757
late TaskDatabase taskdb;
5858
var tasks = <Tasks>[].obs;
59+
final RxBool isRefreshing = false.obs;
5960

6061
@override
6162
void onInit() {
@@ -78,21 +79,20 @@ class HomeController extends GetxController {
7879
handleHomeWidgetClicked();
7980
}
8081
fetchTasksFromDB();
81-
everAll([
82+
everAll([
8283
pendingFilter,
8384
waitingFilter,
8485
projectFilter,
8586
tagUnion,
8687
selectedSort,
8788
selectedTags,
8889
], (_) {
89-
if (Platform.isAndroid) {
90-
WidgetController widgetController =
91-
Get.put(WidgetController());
92-
widgetController.fetchAllData();
90+
if (Platform.isAndroid) {
91+
WidgetController widgetController = Get.put(WidgetController());
92+
widgetController.fetchAllData();
9393

94-
widgetController.update();
95-
}
94+
widgetController.update();
95+
}
9696
});
9797
}
9898

@@ -508,7 +508,15 @@ class HomeController extends GetxController {
508508
final projectcontroller = TextEditingController();
509509
var due = Rxn<DateTime>();
510510
RxString dueString = ''.obs;
511-
RxString priority = 'M'.obs;
511+
final priorityList = ['L', 'X', 'M', 'H'];
512+
final priorityColors = [
513+
TaskWarriorColors.green,
514+
TaskWarriorColors.grey,
515+
TaskWarriorColors.yellow,
516+
TaskWarriorColors.red,
517+
];
518+
RxString priority = 'X'.obs;
519+
512520
final tagcontroller = TextEditingController();
513521
RxList<String> tags = <String>[].obs;
514522
RxBool inThePast = false.obs;
@@ -571,10 +579,9 @@ class HomeController extends GetxController {
571579
void initLanguageAndDarkMode() {
572580
isDarkModeOn.value = AppSettings.isDarkMode;
573581
selectedLanguage.value = AppSettings.selectedLanguage;
574-
HomeWidget.saveWidgetData("themeMode", AppSettings.isDarkMode ? "dark" : "light");
575-
HomeWidget.updateWidget(
576-
androidName: "TaskWarriorWidgetProvider"
577-
);
582+
HomeWidget.saveWidgetData(
583+
"themeMode", AppSettings.isDarkMode ? "dark" : "light");
584+
HomeWidget.updateWidget(androidName: "TaskWarriorWidgetProvider");
578585
// print("called and value is${isDarkModeOn.value}");
579586
}
580587

@@ -668,6 +675,7 @@ class HomeController extends GetxController {
668675
},
669676
);
670677
}
678+
671679
late RxString uuid = "".obs;
672680
late RxBool isHomeWidgetTaskTapped = false.obs;
673681

@@ -682,7 +690,7 @@ class HomeController extends GetxController {
682690
Get.toNamed(Routes.DETAIL_ROUTE, arguments: ["uuid", uuid.value]);
683691
});
684692
}
685-
}else if(uri.host == "addclicked"){
693+
} else if (uri.host == "addclicked") {
686694
showAddDialogAfterWidgetClick();
687695
}
688696
}
@@ -695,15 +703,17 @@ class HomeController extends GetxController {
695703
}
696704
debugPrint('uuid is $uuid');
697705
Get.toNamed(Routes.DETAIL_ROUTE, arguments: ["uuid", uuid.value]);
698-
}else if(uri.host == "addclicked"){
706+
} else if (uri.host == "addclicked") {
699707
showAddDialogAfterWidgetClick();
700708
}
701709
}
702-
703710
});
704711
}
712+
705713
void showAddDialogAfterWidgetClick() {
706-
Widget showDialog = taskchampion.value ? AddTaskToTaskcBottomSheet(homeController: this) : AddTaskBottomSheet(homeController: this);
714+
Widget showDialog = taskchampion.value
715+
? AddTaskToTaskcBottomSheet(homeController: this)
716+
: AddTaskBottomSheet(homeController: this);
707717
Get.dialog(showDialog);
708718
}
709719
}

lib/app/modules/home/views/add_task_bottom_sheet.dart

Lines changed: 70 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class AddTaskBottomSheet extends StatelessWidget {
250250
},
251251
fieldHintText: "Month/Date/Year",
252252
context: context,
253-
initialDate: homeController.due.value ?? DateTime.now(),
253+
initialDate: homeController.due.value?? DateTime.now(),
254254
firstDate: DateTime.now(),
255255
lastDate: DateTime(2037, 12, 31),
256256
);
@@ -305,7 +305,7 @@ class AddTaskBottomSheet extends StatelessWidget {
305305
),
306306
);
307307
// print(dateTime);
308-
homeController.due.value = dateTime.toUtc();
308+
homeController.due.value = dateTime;
309309

310310
// print("due value ${homeController.due}");
311311
homeController.dueString.value =
@@ -367,34 +367,52 @@ class AddTaskBottomSheet extends StatelessWidget {
367367
),
368368
textAlign: TextAlign.left,
369369
),
370+
const SizedBox(width: 2,),
370371
Obx(
371-
() => DropdownButton<String>(
372-
dropdownColor: AppSettings.isDarkMode
373-
? TaskWarriorColors.kdialogBackGroundColor
374-
: TaskWarriorColors.kLightDialogBackGroundColor,
375-
value: homeController.priority.value,
376-
elevation: 16,
377-
style: GoogleFonts.poppins(
378-
color: AppSettings.isDarkMode
379-
? TaskWarriorColors.white
380-
: TaskWarriorColors.black,
381-
),
382-
underline: Container(
383-
height: 1.5,
384-
color: AppSettings.isDarkMode
385-
? TaskWarriorColors.kdialogBackGroundColor
386-
: TaskWarriorColors.kLightDialogBackGroundColor,
387-
),
388-
onChanged: (String? newValue) {
389-
homeController.priority.value = newValue!;
390-
},
391-
items: <String>['H', 'M', 'L', 'None']
392-
.map<DropdownMenuItem<String>>((String value) {
393-
return DropdownMenuItem<String>(
394-
value: value,
395-
child: Text(' $value'),
396-
);
397-
}).toList(),
372+
() => Row(
373+
children: [
374+
for(int i=0;i<homeController.priorityList.length;i++)
375+
Padding(
376+
padding: const EdgeInsets.symmetric(horizontal: 2.5),
377+
child: GestureDetector(
378+
onTap: () {
379+
homeController.priority.value = homeController.priorityList[i];
380+
debugPrint(homeController.priority.value);
381+
},
382+
child: AnimatedContainer(
383+
duration: const Duration(milliseconds: 100),
384+
height: 30,
385+
width: 37,
386+
decoration: BoxDecoration(
387+
388+
borderRadius: BorderRadius.circular(8),
389+
border: Border.all(
390+
color: homeController.priority.value == homeController.priorityList[i]
391+
? AppSettings.isDarkMode
392+
? TaskWarriorColors.kLightPrimaryBackgroundColor
393+
: TaskWarriorColors.kprimaryBackgroundColor
394+
: AppSettings.isDarkMode
395+
? TaskWarriorColors.kprimaryBackgroundColor
396+
: TaskWarriorColors.kLightPrimaryBackgroundColor,
397+
)
398+
),
399+
child: Center(
400+
child: Text(
401+
homeController.priorityList[i],
402+
textAlign: TextAlign.center,
403+
style: GoogleFonts.poppins(
404+
fontWeight: FontWeight.bold,
405+
fontSize: 17,
406+
color: homeController.priorityColors[i]
407+
),
408+
),
409+
),
410+
),
411+
412+
),
413+
)
414+
415+
],
398416
),
399417
)
400418
],
@@ -442,10 +460,31 @@ class AddTaskBottomSheet extends StatelessWidget {
442460
),
443461
onPressed: () async {
444462
// print(homeController.formKey.currentState);
463+
if(homeController.due.value!=null&&DateTime.now().isAfter(homeController.due.value!)){
464+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
465+
content: Text(
466+
SentenceManager(
467+
currentLanguage:
468+
homeController.selectedLanguage.value)
469+
.sentences
470+
.addTaskTimeInPast,
471+
style: TextStyle(
472+
color: AppSettings.isDarkMode
473+
? TaskWarriorColors.kprimaryTextColor
474+
: TaskWarriorColors.kLightPrimaryTextColor,
475+
),
476+
),
477+
backgroundColor: AppSettings.isDarkMode
478+
? TaskWarriorColors.ksecondaryBackgroundColor
479+
: TaskWarriorColors
480+
.kLightSecondaryBackgroundColor,
481+
duration: const Duration(seconds: 2)));
482+
return;
483+
}
445484
if (homeController.formKey.currentState!.validate()) {
446485
try {
447486
var task = taskParser(homeController.namecontroller.text)
448-
.rebuild((b) => b..due = homeController.due.value)
487+
.rebuild((b) => b..due = homeController.due.value?.toUtc())
449488
.rebuild((p) => p..priority = homeController.priority.value);
450489
if (homeController.tagcontroller.text != "") {
451490
homeController.tags.add(homeController.tagcontroller.text.trim());
@@ -462,6 +501,7 @@ class AddTaskBottomSheet extends StatelessWidget {
462501
homeController.priority.value = 'M';
463502
homeController.tagcontroller.text = '';
464503
homeController.tags.value = [];
504+
homeController.due.value=null;
465505
homeController.update();
466506
// Navigator.of(context).pop();
467507
Get.back();

0 commit comments

Comments
 (0)