Skip to content

Commit 27a1eb7

Browse files
committed
delete profile tile added
patch 1
1 parent 9cd58b3 commit 27a1eb7

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

lib/app/modules/profile/views/profiles_list.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,20 @@ class ProfilesList extends StatelessWidget {
128128
copy(profileId);
129129
},
130130
),
131+
ListTile(
132+
leading: Icon(Icons.delete,
133+
color: AppSettings.isDarkMode
134+
? TaskWarriorColors.kprimaryTextColor
135+
: TaskWarriorColors.kLightPrimaryTextColor),
136+
title: Text('Delete Profile',
137+
style: TextStyle(
138+
color: AppSettings.isDarkMode
139+
? TaskWarriorColors.kprimaryTextColor
140+
: TaskWarriorColors.kLightPrimaryTextColor)),
141+
onTap: () {
142+
delete(profileId);
143+
},
144+
),
131145
],
132146
),
133147
);

lib/app/modules/splash/controllers/splash_controller.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,24 @@ class SplashController extends GetxController {
8585
currentProfile.value = _profiles.getCurrentProfile()!;
8686
}
8787

88+
void getMode(String profile) {
89+
_profiles.getMode(profile);
90+
profilesMap.value = _profiles.profilesMap();
91+
}
92+
93+
void changeModeTo(String profile, String mode) {
94+
_profiles.setModeTo(profile, mode);
95+
profilesMap.value = _profiles.profilesMap();
96+
}
97+
98+
Map<String, String?> getTaskcCreds(String profile) {
99+
return _profiles.getTaskcCreds(profile);
100+
}
101+
102+
void setTaskcCreds(String profile, String clientId, String clientSecret) {
103+
_profiles.setTaskcCreds(profile, clientId, clientSecret);
104+
}
105+
88106
Storage getStorage(String profile) {
89107
return _profiles.getStorage(profile);
90108
}

lib/app/utils/home_path/impl/taskchampion_config_file_paths.dart

Whitespace-only changes.

lib/app/utils/taskfunctions/profiles.dart

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,47 @@ class Profiles {
109109
return result;
110110
}
111111

112+
void setModeTo(String profile, String mode) {
113+
File('${base.path}/profiles/$profile/mode').writeAsStringSync(mode);
114+
}
115+
116+
String? getMode(String profile) {
117+
String? result;
118+
if (File('${base.path}/profiles/$profile/mode').existsSync()) {
119+
var contents =
120+
File('${base.path}/profiles/$profile/mode').readAsStringSync();
121+
result = (contents.isEmpty) ? null : contents;
122+
}
123+
return result;
124+
}
125+
126+
void setTaskcCreds(String profile, String clientId, String clientSecret) {
127+
File('${base.path}/profiles/$profile/taskc_client_id')
128+
.writeAsStringSync(clientId);
129+
File('${base.path}/profiles/$profile/taskc_client_secret')
130+
.writeAsStringSync(clientSecret);
131+
}
132+
133+
Map<String, String?> getTaskcCreds(String profile) {
134+
var result = <String, String?>{};
135+
if (File('${base.path}/profiles/$profile/taskc_client_id').existsSync()) {
136+
var contents = File('${base.path}/profiles/$profile/taskc_client_id')
137+
.readAsStringSync();
138+
result['client_id'] = (contents.isEmpty) ? null : contents;
139+
} else {
140+
result['client_id'] = null;
141+
}
142+
if (File('${base.path}/profiles/$profile/taskc_client_secret')
143+
.existsSync()) {
144+
var contents = File('${base.path}/profiles/$profile/taskc_client_secret')
145+
.readAsStringSync();
146+
result['client_secret'] = (contents.isEmpty) ? null : contents;
147+
} else {
148+
result['client_secret'] = null;
149+
}
150+
return result;
151+
}
152+
112153
void setCurrentProfile(String? profile) {
113154
File('${base.path}/current-profile').writeAsStringSync(profile ?? '');
114155
}

0 commit comments

Comments
 (0)