diff --git a/lib/app/modules/profile/views/deleteprofiledialog.dart b/lib/app/modules/profile/views/deleteprofiledialog.dart index 0ccdc9a0..7aea5220 100644 --- a/lib/app/modules/profile/views/deleteprofiledialog.dart +++ b/lib/app/modules/profile/views/deleteprofiledialog.dart @@ -11,12 +11,15 @@ class DeleteProfileDialog extends StatelessWidget { const DeleteProfileDialog({ required this.profile, required this.context, + required this.profiles, + required this.profileName, super.key, }); final String profile; final BuildContext context; - + final RxMap profiles; + final String? profileName; @override Widget build(BuildContext context) { return Center( @@ -25,10 +28,9 @@ class DeleteProfileDialog extends StatelessWidget { child: Utils.showAlertDialog( scrollable: true, title: Text( - SentenceManager( - currentLanguage: AppSettings.selectedLanguage) - .sentences - .profilePageDeleteProfile, + SentenceManager(currentLanguage: AppSettings.selectedLanguage) + .sentences + .profilePageDeleteProfile, style: TextStyle( color: AppSettings.isDarkMode ? TaskWarriorColors.white @@ -39,7 +41,8 @@ class DeleteProfileDialog extends StatelessWidget { actions: [ TextButton( onPressed: () { - // Navigator.of(context).pop(); + debugPrint("PROFILE$profile${profileName!}"); + profiles[profile] = profileName; Get.back(); }, child: Text( diff --git a/lib/app/modules/profile/views/manageprofile.dart b/lib/app/modules/profile/views/manageprofile.dart deleted file mode 100644 index b5b40a3a..00000000 --- a/lib/app/modules/profile/views/manageprofile.dart +++ /dev/null @@ -1,117 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; - -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; -import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; - -import 'package:tuple/tuple.dart'; - -class ManageProfile extends StatelessWidget { - const ManageProfile( - this.rename, - this.configure, - this.export, - this.copy, - this.delete, { - required this.manageSelectedProfileKey, - super.key, - }); - - final void Function() rename; - final void Function() configure; - final void Function() export; - final void Function() copy; - final void Function() delete; - final GlobalKey manageSelectedProfileKey; - - @override - Widget build(BuildContext context) { - var triples = [ - Tuple3( - Icons.edit, - SentenceManager(currentLanguage: AppSettings.selectedLanguage) - .sentences - .profilePageRenameAlias, - rename, - ), - Tuple3( - Icons.link, - SentenceManager(currentLanguage: AppSettings.selectedLanguage) - .sentences - .profilePageConfigureTaskserver, - configure, - ), - Tuple3( - Icons.upload, - SentenceManager(currentLanguage: AppSettings.selectedLanguage) - .sentences - .profilePageExportTasks, - export, - ), - Tuple3( - Icons.copy, - SentenceManager(currentLanguage: AppSettings.selectedLanguage) - .sentences - .profilePageCopyConfigToNewProfile, - copy, - ), - Tuple3( - Icons.delete, - SentenceManager(currentLanguage: AppSettings.selectedLanguage) - .sentences - .profilePageDeleteProfile, - delete, - ), - ]; - - return ExpansionTile( - key: manageSelectedProfileKey, - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, - iconColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - collapsedIconColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - collapsedTextColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.ksecondaryBackgroundColor, - textColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - title: Text( - SentenceManager(currentLanguage: AppSettings.selectedLanguage) - .sentences - .profilePageManageSelectedProfile, - style: GoogleFonts.poppins( - fontWeight: TaskWarriorFonts.bold, - fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - ), - ), - children: [ - for (var triple in triples) - ListTile( - textColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryTextColor - : TaskWarriorColors.kLightSecondaryTextColor, - iconColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.kLightSecondaryTextColor, - leading: Padding( - padding: const EdgeInsets.all(12), - child: Icon(triple.item1), - ), - title: Text(triple.item2), - onTap: triple.item3, - ) - ], - ); - } -} diff --git a/lib/app/modules/profile/views/profile_view.dart b/lib/app/modules/profile/views/profile_view.dart index 8a224b6d..b2123244 100644 --- a/lib/app/modules/profile/views/profile_view.dart +++ b/lib/app/modules/profile/views/profile_view.dart @@ -4,9 +4,8 @@ import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:taskwarrior/app/models/storage/savefile.dart'; import 'package:taskwarrior/app/modules/profile/views/deleteprofiledialog.dart'; -import 'package:taskwarrior/app/modules/profile/views/manageprofile.dart'; +import 'package:taskwarrior/app/modules/profile/views/profiles_list.dart'; import 'package:taskwarrior/app/modules/profile/views/renameprofiledialog.dart'; -import 'package:taskwarrior/app/modules/profile/views/selectprofile.dart'; import 'package:taskwarrior/app/routes/app_pages.dart'; import 'package:taskwarrior/app/utils/constants/palette.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; @@ -21,6 +20,7 @@ class ProfileView extends GetView { const ProfileView({super.key}); @override Widget build(BuildContext context) { + debugPrint("Controller Value: ${controller.currentProfile.value}"); controller.initProfilePageTour(); controller.showProfilePageTour(context); return Scaffold( @@ -42,8 +42,6 @@ class ProfileView extends GetView { )), leading: IconButton( onPressed: () { - // Navigator.pushReplacementNamed(context, PageRoutes.home); - // Navigator.of(context).pop(); Get.back(); }, icon: Icon( @@ -52,293 +50,172 @@ class ProfileView extends GetView { size: 30, ), ), + actions: [ + TextButton( + onPressed: controller.profilesWidget.addProfile, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + Icons.add, + color: Colors.white, + ), + const SizedBox( + width: 10, + ), + Text('Add Profile', style: TextStyle(color: Colors.white)), + ], + ), + ), + ], ), - //primary: false, backgroundColor: AppSettings.isDarkMode ? TaskWarriorColors.kprimaryBackgroundColor : TaskWarriorColors.kLightPrimaryBackgroundColor, - body: SingleChildScrollView( - child: Column( - children: [ - Obx( - () => ProfilesColumn( - currentProfileKey: controller.currentProfileKey, - addNewProfileKey: controller.addNewProfileKey, - manageSelectedProfileKey: controller.manageSelectedProfileKey, - controller.profilesMap, - controller.currentProfile.value, - controller.profilesWidget.addProfile, - controller.profilesWidget.selectProfile, - () => showDialog( + body: Obx(() => ProfilesList( + currentProfileKey: controller.currentProfileKey, + addNewProfileKey: controller.addNewProfileKey, + manageSelectedProfileKey: controller.manageSelectedProfileKey, + controller.profilesMap, + controller.currentProfile.value, + controller.profilesWidget.addProfile, + controller.profilesWidget.selectProfile, + (profile) => showDialog( + context: context, + builder: (context) => Center( + child: RenameProfileDialog( + profile: profile, + alias: + controller.profilesMap[controller.currentProfile.value], context: context, - builder: (context) => Center( - child: RenameProfileDialog( - profile: controller.currentProfile.value, - alias: controller - .profilesMap[controller.currentProfile.value], - context: context, - ), - ), ), - // () => Navigator.push( - // context, - // MaterialPageRoute( - // // builder: (_) => const ConfigureTaskserverRoute(), - // builder: (_) => const ManageTaskServerView(), - // ), - // ), - () => Get.toNamed(Routes.MANAGE_TASK_SERVER), - () { - var tasks = controller.profilesWidget - .getStorage(controller.currentProfile.value) - .data - .export(); - var now = DateTime.now() - .toIso8601String() - .replaceAll(RegExp(r'[-:]'), '') - .replaceAll(RegExp(r'\..*'), ''); + ), + ), + () => Get.toNamed(Routes.MANAGE_TASK_SERVER), + (profile) { + var tasks = + controller.profilesWidget.getStorage(profile).data.export(); + var now = DateTime.now() + .toIso8601String() + .replaceAll(RegExp(r'[-:]'), '') + .replaceAll(RegExp(r'\..*'), ''); - showDialog( - context: context, - builder: (BuildContext context) { - return Utils.showAlertDialog( - title: Text( - SentenceManager( - currentLanguage: AppSettings.selectedLanguage) - .sentences - .profilePageExportTasksDialogueTitle, + showDialog( + context: context, + builder: (BuildContext context) { + return Utils.showAlertDialog( + title: Text( + SentenceManager( + currentLanguage: AppSettings.selectedLanguage) + .sentences + .profilePageExportTasksDialogueTitle, + style: TextStyle( + color: AppSettings.isDarkMode + ? TaskWarriorColors.white + : TaskWarriorColors.black, + ), + ), + content: Text( + SentenceManager( + currentLanguage: AppSettings.selectedLanguage) + .sentences + .profilePageExportTasksDialogueSubtitle, + style: TextStyle( + color: AppSettings.isDarkMode + ? TaskWarriorColors.white + : TaskWarriorColors.black, + ), + ), + actions: [ + TextButton( + child: Text( + "JSON", style: TextStyle( color: AppSettings.isDarkMode ? TaskWarriorColors.white : TaskWarriorColors.black, ), ), - content: Text( - SentenceManager( - currentLanguage: AppSettings.selectedLanguage) - .sentences - .profilePageExportTasksDialogueSubtitle, + onPressed: () { + // Navigator.of(context).pop(); + Get.back(); + exportTasks( + contents: tasks, + suggestedName: 'tasks-$now.json', + ); + }, + ), + TextButton( + child: Text( + "TXT", style: TextStyle( color: AppSettings.isDarkMode ? TaskWarriorColors.white : TaskWarriorColors.black, ), ), - actions: [ - TextButton( - child: Text( - "JSON", - style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - ), - ), - onPressed: () { - // Navigator.of(context).pop(); - Get.back(); - exportTasks( - contents: tasks, - suggestedName: 'tasks-$now.json', - ); - }, - ), - TextButton( - child: Text( - "TXT", - style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - ), - ), - onPressed: () { - // Navigator.of(context).pop(); - Get.back(); - exportTasks( - contents: tasks, - suggestedName: 'tasks-$now.txt', - ); - }, - ), - ], - ); - }, + onPressed: () { + // Navigator.of(context).pop(); + Get.back(); + exportTasks( + contents: tasks, + suggestedName: 'tasks-$now.txt', + ); + }, + ), + ], ); }, - () { - try { - controller.profilesWidget.copyConfigToNewProfile( - controller.currentProfile.value, - ); - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text( - 'Profile Config Copied', - style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - ), - ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, - duration: const Duration(seconds: 2))); - } catch (e) { - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text( - 'Profile Config Copy Failed', - style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - ), - ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, - duration: const Duration(seconds: 2))); - } - }, - () => showDialog( - context: context, - builder: (context) => DeleteProfileDialog( - profile: controller.currentProfile.value, - context: context, - ), - ), - ), - ), - ], - ), - ), - ); - } -} - -class ProfilesColumn extends StatelessWidget { - const ProfilesColumn( - this.profilesMap, - this.currentProfile, - this.addProfile, - this.selectProfile, - this.rename, - this.configure, - this.export, - this.copy, - this.delete, { - required this.currentProfileKey, - required this.addNewProfileKey, - required this.manageSelectedProfileKey, - super.key, - }); - - final Map profilesMap; - final String currentProfile; - final void Function() addProfile; - final void Function(String) selectProfile; - final void Function() rename; - final void Function() configure; - final void Function() export; - final void Function() copy; - final void Function() delete; - final GlobalKey currentProfileKey; - final GlobalKey addNewProfileKey; - final GlobalKey manageSelectedProfileKey; - - @override - Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.only(top: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SelectProfile( - currentProfile, - profilesMap, - selectProfile, - currentProfileKey: currentProfileKey, - ), - const SizedBox( - height: 6, - ), - ManageProfile( - rename, - configure, - export, - copy, - delete, - manageSelectedProfileKey: manageSelectedProfileKey, - ), - const SizedBox( - height: 6, - ), - ElevatedButton.icon( - key: addNewProfileKey, - onPressed: () { + ); + }, + (profile) { try { - addProfile(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - 'Profile Added Successfully', - style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, - ), - ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, - duration: const Duration(seconds: 2)), + controller.profilesWidget.copyConfigToNewProfile( + profile, ); - // Get.find().update(); + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text( + 'Profile Config Copied', + style: TextStyle( + color: AppSettings.isDarkMode + ? TaskWarriorColors.white + : TaskWarriorColors.black, + ), + ), + backgroundColor: AppSettings.isDarkMode + ? TaskWarriorColors.ksecondaryBackgroundColor + : TaskWarriorColors.kLightSecondaryBackgroundColor, + duration: const Duration(seconds: 2))); } catch (e) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( + ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text( - 'Profile Additon Failed', + 'Profile Config Copy Failed', style: TextStyle( color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + ? TaskWarriorColors.white + : TaskWarriorColors.black, ), ), backgroundColor: AppSettings.isDarkMode ? TaskWarriorColors.ksecondaryBackgroundColor : TaskWarriorColors.kLightSecondaryBackgroundColor, - duration: const Duration(seconds: 2), - ), - ); + duration: const Duration(seconds: 2))); } }, - style: ButtonStyle( - backgroundColor: WidgetStateProperty.all( - AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, - ), - ), - icon: Icon(Icons.add, - color: AppSettings.isDarkMode - ? TaskWarriorColors.deepPurpleAccent - : TaskWarriorColors.deepPurple), - label: Text( - SentenceManager( - currentLanguage: AppSettings.selectedLanguage) - .sentences - .profilePageAddNewProfile, - - style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - ), - ), - ) - ], - ), + (profile) { + String? profileName = controller.profilesMap[profile]; + controller.profilesMap.remove(profile); + showDialog( + context: context, + builder: (context) => DeleteProfileDialog( + profile: profile, + context: context, + profiles: controller.profilesMap, + profileName: profileName, + ), + ); + }, + )), ); } } diff --git a/lib/app/modules/profile/views/profiles_list.dart b/lib/app/modules/profile/views/profiles_list.dart new file mode 100644 index 00000000..0f0c90f1 --- /dev/null +++ b/lib/app/modules/profile/views/profiles_list.dart @@ -0,0 +1,137 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; +import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; + +class ProfilesList extends StatelessWidget { + const ProfilesList( + this.profilesMap, + this.currentProfile, + this.addProfile, + this.selectProfile, + this.rename, + this.configure, + this.export, + this.copy, + this.delete, { + required this.currentProfileKey, + required this.addNewProfileKey, + required this.manageSelectedProfileKey, + super.key, + }); + + final RxMap profilesMap; + final String currentProfile; + final void Function() addProfile; + final void Function(String) selectProfile; + final void Function(String) rename; + final void Function() configure; + final void Function(String) export; + final void Function(String) copy; + final void Function(dynamic) delete; + final GlobalKey currentProfileKey; + final GlobalKey addNewProfileKey; + final GlobalKey manageSelectedProfileKey; + + @override + Widget build(BuildContext context) { + return Obx(() => ListView.builder( + itemCount: profilesMap.values.toList().length, + itemBuilder: (context, index) { + List pnames = profilesMap.values.toList(); + List pid = profilesMap.keys.toList(); + final item = pnames[index]; + final profileId = + pid[index]; // Store pid[index] in a variable for clarity + + return Dismissible( + key: Key(profileId), + direction: DismissDirection.endToStart, + onDismissed: (direction) { + delete(profileId); + }, + background: Container( + color: Colors.red, + alignment: Alignment.centerRight, + padding: const EdgeInsets.only(right: 20.0), + child: const Icon(Icons.delete, color: Colors.white), + ), + child: ExpansionTile( + // Use ExpansionTile here + title: Text( + item, + style: TextStyle( + color: AppSettings.isDarkMode + ? TaskWarriorColors.kprimaryTextColor + : TaskWarriorColors.kLightPrimaryTextColor, + ), + ), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + icon: Icon(Icons.edit, + color: AppSettings.isDarkMode + ? TaskWarriorColors.kprimaryTextColor + : TaskWarriorColors.kLightPrimaryTextColor), + onPressed: () => rename(profileId), + ), + // The settings icon will now trigger the ExpansionTile's expansion/collapse + // No need for a separate IconButton for settings if ExpansionTile handles it + currentProfile != profileId + ? IconButton( + onPressed: () { + selectProfile(profileId); + }, + icon: Icon(Icons.check, + color: AppSettings.isDarkMode + ? TaskWarriorColors.kprimaryTextColor + : TaskWarriorColors.kLightPrimaryTextColor), + ) + : IconButton( + onPressed: () { + configure(); + }, + icon: Icon(Icons.key, + color: AppSettings.isDarkMode + ? TaskWarriorColors.kprimaryTextColor + : TaskWarriorColors.kLightPrimaryTextColor), + ), + ], + ), + children: [ + ListTile( + leading: Icon(Icons.file_copy, + color: AppSettings.isDarkMode + ? TaskWarriorColors.kprimaryTextColor + : TaskWarriorColors.kLightPrimaryTextColor), + title: Text('Export Tasks', + style: TextStyle( + color: AppSettings.isDarkMode + ? TaskWarriorColors.kprimaryTextColor + : TaskWarriorColors.kLightPrimaryTextColor)), + onTap: () { + export(profileId); + }, + ), + ListTile( + leading: Icon(Icons.copy, + color: AppSettings.isDarkMode + ? TaskWarriorColors.kprimaryTextColor + : TaskWarriorColors.kLightPrimaryTextColor), + title: Text('Copy to new Profile', + style: TextStyle( + color: AppSettings.isDarkMode + ? TaskWarriorColors.kprimaryTextColor + : TaskWarriorColors.kLightPrimaryTextColor)), + onTap: () { + copy(profileId); + }, + ), + ], + ), + ); + }, + )); + } +} diff --git a/lib/app/modules/profile/views/renameprofiledialog.dart b/lib/app/modules/profile/views/renameprofiledialog.dart index b74a3350..4e327dc0 100644 --- a/lib/app/modules/profile/views/renameprofiledialog.dart +++ b/lib/app/modules/profile/views/renameprofiledialog.dart @@ -28,10 +28,9 @@ class RenameProfileDialog extends StatelessWidget { child: Utils.showAlertDialog( scrollable: true, title: Text( - SentenceManager( - currentLanguage: AppSettings.selectedLanguage) - .sentences - .profilePageRenameAliasDialogueBoxTitle, + SentenceManager(currentLanguage: AppSettings.selectedLanguage) + .sentences + .profilePageRenameAliasDialogueBoxTitle, style: TextStyle( color: AppSettings.isDarkMode ? TaskWarriorColors.white @@ -41,8 +40,8 @@ class RenameProfileDialog extends StatelessWidget { content: TextField( style: TextStyle( color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + ? TaskWarriorColors.white + : TaskWarriorColors.black, ), controller: controller), actions: [ @@ -53,8 +52,8 @@ class RenameProfileDialog extends StatelessWidget { }, child: Text( SentenceManager(currentLanguage: AppSettings.selectedLanguage) - .sentences - .profilePageRenameAliasDialogueBoxCancel, + .sentences + .profilePageRenameAliasDialogueBoxCancel, style: TextStyle( color: AppSettings.isDarkMode ? TaskWarriorColors.white @@ -73,8 +72,8 @@ class RenameProfileDialog extends StatelessWidget { }, child: Text( SentenceManager(currentLanguage: AppSettings.selectedLanguage) - .sentences - .profilePageRenameAliasDialogueBoxSubmit, + .sentences + .profilePageRenameAliasDialogueBoxSubmit, style: TextStyle( color: AppSettings.isDarkMode ? TaskWarriorColors.black diff --git a/lib/app/modules/profile/views/selectprofile.dart b/lib/app/modules/profile/views/selectprofile.dart deleted file mode 100644 index 4b192cc8..00000000 --- a/lib/app/modules/profile/views/selectprofile.dart +++ /dev/null @@ -1,205 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import 'package:google_fonts/google_fonts.dart'; -import 'package:taskwarrior/app/modules/home/controllers/home_controller.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; - -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; -import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; - -class SelectProfile extends StatelessWidget { - const SelectProfile( - this.currentProfile, - this.profilesMap, - this.selectProfile, { - required this.currentProfileKey, - super.key, - }); - - final String currentProfile; - final Map profilesMap; - final void Function(String) selectProfile; - final GlobalKey currentProfileKey; - - @override - Widget build(BuildContext context) { - return Obx(() => ExpansionTile( - // key: currentProfileKey, - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, - iconColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - collapsedIconColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - collapsedTextColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryTextColor - : TaskWarriorColors.kLightSecondaryTextColor, - textColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - title: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - SentenceManager( - currentLanguage: AppSettings.selectedLanguage) - .sentences - .profilePageCurrentProfile, - key : currentProfileKey, - overflow: TextOverflow.fade, - style: GoogleFonts.poppins( - fontWeight: TaskWarriorFonts.bold, - fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - ), - ), - SizedBox( - height: Get.height * 0.01, - ), - Text(currentProfile, - style: GoogleFonts.poppins( - fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? TaskWarriorColors.grey - : TaskWarriorColors.lightGrey, - )) - ], - ), - children: [ - SizedBox( - height: Get.height * 0.01, - ), - Padding( - padding: EdgeInsets.only(left: Get.height * 0.04), - child: Row( - children: [ - Text( - 'All Profiles:', - overflow: TextOverflow.fade, - style: GoogleFonts.poppins( - - fontWeight: TaskWarriorFonts.bold, - fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - ), - ), - ], - ), - ), - SizedBox( - height: Get.height * 0.01, - ), - for (var entry in profilesMap.entries) - SelectProfileListTile( - currentProfile, - entry.key, - () => selectProfile(entry.key), - entry.value, - ) - ], - )); - } -} - -class SelectProfileListTile extends StatelessWidget { - const SelectProfileListTile( - this.selectedUuid, - this.uuid, - this.select, [ - this.alias, - Key? key, - ]) : super(key: key); - - final String selectedUuid; - final String uuid; - final void Function() select; - final String? alias; - - @override - Widget build(BuildContext context) { - return Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Radio( - value: uuid, - groupValue: selectedUuid, - onChanged: (_) { - select(); - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - 'Switched to Profile ${alias ?? uuid}', - style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, - ), - ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, - duration: const Duration(seconds: 2), - ), - ); - Get.find().refreshTaskWithNewProfile(); - }, - activeColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.ksecondaryBackgroundColor, - focusColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.ksecondaryBackgroundColor, - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - if (alias != null && alias!.isNotEmpty) - SizedBox( - // height: 100, - width: 300, - child: SingleChildScrollView( - key: PageStorageKey('scroll-title-$uuid'), - scrollDirection: Axis.horizontal, - child: Text( - alias!, - overflow: TextOverflow.fade, - style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryTextColor - : TaskWarriorColors.kLightSecondaryTextColor, - fontSize: TaskWarriorFonts.fontSizeMedium - ), - ), - ), - ), - SingleChildScrollView( - key: PageStorageKey('scroll-subtitle-$uuid'), - scrollDirection: Axis.horizontal, - child: Text( - uuid, - style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryTextColor - : TaskWarriorColors.kLightSecondaryTextColor, - fontSize: TaskWarriorFonts.fontSizeSmall - ), - ), - ), - ], - ), - ], - ); - } -}