Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional account settings #1436

Merged
merged 8 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/community/widgets/community_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class FeedDrawerItems extends StatelessWidget {
isSelected: destination.listingType == feedState.postListingType,
onTap: () {
Navigator.of(context).pop();
navigateToFeedPage(context, feedType: FeedType.general, postListingType: destination.listingType, sortType: thunderState.sortTypeForInstance);
navigateToFeedPage(context, feedType: FeedType.general, postListingType: destination.listingType);
},
label: destination.label,
icon: destination.icon,
Expand Down Expand Up @@ -228,6 +228,7 @@ class FavoriteCommunities extends StatelessWidget {
final theme = Theme.of(context);
final l10n = AppLocalizations.of(context)!;

AuthState authState = context.watch<AuthBloc>().state;
FeedState feedState = context.watch<FeedBloc>().state;
AccountState accountState = context.watch<AccountBloc>().state;
ThunderState thunderState = context.read<ThunderBloc>().state;
Expand Down Expand Up @@ -264,7 +265,7 @@ class FavoriteCommunities extends StatelessWidget {
context.read<FeedBloc>().add(
FeedFetchedEvent(
feedType: FeedType.community,
sortType: thunderState.sortTypeForInstance,
sortType: authState.getSiteResponse?.myUser?.localUserView.localUser.defaultSortType ?? thunderState.sortTypeForInstance,
communityId: community.id,
reset: true,
),
Expand All @@ -288,6 +289,7 @@ class SubscribedCommunities extends StatelessWidget {
final theme = Theme.of(context);
final l10n = AppLocalizations.of(context)!;

AuthState authState = context.watch<AuthBloc>().state;
FeedState feedState = context.watch<FeedBloc>().state;
AccountState accountState = context.watch<AccountBloc>().state;
ThunderState thunderState = context.read<ThunderBloc>().state;
Expand Down Expand Up @@ -341,7 +343,7 @@ class SubscribedCommunities extends StatelessWidget {
context.read<FeedBloc>().add(
FeedFetchedEvent(
feedType: FeedType.community,
sortType: thunderState.sortTypeForInstance,
sortType: authState.getSiteResponse?.myUser?.localUserView.localUser.defaultSortType ?? thunderState.sortTypeForInstance,
communityId: community.id,
reset: true,
),
Expand Down Expand Up @@ -375,6 +377,7 @@ class ModeratedCommunities extends StatelessWidget {
final theme = Theme.of(context);
final l10n = AppLocalizations.of(context)!;

AuthState authState = context.watch<AuthBloc>().state;
FeedState feedState = context.watch<FeedBloc>().state;
AccountState accountState = context.watch<AccountBloc>().state;
ThunderState thunderState = context.read<ThunderBloc>().state;
Expand Down Expand Up @@ -411,7 +414,7 @@ class ModeratedCommunities extends StatelessWidget {
context.read<FeedBloc>().add(
FeedFetchedEvent(
feedType: FeedType.community,
sortType: thunderState.sortTypeForInstance,
sortType: authState.getSiteResponse?.myUser?.localUserView.localUser.defaultSortType ?? thunderState.sortTypeForInstance,
communityId: community.id,
reset: true,
),
Expand Down
8 changes: 4 additions & 4 deletions lib/feed/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ Future<void> navigateToFeedPage(
return context.read<FeedBloc>().add(
FeedFetchedEvent(
feedType: feedType,
postListingType: postListingType,
sortType: sortType ?? thunderBloc.state.sortTypeForInstance,
postListingType: postListingType ?? authBloc.state.getSiteResponse?.myUser?.localUserView.localUser.defaultListingType,
sortType: sortType ?? authBloc.state.getSiteResponse?.myUser?.localUserView.localUser.defaultSortType ?? thunderBloc.state.sortTypeForInstance,
communityId: communityId,
communityName: communityName,
userId: userId,
Expand Down Expand Up @@ -121,12 +121,12 @@ Future<void> navigateToFeedPage(
child: Material(
child: FeedPage(
feedType: feedType,
sortType: sortType ?? thunderBloc.state.sortTypeForInstance,
sortType: sortType ?? authBloc.state.getSiteResponse?.myUser?.localUserView.localUser.defaultSortType ?? thunderBloc.state.sortTypeForInstance,
communityName: communityName,
communityId: communityId,
userId: userId,
username: username,
postListingType: postListingType,
postListingType: postListingType ?? authBloc.state.getSiteResponse?.myUser?.localUserView.localUser.defaultListingType,
),
),
),
Expand Down
5 changes: 3 additions & 2 deletions lib/feed/view/feed_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -543,14 +543,15 @@ class _FeedViewState extends State<FeedView> {
return true;
}

AuthBloc authBloc = context.read<AuthBloc>();
FeedBloc feedBloc = context.read<FeedBloc>();
ThunderBloc thunderBloc = context.read<ThunderBloc>();

// See if we're at the top level of navigation
final canPop = Navigator.of(context).canPop();

// Get the desired post listing so we can check against current
final desiredListingType = thunderBloc.state.defaultListingType;
final desiredListingType = authBloc.state.getSiteResponse?.myUser?.localUserView.localUser.defaultListingType ?? thunderBloc.state.defaultListingType;
final currentListingType = feedBloc.state.postListingType;

// See if we're in a community
Expand All @@ -564,7 +565,7 @@ class _FeedViewState extends State<FeedView> {
if (!canPop && (desiredListingType != currentListingType || communityMode)) {
feedBloc.add(
FeedFetchedEvent(
sortType: thunderBloc.state.sortTypeForInstance,
sortType: authBloc.state.getSiteResponse?.myUser?.localUserView.localUser.defaultSortType ?? thunderBloc.state.sortTypeForInstance,
reset: true,
postListingType: desiredListingType,
feedType: FeedType.general,
Expand Down
76 changes: 76 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"@accountBirthday": {
"description": "User descriptor for accounts created on today's date"
},
"accountSettingOverrideWarning": "Your account settings override the following settings",
"@accountSettingOverrideWarning": {
"description": "Warning for account settings override"
},
"accountSettings": "Account Settings",
"@accountSettings": {},
"accountSwitchParentCommentNotFound": "The selected comment was not found on '{instance}'. Switching back to previous account.",
Expand Down Expand Up @@ -139,6 +143,14 @@
"@blockCommunity": {},
"blockInstance": "Block Instance",
"@blockInstance": {},
"blockManagement": "Block Management",
"@blockManagement": {
"description": "Setting for user, community, and instance block settings"
},
"blockSettingLabel": "User/Community/Instance Blocks",
"@blockSettingLabel": {
"description": "Setting for user, community, and instance block settings"
},
"blockUser": "Block User",
"@blockUser": {},
"blockedCommunities": "Blocked Communities",
Expand Down Expand Up @@ -209,6 +221,14 @@
"@changeNotificationSettings": {
"description": "A shortcut to navigate to the notification settings"
},
"changePassword": "Change Password",
"@changePassword": {
"description": "Label for action to change password"
},
"changePasswordWarning": "To change your password, you will be redirected to your instance site. \\n\\nAre you sure you want to continue?",
"@changePasswordWarning": {
"description": "Warning label for changing password"
},
"changeSort": "Change Sort",
"@changeSort": {},
"clearCache": "Clear Cache ({cacheSize})",
Expand Down Expand Up @@ -421,6 +441,10 @@
"@connectedToUnifiedPushDistributorApp": {
"description": "Tell the user which UnifiedPush app we're connected to"
},
"contentManagement": "Content Management",
"@contentManagement": {
"description": "Setting for content management (languages/blocking)"
},
"controversial": "Controversial",
"@controversial": {},
"copiedToClipboard": "Copied to clipboard",
Expand Down Expand Up @@ -589,6 +613,10 @@
"@discussionLanguagesTooltip": {},
"dismissRead": "Dismiss Read",
"@dismissRead": {},
"displayName": "Display Name",
"@displayName": {
"description": "Label for display name"
},
"displayUserScore": "Display User Scores (Karma).",
"@displayUserScore": {
"description": "Option for displaying user scores or karma."
Expand Down Expand Up @@ -629,6 +657,10 @@
"@editPost": {
"description": "Title when editing a post."
},
"email": "Email",
"@email": {
"description": "Label for email input"
},
"empty": "Empty",
"@empty": {},
"emptyInbox": "Empty Inbox",
Expand Down Expand Up @@ -825,6 +857,14 @@
"@green": {
"description": "The color green"
},
"guestModeFeedSettings": "Guest Mode Feed Settings",
"@guestModeFeedSettings": {
"description": "Feed settings for guest accounts"
},
"guestModeFeedSettingsLabel": "The following settings are only applied to guest accounts. To adjust feed settings for your account, go to Account Settings.",
"@guestModeFeedSettingsLabel": {
"description": "Description for guest mode feed settings"
},
"havingIssuesWithNotifications": "Having issues with notifications?",
"@havingIssuesWithNotifications": {
"description": "A shortcut to navigate to the notification debugging section"
Expand Down Expand Up @@ -929,6 +969,10 @@
"@instanceNameThickness": {
"description": "Setting for instance name thickness"
},
"instances": "Instances",
"@instances": {
"description": "Title for settings related to instances"
},
"internetOrInstanceIssues": "You may not be connected to the Internet, or your instance may be currently unavailable.",
"@internetOrInstanceIssues": {},
"keywordFilterDescription": "Filters posts containing any keywords in the title or body",
Expand Down Expand Up @@ -1055,6 +1099,10 @@
"@markReadColor": {
"description": "Name of mark read/unread color setting"
},
"matrixUser": "Matrix User",
"@matrixUser": {
"description": "Label for Matrix user id"
},
"me": "Me",
"@me": {
"description": "Label for the current user."
Expand Down Expand Up @@ -1193,6 +1241,14 @@
"@noDiscussionLanguages": {
"description": "Message for no discussion languages added"
},
"noDisplayNameSet": "No display name set",
"@noDisplayNameSet": {
"description": "Message for no display name set"
},
"noEmailSet": "No email set",
"@noEmailSet": {
"description": "Message for no email set"
},
"noFavoritedCommunities": "No favorited communities",
"@noFavoritedCommunities": {
"description": "Message for no favorited communities on the drawer"
Expand All @@ -1211,8 +1267,16 @@
"@noLanguage": {
"description": "The entry for no language when selecting a post language"
},
"noMatrixUserSet": "No matrix user set",
"@noMatrixUserSet": {
"description": "Message for no matrix user set"
},
"noPostsFound": "No posts found.",
"@noPostsFound": {},
"noProfileBioSet": "No profile bio set",
"@noProfileBioSet": {
"description": "Message for no profile bio set"
},
"noReplies": "No replies",
"@noReplies": {
"description": "Label for when there are no replies in the list"
Expand Down Expand Up @@ -1417,6 +1481,10 @@
"@preview": {},
"profileAppliedSuccessfully": "{profile} applied successfully!",
"@profileAppliedSuccessfully": {},
"profileBio": "Profile Bio",
"@profileBio": {
"description": "Setting for profile bio"
},
"profiles": "Profiles",
"@profiles": {},
"pureBlack": "Pure Black",
Expand Down Expand Up @@ -1705,6 +1773,10 @@
"@setLongPress": {},
"setShortPress": "Set as short-press action",
"@setShortPress": {},
"settingOverrideLabel": "These settings override Thunder's default settings.",
"@settingOverrideLabel": {
"description": "Message which indicates that the (instance) settings override the app settings"
},
"settingTypeNotSupported": "Settings of type {settingType} are not yet supported.",
"@settingTypeNotSupported": {},
"settings": "Settings",
Expand Down Expand Up @@ -1827,6 +1899,10 @@
"@showNavigationLabelsDescription": {
"description": "Description for setting for showing navigation labels"
},
"showNsfwContent": "Show NSFW Content",
"@showNsfwContent": {
"description": "Toggle to show NSFW content."
},
"showPassword": "Show Password",
"@showPassword": {},
"showPostAuthor": "Show Post Author",
Expand Down
9 changes: 7 additions & 2 deletions lib/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import 'package:thunder/settings/pages/theme_settings_page.dart';
import 'package:thunder/settings/pages/video_player_settings.dart';
import 'package:thunder/settings/settings.dart';
import 'package:thunder/thunder/thunder.dart';
import 'package:thunder/user/bloc/user_settings_bloc.dart';
import 'package:thunder/user/pages/user_settings_page.dart';

PageController thunderPageController = PageController(initialPage: 0);
Expand Down Expand Up @@ -144,8 +145,12 @@ final GoRouter router = GoRouter(
name: 'account',
path: 'account',
builder: (context, state) {
return BlocProvider.value(
value: (state.extra! as List)[0] as ThunderBloc,
UserSettingsBloc userSettingsBloc = UserSettingsBloc();
return MultiBlocProvider(
providers: [
BlocProvider.value(value: (state.extra! as List)[0] as ThunderBloc),
BlocProvider.value(value: userSettingsBloc),
],
child: UserSettingsPage(settingToHighlight: (state.extra! as List).elementAtOrNull(1) as LocalSettings?),
);
},
Expand Down
Loading
Loading