From 4a70113ae946dc0d14e94f02471e160a165aa42d Mon Sep 17 00:00:00 2001 From: CTalvio Date: Mon, 6 May 2024 21:54:59 +0300 Subject: [PATCH 01/11] Move account button left, add account management to account settings --- lib/account/widgets/profile_modal_body.dart | 2 +- lib/user/pages/user_page.dart | 27 +- lib/user/pages/user_settings_page.dart | 337 +++++++++++--------- 3 files changed, 192 insertions(+), 174 deletions(-) diff --git a/lib/account/widgets/profile_modal_body.dart b/lib/account/widgets/profile_modal_body.dart index d896f42d8..46f6bdfba 100644 --- a/lib/account/widgets/profile_modal_body.dart +++ b/lib/account/widgets/profile_modal_body.dart @@ -311,7 +311,7 @@ class _ProfileSelectState extends State { ), ], ), - trailing: !widget.quickSelectMode && (accounts!.length > 1 || anonymousInstances?.isNotEmpty == true) + trailing: !widget.quickSelectMode ? (currentAccountId == accounts![index].account.id) ? IconButton( icon: loggingOutId == accounts![index].account.id diff --git a/lib/user/pages/user_page.dart b/lib/user/pages/user_page.dart index e94b8a1dc..81ec03e5e 100644 --- a/lib/user/pages/user_page.dart +++ b/lib/user/pages/user_page.dart @@ -57,14 +57,17 @@ class _UserPageState extends State { appBar: AppBar( scrolledUnderElevation: 0, leading: widget.isAccountUser - ? IconButton( - onPressed: () => showProfileModalSheet(context, showLogoutDialog: true), + ? Padding( + padding: const EdgeInsets.fromLTRB(0.0, 4.0, 4.0, 4.0), + child: IconButton( + onPressed: () => showProfileModalSheet(context), icon: Icon( - Icons.logout, - semanticLabel: AppLocalizations.of(context)!.logOut, + Icons.people_alt_rounded, + semanticLabel: AppLocalizations.of(context)!.profiles, ), - tooltip: AppLocalizations.of(context)!.logOut, - ) + tooltip: AppLocalizations.of(context)!.profiles, + ), + ) : null, actions: [ Padding( @@ -118,18 +121,6 @@ class _UserPageState extends State { tooltip: AppLocalizations.of(context)!.accountSettings, ), ), - if (widget.isAccountUser) - Padding( - padding: const EdgeInsets.fromLTRB(0.0, 4.0, 4.0, 4.0), - child: IconButton( - onPressed: () => showProfileModalSheet(context), - icon: Icon( - Icons.people_alt_rounded, - semanticLabel: AppLocalizations.of(context)!.profiles, - ), - tooltip: AppLocalizations.of(context)!.profiles, - ), - ), ], ), body: BlocBuilder(builder: (context, state) { diff --git a/lib/user/pages/user_settings_page.dart b/lib/user/pages/user_settings_page.dart index c95a7b92c..b1b84546a 100644 --- a/lib/user/pages/user_settings_page.dart +++ b/lib/user/pages/user_settings_page.dart @@ -6,7 +6,6 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:thunder/account/bloc/account_bloc.dart'; import 'package:thunder/account/models/account.dart'; -import 'package:thunder/account/widgets/account_placeholder.dart'; import 'package:thunder/core/auth/bloc/auth_bloc.dart'; import 'package:thunder/core/enums/full_name.dart'; import 'package:thunder/core/enums/local_settings.dart'; @@ -29,6 +28,8 @@ import 'package:thunder/utils/instance.dart'; import 'package:thunder/utils/links.dart'; import 'package:thunder/instance/utils/navigate_instance.dart'; +import '../../account/utils/profiles.dart'; + class UserSettingsPage extends StatefulWidget { final LocalSettings? settingToHighlight; @@ -108,10 +109,6 @@ class _UserSettingsPageState extends State { context.read().add(const GetUserBlocksEvent()); } - if (state.status == UserSettingsStatus.notLoggedIn) { - return const AccountPlaceholder(); - } - GetSiteResponse? getSiteResponse = state.getSiteResponse; MyUserInfo? myUserInfo = getSiteResponse?.myUser; @@ -129,169 +126,199 @@ class _UserSettingsPageState extends State { crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.only(left: 16.0, bottom: 16.0), - child: UserSelector( - profileModalHeading: l10n.changeAccountSettingsFor, - ), - ), - Padding( - padding: const EdgeInsets.only(top: 0, bottom: 8.0, left: 16.0, right: 16.0), - child: Text( - l10n.userSettingDescription, - style: theme.textTheme.bodyMedium!.copyWith( - fontWeight: FontWeight.w500, - color: theme.colorScheme.onBackground.withOpacity(0.75), + SettingsListTile( + icon: Icons.people_alt_rounded, + description: l10n.manageAccounts, + widget: const SizedBox( + height: 42.0, + child: Icon(Icons.chevron_right_rounded), ), - ), + onTap: () => showProfileModalSheet(context) ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), - child: Text(l10n.general, style: theme.textTheme.titleMedium), - ), - ToggleOption( - description: l10n.showReadPosts, - value: showReadPosts, - iconEnabled: Icons.fact_check_rounded, - iconDisabled: Icons.fact_check_outlined, - onToggle: (bool value) => {context.read().add(UpdateUserSettingsEvent(showReadPosts: value))}, - ), - ToggleOption( - description: l10n.showScores, - value: showScores, - iconEnabled: Icons.onetwothree_rounded, - iconDisabled: Icons.onetwothree_rounded, - onToggle: (bool value) => {context.read().add(UpdateUserSettingsEvent(showScores: value))}, - ), - ToggleOption( - description: l10n.showBotAccounts, - value: showBotAccounts, - iconEnabled: Thunder.robot, - iconEnabledSize: 18.0, - iconDisabled: Thunder.robot, - iconDisabledSize: 18.0, - iconSpacing: 14.0, - onToggle: (bool value) => {context.read().add(UpdateUserSettingsEvent(showBotAccounts: value))}, - ), - DiscussionLanguageSelector( - initialDiscussionLanguages: DiscussionLanguageSelector.getDiscussionLanguagesFromSiteResponse(state.getSiteResponse), - settingToHighlight: widget.settingToHighlight, - ), - if (LemmyClient.instance.supportsFeature(LemmyFeature.blockInstance)) ...[ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(l10n.blockedInstances, style: theme.textTheme.titleMedium), - IconButton( - visualDensity: VisualDensity.compact, - icon: Icon( - Icons.add_rounded, - semanticLabel: l10n.add, + if (state.status != UserSettingsStatus.notLoggedIn) + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const Divider(), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), + child: Text('This Account', style: theme.textTheme.titleMedium), + ), + Padding( + padding: const EdgeInsets.only(left: 16.0, bottom: 16.0, right: 8), + child: UserSelector( + profileModalHeading: l10n.changeAccountSettingsFor, + ), + ), + Padding( + padding: const EdgeInsets.only(top: 0, bottom: 8.0, left: 16.0, right: 16.0), + child: Text( + l10n.userSettingDescription, + style: theme.textTheme.bodyMedium!.copyWith( + fontWeight: FontWeight.w500, + color: theme.colorScheme.onBackground.withOpacity(0.75), ), - onPressed: () => showInstanceInputDialog( - context, - title: l10n.blockInstance, - onInstanceSelected: (instance) { - context.read().add(UnblockInstanceEvent(instanceId: instance.id, unblock: false)); - }, + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), + child: Text(l10n.general, style: theme.textTheme.titleMedium), + ), + SettingsListTile( + icon: Icons.logout_rounded, + description: l10n.logOut, + widget: const SizedBox( + height: 42.0, + child: Icon(Icons.chevron_right_rounded), + ), + onTap: () => showProfileModalSheet(context, showLogoutDialog: true) + ), + ToggleOption( + description: l10n.showReadPosts, + value: showReadPosts, + iconEnabled: Icons.fact_check_rounded, + iconDisabled: Icons.fact_check_outlined, + onToggle: (bool value) => {context.read().add(UpdateUserSettingsEvent(showReadPosts: value))}, + ), + ToggleOption( + description: l10n.showScores, + value: showScores, + iconEnabled: Icons.onetwothree_rounded, + iconDisabled: Icons.onetwothree_rounded, + onToggle: (bool value) => {context.read().add(UpdateUserSettingsEvent(showScores: value))}, + ), + ToggleOption( + description: l10n.showBotAccounts, + value: showBotAccounts, + iconEnabled: Thunder.robot, + iconEnabledSize: 18.0, + iconDisabled: Thunder.robot, + iconDisabledSize: 18.0, + iconSpacing: 14.0, + onToggle: (bool value) => {context.read().add(UpdateUserSettingsEvent(showBotAccounts: value))}, + ), + DiscussionLanguageSelector( + initialDiscussionLanguages: DiscussionLanguageSelector.getDiscussionLanguagesFromSiteResponse(state.getSiteResponse), + settingToHighlight: widget.settingToHighlight, + ), + if (LemmyClient.instance.supportsFeature(LemmyFeature.blockInstance)) ...[ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(l10n.blockedInstances, style: theme.textTheme.titleMedium), + IconButton( + visualDensity: VisualDensity.compact, + icon: Icon( + Icons.add_rounded, + semanticLabel: l10n.add, + ), + onPressed: () => showInstanceInputDialog( + context, + title: l10n.blockInstance, + onInstanceSelected: (instance) { + context.read().add(UnblockInstanceEvent(instanceId: instance.id, unblock: false)); + }, + ), + ), + ], ), ), - ], - ), - ), - UserSettingBlockList( - status: state.status, - emptyText: l10n.noInstanceBlocks, - items: getInstanceBlocks(context, state, state.instanceBlocks), - ), - ], - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(l10n.blockedUsers, style: theme.textTheme.titleMedium), - IconButton( - visualDensity: VisualDensity.compact, - icon: Icon( - Icons.add_rounded, - semanticLabel: l10n.add, + UserSettingBlockList( + status: state.status, + emptyText: l10n.noInstanceBlocks, + items: getInstanceBlocks(context, state, state.instanceBlocks), ), - onPressed: () => showUserInputDialog( - context, - title: l10n.blockUser, - onUserSelected: (personViewSafe) { - context.read().add(UnblockPersonEvent(personId: personViewSafe.person.id, unblock: false)); - }, + ], + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(l10n.blockedUsers, style: theme.textTheme.titleMedium), + IconButton( + visualDensity: VisualDensity.compact, + icon: Icon( + Icons.add_rounded, + semanticLabel: l10n.add, + ), + onPressed: () => showUserInputDialog( + context, + title: l10n.blockUser, + onUserSelected: (personViewSafe) { + context.read().add(UnblockPersonEvent(personId: personViewSafe.person.id, unblock: false)); + }, + ), + ), + ], ), ), - ], - ), - ), - UserSettingBlockList( - status: state.status, - emptyText: l10n.noUserBlocks, - items: getPersonBlocks(context, state, state.personBlocks), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(l10n.blockedCommunities, style: theme.textTheme.titleMedium), - IconButton( - visualDensity: VisualDensity.compact, - icon: Icon( - Icons.add_rounded, - semanticLabel: l10n.add, + UserSettingBlockList( + status: state.status, + emptyText: l10n.noUserBlocks, + items: getPersonBlocks(context, state, state.personBlocks), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(l10n.blockedCommunities, style: theme.textTheme.titleMedium), + IconButton( + visualDensity: VisualDensity.compact, + icon: Icon( + Icons.add_rounded, + semanticLabel: l10n.add, + ), + onPressed: () => showCommunityInputDialog( + context, + title: l10n.blockCommunity, + onCommunitySelected: (communityView) { + context.read().add(UnblockCommunityEvent(communityId: communityView.community.id, unblock: false)); + }, + ), + ), + ], ), - onPressed: () => showCommunityInputDialog( - context, - title: l10n.blockCommunity, - onCommunitySelected: (communityView) { - context.read().add(UnblockCommunityEvent(communityId: communityView.community.id, unblock: false)); - }, + ), + UserSettingBlockList( + status: state.status, + 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), + ), + 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), ], ), - ), - UserSettingBlockList( - status: state.status, - 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), - ), - 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), ], ), ); From 574d2150270cac7b343221098f871bc6b2cc4298 Mon Sep 17 00:00:00 2001 From: CTalvio Date: Mon, 6 May 2024 22:41:48 +0300 Subject: [PATCH 02/11] Do not show just saved or placeholder when actually still loading a profile --- lib/account/pages/account_page.dart | 2 +- lib/user/pages/user_page.dart | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/account/pages/account_page.dart b/lib/account/pages/account_page.dart index e2ae39da8..6c05e3f9b 100644 --- a/lib/account/pages/account_page.dart +++ b/lib/account/pages/account_page.dart @@ -41,7 +41,7 @@ class _AccountPageState extends State with AutomaticKeepAliveClient }, ), ], - child: (authState.isLoggedIn && accountState.status == AccountStatus.success && accountState.personView != null) + child: (authState.isLoggedIn && accountState.personView != null) ? UserPage( userId: accountState.personView!.person.id, isAccountUser: true, diff --git a/lib/user/pages/user_page.dart b/lib/user/pages/user_page.dart index 81ec03e5e..fd970e927 100644 --- a/lib/user/pages/user_page.dart +++ b/lib/user/pages/user_page.dart @@ -140,6 +140,9 @@ class _UserPageState extends State { case UserStatus.refreshing: case UserStatus.success: case UserStatus.failedToBlock: + if (state.personView == null) { + return const Center(child: CircularProgressIndicator()); + } return UserPageSuccess( userId: widget.userId, isAccountUser: widget.isAccountUser, From ca4b0e0421a1d3c17036fb2267a2990f9164b525 Mon Sep 17 00:00:00 2001 From: CTalvio Date: Mon, 6 May 2024 22:42:29 +0300 Subject: [PATCH 03/11] Change login instance links into buttons --- lib/account/pages/login_page.dart | 112 +++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 34 deletions(-) diff --git a/lib/account/pages/login_page.dart b/lib/account/pages/login_page.dart index f6f3461a2..9c6bdbe04 100644 --- a/lib/account/pages/login_page.dart +++ b/lib/account/pages/login_page.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:cached_network_image/cached_network_image.dart'; -import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -187,14 +186,31 @@ class _LoginPageState extends State with SingleTickerProviderStateMix firstChild: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - RichText( - text: TextSpan( - style: theme.textTheme.bodySmall?.copyWith(color: Colors.blue), - text: AppLocalizations.of(context)!.gettingStarted, - recognizer: TapGestureRecognizer() - ..onTap = () { - handleLink(context, url: 'https://join-lemmy.org/'); - }, + OutlinedButton( + onPressed: () { + handleLink(context, url: 'https://join-lemmy.org/'); + }, + style: OutlinedButton.styleFrom( + padding: const EdgeInsets.only(left: 10, right: 16), + backgroundColor: theme.colorScheme.surface, + textStyle: theme.textTheme.titleMedium?.copyWith( + color: theme.colorScheme.onPrimary, + ), + ), + child: Row( + children: [ + Icon( + Icons.insert_link_rounded, + color: theme.textTheme.bodySmall?.color, + ), + const SizedBox( + width: 8, + ), + Text( + AppLocalizations.of(context)!.gettingStarted, + style: theme.textTheme.bodySmall, + ), + ], ), ), ], @@ -202,32 +218,60 @@ class _LoginPageState extends State with SingleTickerProviderStateMix secondChild: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - const SizedBox(width: 5), - RichText( - text: TextSpan( - style: theme.textTheme.bodySmall?.copyWith(color: Colors.blue), - text: AppLocalizations.of(context)!.openInstance, - recognizer: TapGestureRecognizer() - ..onTap = () { - handleLink(context, url: 'https://${_instanceTextEditingController.text}'); - }, + OutlinedButton( + onPressed: () { + handleLink(context, url: 'https://${_instanceTextEditingController.text}'); + }, + style: OutlinedButton.styleFrom( + padding: const EdgeInsets.only(left: 10, right: 16), + backgroundColor: theme.colorScheme.surface, + textStyle: theme.textTheme.titleMedium?.copyWith( + color: theme.colorScheme.onPrimary, + ), + ), + child: Row( + children: [ + Icon( + Icons.insert_link_rounded, + color: theme.textTheme.bodySmall?.color, + ), + const SizedBox( + width: 8, + ), + Text( + AppLocalizations.of(context)!.openInstance, + style: theme.textTheme.bodySmall, + ), + ], ), ), if (!widget.anonymous) ...[ - const SizedBox(width: 10), - Text( - '|', - style: theme.textTheme.bodySmall, - ), - const SizedBox(width: 10), - RichText( - text: TextSpan( - style: theme.textTheme.bodySmall?.copyWith(color: Colors.blue), - text: AppLocalizations.of(context)!.createAccount, - recognizer: TapGestureRecognizer() - ..onTap = () { - handleLink(context, url: 'https://${_instanceTextEditingController.text}/signup'); - }, + const SizedBox(width: 12), + OutlinedButton( + onPressed: () { + handleLink(context, url: 'https://${_instanceTextEditingController.text}/signup'); + }, + style: OutlinedButton.styleFrom( + padding: const EdgeInsets.only(left: 10, right: 16), + backgroundColor: theme.colorScheme.surface, + textStyle: theme.textTheme.titleMedium?.copyWith( + color: theme.colorScheme.onPrimary, + ), + ), + child: Row( + children: [ + Icon( + Icons.insert_link_rounded, + color: theme.textTheme.bodySmall?.color, + ), + const SizedBox( + width: 8, + ), + Text( + AppLocalizations.of(context)!.createAccount, + style: theme.textTheme.bodySmall, + ), + ], ), ), ], @@ -274,7 +318,7 @@ class _LoginPageState extends State with SingleTickerProviderStateMix hideOnError: true, ), if (!widget.anonymous) ...[ - const SizedBox(height: 35.0), + const SizedBox(height: 32.0), AutofillGroup( child: Column( children: [ @@ -344,7 +388,6 @@ class _LoginPageState extends State with SingleTickerProviderStateMix enableSuggestions: false, ), ], - const SizedBox(height: 12.0), const SizedBox(height: 32.0), ElevatedButton( style: ElevatedButton.styleFrom( @@ -362,6 +405,7 @@ class _LoginPageState extends State with SingleTickerProviderStateMix child: Text(widget.anonymous ? AppLocalizations.of(context)!.add : AppLocalizations.of(context)!.login, style: theme.textTheme.titleMedium?.copyWith(color: !isLoading && fieldsFilledIn ? theme.colorScheme.onPrimary : theme.colorScheme.primary)), ), + const SizedBox(height: 12.0), TextButton( style: ElevatedButton.styleFrom(minimumSize: const Size.fromHeight(60)), onPressed: !isLoading ? () => widget.popRegister() : null, From a8961b949905a8fc122f3f28f4fd394f1d564b37 Mon Sep 17 00:00:00 2001 From: CTalvio Date: Mon, 6 May 2024 23:16:55 +0300 Subject: [PATCH 04/11] formatting --- lib/user/pages/user_page.dart | 18 +++++++++--------- lib/user/pages/user_settings_page.dart | 6 ++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/user/pages/user_page.dart b/lib/user/pages/user_page.dart index fd970e927..f53eec0c9 100644 --- a/lib/user/pages/user_page.dart +++ b/lib/user/pages/user_page.dart @@ -58,16 +58,16 @@ class _UserPageState extends State { scrolledUnderElevation: 0, leading: widget.isAccountUser ? Padding( - padding: const EdgeInsets.fromLTRB(0.0, 4.0, 4.0, 4.0), - child: IconButton( - onPressed: () => showProfileModalSheet(context), - icon: Icon( - Icons.people_alt_rounded, - semanticLabel: AppLocalizations.of(context)!.profiles, + padding: const EdgeInsets.fromLTRB(0.0, 4.0, 4.0, 4.0), + child: IconButton( + onPressed: () => showProfileModalSheet(context), + icon: Icon( + Icons.people_alt_rounded, + semanticLabel: AppLocalizations.of(context)!.profiles, + ), + tooltip: AppLocalizations.of(context)!.profiles, ), - tooltip: AppLocalizations.of(context)!.profiles, - ), - ) + ) : null, actions: [ Padding( diff --git a/lib/user/pages/user_settings_page.dart b/lib/user/pages/user_settings_page.dart index b1b84546a..4c9defcfb 100644 --- a/lib/user/pages/user_settings_page.dart +++ b/lib/user/pages/user_settings_page.dart @@ -133,8 +133,7 @@ class _UserSettingsPageState extends State { height: 42.0, child: Icon(Icons.chevron_right_rounded), ), - onTap: () => showProfileModalSheet(context) - ), + onTap: () => showProfileModalSheet(context)), if (state.status != UserSettingsStatus.notLoggedIn) Column( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -172,8 +171,7 @@ class _UserSettingsPageState extends State { height: 42.0, child: Icon(Icons.chevron_right_rounded), ), - onTap: () => showProfileModalSheet(context, showLogoutDialog: true) - ), + onTap: () => showProfileModalSheet(context, showLogoutDialog: true)), ToggleOption( description: l10n.showReadPosts, value: showReadPosts, From 6988e235455ab3e64c44af33e83f69f670d31688 Mon Sep 17 00:00:00 2001 From: CTalvio Date: Tue, 7 May 2024 01:17:42 +0300 Subject: [PATCH 05/11] Further improvements, localisation --- lib/l10n/app_en.arb | 4 ++++ lib/user/pages/user_settings_page.dart | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 64bb52d1a..e22f6687b 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -1887,6 +1887,10 @@ "@thickness": { "description": "Describes a thickness (e.g., divider)" }, + "thisAccount": "This Account", + "@thisAccount": { + "description": "Referring to the currently active account in account settings" + }, "thunderHasBeenUpdated": "Thunder updated to {version}!", "@thunderHasBeenUpdated": { "description": "Heading for changelog when Thunder has been updated" diff --git a/lib/user/pages/user_settings_page.dart b/lib/user/pages/user_settings_page.dart index 4c9defcfb..c8f4633b0 100644 --- a/lib/user/pages/user_settings_page.dart +++ b/lib/user/pages/user_settings_page.dart @@ -23,7 +23,7 @@ import 'package:thunder/shared/avatars/user_avatar.dart'; import 'package:thunder/thunder/thunder_icons.dart'; import 'package:thunder/user/bloc/user_settings_bloc.dart'; import 'package:thunder/user/utils/restore_user.dart'; -import 'package:thunder/user/widgets/user_selector.dart'; +import 'package:thunder/user/widgets/user_indicator.dart'; import 'package:thunder/utils/instance.dart'; import 'package:thunder/utils/links.dart'; import 'package:thunder/instance/utils/navigate_instance.dart'; @@ -117,10 +117,6 @@ class _UserSettingsPageState extends State { bool showBotAccounts = localUser?.showBotAccounts ?? true; bool showScores = localUser?.showScores ?? true; - if (state.getSiteResponse == null || myUserInfo == null) { - return const Center(child: CircularProgressIndicator()); - } - return SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -134,21 +130,25 @@ class _UserSettingsPageState extends State { child: Icon(Icons.chevron_right_rounded), ), onTap: () => showProfileModalSheet(context)), - if (state.status != UserSettingsStatus.notLoggedIn) + if (state.status != UserSettingsStatus.notLoggedIn && state.getSiteResponse != null && myUserInfo != null) Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.start, children: [ - const Divider(), + Divider( + indent: 32.0, + height: 32.0, + endIndent: 32.0, + thickness: 2.0, + color: theme.dividerColor.withOpacity(0.6), + ), Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), - child: Text('This Account', style: theme.textTheme.titleMedium), + child: Text(l10n.thisAccount, style: theme.textTheme.titleMedium), ), - Padding( - padding: const EdgeInsets.only(left: 16.0, bottom: 16.0, right: 8), - child: UserSelector( - profileModalHeading: l10n.changeAccountSettingsFor, - ), + const Padding( + padding: EdgeInsets.only(left: 16.0, bottom: 16.0, right: 8), + child: UserIndicator(), ), Padding( padding: const EdgeInsets.only(top: 0, bottom: 8.0, left: 16.0, right: 16.0), From eecc179ef89bd834ab73cfdeb4d85285c6ad1def Mon Sep 17 00:00:00 2001 From: CTalvio Date: Tue, 7 May 2024 22:01:26 +0300 Subject: [PATCH 06/11] Fix account page failing to update --- lib/account/pages/account_page.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/account/pages/account_page.dart b/lib/account/pages/account_page.dart index 6c05e3f9b..6221a16d8 100644 --- a/lib/account/pages/account_page.dart +++ b/lib/account/pages/account_page.dart @@ -30,18 +30,16 @@ class _AccountPageState extends State with AutomaticKeepAliveClient listeners: [ BlocListener( listener: (context, state) { - if (!state.reload) return; setState(() => authState = state); }, ), BlocListener( listener: (context, state) { - if (!state.reload) return; setState(() => accountState = state); }, ), ], - child: (authState.isLoggedIn && accountState.personView != null) + child: (authState.isLoggedIn) ? UserPage( userId: accountState.personView!.person.id, isAccountUser: true, From f2f7bcabd3deaf178e185f46099cf8a5c82385af Mon Sep 17 00:00:00 2001 From: CTalvio Date: Wed, 8 May 2024 00:15:53 +0300 Subject: [PATCH 07/11] Undo removal of returns in listeners --- lib/account/pages/account_page.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/account/pages/account_page.dart b/lib/account/pages/account_page.dart index 6221a16d8..af46a4fca 100644 --- a/lib/account/pages/account_page.dart +++ b/lib/account/pages/account_page.dart @@ -30,11 +30,13 @@ class _AccountPageState extends State with AutomaticKeepAliveClient listeners: [ BlocListener( listener: (context, state) { + if (!state.reload) return; setState(() => authState = state); }, ), BlocListener( listener: (context, state) { + if (!state.reload) return; setState(() => accountState = state); }, ), From fc0ef15063cbc9ad279429ad54ef2f69e7d58522 Mon Sep 17 00:00:00 2001 From: CTalvio Date: Sun, 12 May 2024 23:25:06 +0300 Subject: [PATCH 08/11] add logged-in check to reload check --- lib/account/pages/account_page.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/account/pages/account_page.dart b/lib/account/pages/account_page.dart index af46a4fca..14d130a49 100644 --- a/lib/account/pages/account_page.dart +++ b/lib/account/pages/account_page.dart @@ -30,13 +30,13 @@ class _AccountPageState extends State with AutomaticKeepAliveClient listeners: [ BlocListener( listener: (context, state) { - if (!state.reload) return; + if (state.isLoggedIn && !state.reload) return; setState(() => authState = state); }, ), BlocListener( listener: (context, state) { - if (!state.reload) return; + if (authState.isLoggedIn && !state.reload) return; setState(() => accountState = state); }, ), From 1c890925f3cd354ae08c5d202787cc8278b729e0 Mon Sep 17 00:00:00 2001 From: CTalvio Date: Sun, 12 May 2024 23:25:29 +0300 Subject: [PATCH 09/11] do no restore previous user on account settings exit --- lib/user/pages/user_settings_page.dart | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/user/pages/user_settings_page.dart b/lib/user/pages/user_settings_page.dart index c8f4633b0..3f15badb1 100644 --- a/lib/user/pages/user_settings_page.dart +++ b/lib/user/pages/user_settings_page.dart @@ -40,21 +40,13 @@ class UserSettingsPage extends StatefulWidget { } class _UserSettingsPageState extends State { - Account? originalUser; @override Widget build(BuildContext context) { final theme = Theme.of(context); final l10n = AppLocalizations.of(context)!; - AuthState state = context.read().state; - originalUser ??= state.account; return PopScope( - onPopInvoked: (_) { - if (context.mounted) { - restoreUser(context, originalUser); - } - }, child: Scaffold( appBar: AppBar( toolbarHeight: 70.0, From 9e2a8140388032658284c5c7c30439b951c6a07c Mon Sep 17 00:00:00 2001 From: CTalvio Date: Sun, 12 May 2024 23:26:10 +0300 Subject: [PATCH 10/11] formatting --- lib/user/pages/user_settings_page.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/user/pages/user_settings_page.dart b/lib/user/pages/user_settings_page.dart index 3f15badb1..8ad484e58 100644 --- a/lib/user/pages/user_settings_page.dart +++ b/lib/user/pages/user_settings_page.dart @@ -5,7 +5,6 @@ import 'package:lemmy_api_client/v3.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:thunder/account/bloc/account_bloc.dart'; -import 'package:thunder/account/models/account.dart'; import 'package:thunder/core/auth/bloc/auth_bloc.dart'; import 'package:thunder/core/enums/full_name.dart'; import 'package:thunder/core/enums/local_settings.dart'; @@ -22,7 +21,6 @@ import 'package:thunder/shared/snackbar.dart'; import 'package:thunder/shared/avatars/user_avatar.dart'; import 'package:thunder/thunder/thunder_icons.dart'; import 'package:thunder/user/bloc/user_settings_bloc.dart'; -import 'package:thunder/user/utils/restore_user.dart'; import 'package:thunder/user/widgets/user_indicator.dart'; import 'package:thunder/utils/instance.dart'; import 'package:thunder/utils/links.dart'; @@ -40,7 +38,6 @@ class UserSettingsPage extends StatefulWidget { } class _UserSettingsPageState extends State { - @override Widget build(BuildContext context) { final theme = Theme.of(context); From 089276d985c48b753859f65da40bf5b504c4b9c7 Mon Sep 17 00:00:00 2001 From: Casper Talvio Date: Thu, 16 May 2024 11:56:24 +0300 Subject: [PATCH 11/11] absolute import --- lib/user/pages/user_settings_page.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/user/pages/user_settings_page.dart b/lib/user/pages/user_settings_page.dart index 8ad484e58..428bbb6cf 100644 --- a/lib/user/pages/user_settings_page.dart +++ b/lib/user/pages/user_settings_page.dart @@ -25,8 +25,7 @@ import 'package:thunder/user/widgets/user_indicator.dart'; import 'package:thunder/utils/instance.dart'; import 'package:thunder/utils/links.dart'; import 'package:thunder/instance/utils/navigate_instance.dart'; - -import '../../account/utils/profiles.dart'; +import 'package:thunder/account/utils/profiles.dart'; class UserSettingsPage extends StatefulWidget { final LocalSettings? settingToHighlight;