@@ -20,6 +20,7 @@ import 'package:path/path.dart' as path;
2020
2121import 'package:taskwarrior/app/modules/splash/controllers/splash_controller.dart' ;
2222import 'package:taskwarrior/app/utils/themes/theme_extension.dart' ;
23+ import 'package:taskwarrior/app/v3/db/task_database.dart' ;
2324
2425class SettingsController extends GetxController {
2526 RxBool isMovingDirectory = false .obs;
@@ -46,71 +47,72 @@ class SettingsController extends GetxController {
4647 }
4748
4849 void pickDirectory (BuildContext context) {
49- TaskwarriorColorTheme tColors = Theme .of (context).extension < TaskwarriorColorTheme > ()! ;
50+ TaskwarriorColorTheme tColors =
51+ Theme .of (context).extension < TaskwarriorColorTheme > ()! ;
5052 FilePicker .platform.getDirectoryPath ().then ((value) async {
5153 if (value != null ) {
5254 isMovingDirectory.value = true ;
5355 update ();
5456 // InheritedProfiles profilesWidget = ProfilesWidget.of(context);
5557 var profilesWidget = Get .find <SplashController >();
5658 Directory source = profilesWidget.baseDirectory ();
57- Directory destination = Directory (value);
59+ Directory destination = Directory (value);
5860 moveDirectory (source.path, destination.path).then ((value) async {
5961 isMovingDirectory.value = false ;
6062 update ();
6163 if (value == "same" ) {
6264 return ;
63- } else if (value == "success" ) {
65+ } else if (value == "success" ) {
6466 profilesWidget.setBaseDirectory (destination);
6567 SharedPreferences prefs = await SharedPreferences .getInstance ();
6668 prefs.setString ('baseDirectory' , destination.path);
6769 baseDirectory.value = destination.path;
68- Get .snackbar (
69- 'Success' ,
70- 'Base directory moved successfully' ,
71- snackPosition: SnackPosition .BOTTOM ,
72- duration: const Duration (seconds: 2 ),
73- );
74- } else {
75- Get .dialog (
76- Utils .showAlertDialog (
77- title: Text (
78- 'Error' ,
79- style: GoogleFonts .poppins (
80- fontWeight: FontWeight .bold,
81- fontSize: TaskWarriorFonts .fontSizeMedium,
82- color: tColors.primaryTextColor,
83- ),
70+ Get .snackbar (
71+ 'Success' ,
72+ 'Base directory moved successfully' ,
73+ snackPosition: SnackPosition .BOTTOM ,
74+ duration: const Duration (seconds: 2 ),
75+ );
76+ } else {
77+ Get .dialog (
78+ Utils .showAlertDialog (
79+ title: Text (
80+ 'Error' ,
81+ style: GoogleFonts .poppins (
82+ fontWeight: FontWeight .bold,
83+ fontSize: TaskWarriorFonts .fontSizeMedium,
84+ color: tColors.primaryTextColor,
8485 ),
85- content : Text (
86- value == "nested"
87- ? "Cannot move to a nested directory "
88- : value == "not-empty "
89- ? "Destination directory is not empty"
90- : value == " not-permitted "
91- ? "Selected folder can't be written to (Android SAF). Please choose a different folder. "
92- : "An error occurred" ,
93- style : GoogleFonts . poppins (
94- color : TaskWarriorColors .grey,
95- fontSize : TaskWarriorFonts .fontSizeSmall ,
96- ) ,
86+ ),
87+ content : Text (
88+ value == " nested"
89+ ? "Cannot move to a nested directory "
90+ : value == " not- empty"
91+ ? "Destination directory is not empty "
92+ : value == "not-permitted "
93+ ? "Selected folder can't be written to (Android SAF). Please choose a different folder."
94+ : "An error occurred" ,
95+ style : GoogleFonts . poppins (
96+ color : TaskWarriorColors .grey ,
97+ fontSize : TaskWarriorFonts .fontSizeSmall ,
9798 ),
98- actions: [
99- TextButton (
100- onPressed: () {
101- Get .back ();
102- },
103- child: Text (
104- 'OK' ,
105- style: GoogleFonts .poppins (
106- color: tColors.primaryTextColor,
107- ),
108- ),
109- )
110- ],
11199 ),
112- );
113- }
100+ actions: [
101+ TextButton (
102+ onPressed: () {
103+ Get .back ();
104+ },
105+ child: Text (
106+ 'OK' ,
107+ style: GoogleFonts .poppins (
108+ color: tColors.primaryTextColor,
109+ ),
110+ ),
111+ )
112+ ],
113+ ),
114+ );
115+ }
114116 });
115117 }
116118 });
@@ -125,9 +127,9 @@ class SettingsController extends GetxController {
125127 return "nested" ;
126128 }
127129
128- Directory toDir = Directory (toDirectory);
129- // Ensure destination exists before checking contents
130- await toDir.create (recursive: true );
130+ Directory toDir = Directory (toDirectory);
131+ // Ensure destination exists before checking contents
132+ await toDir.create (recursive: true );
131133 final length = await toDir.list ().length;
132134 if (length > 0 ) {
133135 return "not-empty" ;
@@ -143,7 +145,10 @@ class SettingsController extends GetxController {
143145 } on FileSystemException catch (e) {
144146 // Map common permission error to a friendly status
145147 if (e.osError? .errorCode == 1 ||
146- (e.osError? .message.toLowerCase ().contains ("operation not permitted" ) ?? false )) {
148+ (e.osError? .message
149+ .toLowerCase ()
150+ .contains ("operation not permitted" ) ??
151+ false )) {
147152 return "not-permitted" ;
148153 }
149154 return "error" ;
@@ -156,7 +161,10 @@ class SettingsController extends GetxController {
156161 return "success" ;
157162 } on FileSystemException catch (e) {
158163 if (e.osError? .errorCode == 1 ||
159- (e.osError? .message.toLowerCase ().contains ("operation not permitted" ) ?? false )) {
164+ (e.osError? .message
165+ .toLowerCase ()
166+ .contains ("operation not permitted" ) ??
167+ false )) {
160168 return "not-permitted" ;
161169 }
162170 return "error" ;
@@ -200,6 +208,12 @@ class SettingsController extends GetxController {
200208 }
201209 }
202210
211+ Future <void > deleteAllTasksInDB () async {
212+ var taskDatabase = TaskDatabase ();
213+ await taskDatabase.deleteAllTasksInDB ();
214+ debugPrint ('Deleted all tasks from db' );
215+ }
216+
203217 RxBool isSyncOnStartActivel = false .obs;
204218 RxBool isSyncOnTaskCreateActivel = false .obs;
205219 RxBool delaytask = false .obs;
0 commit comments