Skip to content

Commit

Permalink
Merge pull request #399 from SGI-CAPP-AT2/improve-add-tags
Browse files Browse the repository at this point in the history
feat: Improve tags add ux while adding task
  • Loading branch information
Pavel401 authored Dec 19, 2024
2 parents 309f3f2 + b2e8e0e commit 71614cd
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions lib/app/modules/home/views/add_task_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ class AddTaskBottomSheet extends StatelessWidget {
onFieldSubmitted: (tag) {
addTag(tag.trim());
},
onChanged: (value) {
String trimmedString = value.trim();
if (value.endsWith(" ") &&
trimmedString.split(' ').length == 1) {
addTag(trimmedString);
}
},
),
),
IconButton(
Expand Down Expand Up @@ -158,9 +165,9 @@ class AddTaskBottomSheet extends StatelessWidget {
),
validator: (name) => name != null && name.isEmpty
? SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskFieldCannotBeEmpty
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskFieldCannotBeEmpty
: null,
);

Expand Down Expand Up @@ -400,9 +407,9 @@ class AddTaskBottomSheet extends StatelessWidget {
TextButton(
child: Text(
SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskCancel,
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskCancel,
style: TextStyle(
color: AppSettings.isDarkMode
? TaskWarriorColors.white
Expand All @@ -425,8 +432,8 @@ class AddTaskBottomSheet extends StatelessWidget {
child: Text(
SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskAdd,
.sentences
.addTaskAdd,
style: TextStyle(
color: AppSettings.isDarkMode
? TaskWarriorColors.white
Expand Down Expand Up @@ -472,8 +479,8 @@ class AddTaskBottomSheet extends StatelessWidget {
content: Text(
SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskTaskAddedSuccessfully,
.sentences
.addTaskTaskAddedSuccessfully,
style: TextStyle(
color: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryTextColor
Expand Down Expand Up @@ -519,11 +526,19 @@ class AddTaskBottomSheet extends StatelessWidget {
void addTag(String tag) {
if (tag.isNotEmpty) {
String trimmedString = tag.trim();
homeController.tags.add(trimmedString);
List<String> tags = trimmedString.split(" ");
for(tag in tags){
if(checkTagIfExists(tag)) {
removeTag(tag);
}
homeController.tags.add(tag);
}
homeController.tagcontroller.text = '';
}
}

bool checkTagIfExists(String tag){
return homeController.tags.contains(tag);
}
void removeTag(String tag) {
homeController.tags.remove(tag);
}
Expand Down

0 comments on commit 71614cd

Please sign in to comment.