diff --git a/lib/globals.dart b/lib/globals.dart index 3504fcbb8..43ae0edc6 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -1 +1 @@ -const String currentVersion = '0.2.7+35'; +const String currentVersion = '0.2.8+37'; diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index d72e1dbb8..b3f10b16f 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -189,6 +189,10 @@ "@compactViewSettings": { "description": "Subcategory in Setting -> Appearance -> Posts" }, + "confirm": "Confirm", + "@confirm": { + "description": "Label for the confirm action in the dialog" + }, "condensed": "Condensed", "@condensed": { "description": "Condensed post body view type" @@ -261,6 +265,10 @@ "@currentSinglePress": {}, "customizeSwipeActions": "Customize swipe actions (tap to change)", "@customizeSwipeActions": {}, + "dangerZone": "Danger Zone", + "@dangerZone": { + "description": "Describes a section where the actions could be dangerous (e.g., permanently deleting account)" + }, "debug": "Debug", "@debug": { "description": "Debug settings category." @@ -271,6 +279,14 @@ }, "delete": "Delete", "@delete": {}, + "deleteAccount": "Delete Account", + "@deleteAccount": { + "description": "Label for action to delete account" + }, + "deleteAccountDescription": "To permanently delete your account, you will be redirected to your instance site. \n\nAre you sure you want to continue?", + "@deleteAccountDescription": { + "description": "Description for confirmation action to delete account" + }, "deleteLocalDatabase": "Delete Local Database", "@deleteLocalDatabase": { "description": "Label for action to delete local database" diff --git a/lib/thunder/bloc/thunder_bloc.dart b/lib/thunder/bloc/thunder_bloc.dart index 5608e5b89..38aa946cf 100644 --- a/lib/thunder/bloc/thunder_bloc.dart +++ b/lib/thunder/bloc/thunder_bloc.dart @@ -111,7 +111,7 @@ class ThunderBloc extends Bloc { bool useDisplayNames = prefs.getBool(LocalSettings.useDisplayNamesForUsers.name) ?? true; bool markPostReadOnMediaView = prefs.getBool(LocalSettings.markPostAsReadOnMediaView.name) ?? false; bool showInAppUpdateNotification = prefs.getBool(LocalSettings.showInAppUpdateNotification.name) ?? false; - String? appLanguageCode = prefs.getString(LocalSettings.appLanguageCode.name); + String? appLanguageCode = prefs.getString(LocalSettings.appLanguageCode.name) ?? 'en'; FullNameSeparator userSeparator = FullNameSeparator.values.byName(prefs.getString(LocalSettings.userFormat.name) ?? FullNameSeparator.at.name); FullNameSeparator communitySeparator = FullNameSeparator.values.byName(prefs.getString(LocalSettings.communityFormat.name) ?? FullNameSeparator.dot.name); bool hideTopBarOnScroll = prefs.getBool(LocalSettings.hideTopBarOnScroll.name) ?? false; diff --git a/lib/thunder/bloc/thunder_state.dart b/lib/thunder/bloc/thunder_state.dart index 32dcf67a7..47995b46b 100644 --- a/lib/thunder/bloc/thunder_state.dart +++ b/lib/thunder/bloc/thunder_state.dart @@ -56,7 +56,7 @@ class ThunderState extends Equatable { this.useAdvancedShareSheet = true, this.showCrossPosts = true, this.keywordFilters = const [], - this.appLanguageCode, + this.appLanguageCode = 'en', /// -------------------------- Post Page Related Settings -------------------------- this.disablePostFabs = false, @@ -317,7 +317,7 @@ class ThunderState extends Equatable { bool? dimReadPosts, bool? useAdvancedShareSheet, bool? showCrossPosts, - String? appLanguageCode, + String? appLanguageCode = 'en', List? keywordFilters, /// -------------------------- Post Page Related Settings -------------------------- diff --git a/lib/user/pages/user_settings_page.dart b/lib/user/pages/user_settings_page.dart index ea5045307..82e4cc63d 100644 --- a/lib/user/pages/user_settings_page.dart +++ b/lib/user/pages/user_settings_page.dart @@ -10,8 +10,10 @@ import 'package:thunder/core/auth/bloc/auth_bloc.dart'; import 'package:thunder/core/enums/full_name_separator.dart'; import 'package:thunder/core/singletons/lemmy_client.dart'; import 'package:thunder/feed/feed.dart'; +import 'package:thunder/settings/widgets/settings_list_tile.dart'; import 'package:thunder/settings/widgets/toggle_option.dart'; import 'package:thunder/shared/community_icon.dart'; +import 'package:thunder/shared/dialogs.dart'; import 'package:thunder/shared/input_dialogs.dart'; import 'package:thunder/shared/snackbar.dart'; import 'package:thunder/shared/user_avatar.dart'; @@ -19,6 +21,7 @@ import 'package:thunder/thunder/thunder_icons.dart'; import 'package:thunder/user/bloc/user_settings_bloc.dart'; import 'package:thunder/user/widgets/user_indicator.dart'; import 'package:thunder/utils/instance.dart'; +import 'package:thunder/utils/links.dart'; import 'package:thunder/utils/navigate_instance.dart'; import 'package:thunder/utils/navigate_user.dart'; @@ -250,6 +253,38 @@ class _UserSettingsPageState extends State { emptyText: l10n.noCommunityBlocks, items: getCommunityBlocks(context, state, state.communityBlocks), ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), + child: Text(l10n.dangerZone, style: theme.textTheme.titleMedium), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: SettingsListTile( + icon: Icons.delete_forever_rounded, + description: l10n.deleteAccount, + widget: const SizedBox( + height: 42.0, + child: Icon(Icons.chevron_right_rounded), + ), + onTap: () async { + showThunderDialog( + context: context, + title: l10n.deleteAccount, + contentText: l10n.deleteAccountDescription, + onSecondaryButtonPressed: (dialogContext) => Navigator.of(dialogContext).pop(), + secondaryButtonText: l10n.cancel, + onPrimaryButtonPressed: (dialogContext, _) async { + if (context.mounted) { + Navigator.of(context).pop(); + handleLink(context, url: 'https://${LemmyClient.instance.lemmyApiV3.host}/settings'); + } + }, + primaryButtonText: l10n.confirm, + ); + }, + ), + ), + const SizedBox(height: 100.0), ], ), ); diff --git a/pubspec.yaml b/pubspec.yaml index 786b3a07b..79deb6a2a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: thunder description: An open-source cross-platform Lemmy client for iOS and Android built with Flutter publish_to: "none" -version: 0.2.7+35 +version: 0.2.8+37 environment: sdk: "^3.0.0"