Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into feature/notifica…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
micahmo committed Jan 12, 2024
2 parents 5018438 + 2495369 commit d22dc2e
Show file tree
Hide file tree
Showing 15 changed files with 774 additions and 674 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
## Unreleased
### Added
- Added ability to subscribe/unsubscribe to community from long press action on posts
- Added option to hide top app bar on scroll

## Changed
- Small UI adjustments for account switcher
- Dynamic Maximum Zoom Level Based on Image Resolution - contribution from @Niranjan-Dorage

### Fixed
- Fixed issue where Thunder was being locked to 60Hz on 120Hz displays on Android
- Fixed issue where subscriptions list in drawer is not respecting alphabetical order
- Fixed issue where long-pressing bottom navigation account icon would not open account switcher

## 0.2.7 - 2024-01-03
## Added
Expand Down
3 changes: 2 additions & 1 deletion lib/account/utils/profiles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ void showProfileModalSheet(BuildContext context, {bool showLogoutDialog = false}
ThunderBloc thunderBloc = context.read<ThunderBloc>();

showModalBottomSheet(
elevation: 0,
isScrollControlled: true,
context: context,
showDragHandle: true,
Expand All @@ -21,7 +22,7 @@ void showProfileModalSheet(BuildContext context, {bool showLogoutDialog = false}
BlocProvider.value(value: thunderBloc),
],
child: FractionallySizedBox(
heightFactor: 0.9,
heightFactor: 0.8,
child: ProfileModalBody(showLogoutDialog: showLogoutDialog),
),
);
Expand Down
691 changes: 333 additions & 358 deletions lib/account/widgets/profile_modal_body.dart

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/community/pages/create_post_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class _CreatePostPageState extends State<CreatePostPage> {
_titleTextController.text = widget.title ?? '';
_bodyTextController.text = widget.text ?? '';
_urlTextController.text = widget.url ?? '';
_getDataFromLink();
_getDataFromLink(updateTitleField: _titleTextController.text.isEmpty);

if (widget.image != null) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
Expand Down
61 changes: 44 additions & 17 deletions lib/community/utils/post_card_action_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,21 @@ import 'package:thunder/utils/global_context.dart';

enum PostCardAction {
visitProfile,
blockUser,
visitCommunity,
subscribeToCommunity,
unsubscribeFromCommunity,
blockCommunity,
visitInstance,
blockInstance,
sharePost,
shareMedia,
shareLink,
blockInstance,
blockCommunity,
upvote,
downvote,
save,
toggleRead,
share,
blockUser,
}

class ExtendedPostCardActions {
Expand All @@ -70,66 +72,80 @@ class ExtendedPostCardActions {
final bool Function(bool isUserLoggedIn)? shouldEnable;
}

final l10n = AppLocalizations.of(GlobalContext.context)!;

final List<ExtendedPostCardActions> postCardActionItems = [
ExtendedPostCardActions(
postCardAction: PostCardAction.visitProfile,
icon: Icons.person_search_rounded,
label: AppLocalizations.of(GlobalContext.context)!.visitUserProfile,
label: l10n.visitUserProfile,
),
ExtendedPostCardActions(
postCardAction: PostCardAction.blockUser,
icon: Icons.block,
label: AppLocalizations.of(GlobalContext.context)!.blockUser,
label: l10n.blockUser,
shouldEnable: (isUserLoggedIn) => isUserLoggedIn,
),
ExtendedPostCardActions(
postCardAction: PostCardAction.visitCommunity,
icon: Icons.home_work_rounded,
label: AppLocalizations.of(GlobalContext.context)!.visitCommunity,
label: l10n.visitCommunity,
),
ExtendedPostCardActions(
postCardAction: PostCardAction.subscribeToCommunity,
icon: Icons.add_circle_outline_rounded,
label: l10n.subscribeToCommunity,
shouldEnable: (isUserLoggedIn) => isUserLoggedIn,
),
ExtendedPostCardActions(
postCardAction: PostCardAction.unsubscribeFromCommunity,
icon: Icons.remove_circle_outline_rounded,
label: l10n.unsubscribeFromCommunity,
shouldEnable: (isUserLoggedIn) => isUserLoggedIn,
),
ExtendedPostCardActions(
postCardAction: PostCardAction.blockCommunity,
icon: Icons.block_rounded,
label: AppLocalizations.of(GlobalContext.context)!.blockCommunity,
label: l10n.blockCommunity,
shouldEnable: (isUserLoggedIn) => isUserLoggedIn,
),
ExtendedPostCardActions(
postCardAction: PostCardAction.visitInstance,
icon: Icons.language,
label: AppLocalizations.of(GlobalContext.context)!.visitInstance,
label: l10n.visitInstance,
),
ExtendedPostCardActions(
postCardAction: PostCardAction.blockInstance,
icon: Icons.block_rounded,
label: AppLocalizations.of(GlobalContext.context)!.blockInstance,
label: l10n.blockInstance,
shouldEnable: (isUserLoggedIn) => isUserLoggedIn,
),
ExtendedPostCardActions(
postCardAction: PostCardAction.sharePost,
icon: Icons.share_rounded,
label: AppLocalizations.of(GlobalContext.context)!.sharePost,
label: l10n.sharePost,
),
ExtendedPostCardActions(
postCardAction: PostCardAction.shareMedia,
icon: Icons.image_rounded,
label: AppLocalizations.of(GlobalContext.context)!.shareMedia,
label: l10n.shareMedia,
),
ExtendedPostCardActions(
postCardAction: PostCardAction.shareLink,
icon: Icons.link_rounded,
label: AppLocalizations.of(GlobalContext.context)!.shareLink,
label: l10n.shareLink,
),
ExtendedPostCardActions(
postCardAction: PostCardAction.upvote,
label: AppLocalizations.of(GlobalContext.context)!.upvote,
label: l10n.upvote,
icon: Icons.arrow_upward_rounded,
color: Colors.orange,
getForegroundColor: (postView) => postView.myVote == 1 ? Colors.orange : null,
shouldEnable: (isUserLoggedIn) => isUserLoggedIn,
),
ExtendedPostCardActions(
postCardAction: PostCardAction.downvote,
label: AppLocalizations.of(GlobalContext.context)!.downvote,
label: l10n.downvote,
icon: Icons.arrow_downward_rounded,
color: Colors.blue,
getForegroundColor: (postView) => postView.myVote == -1 ? Colors.blue : null,
Expand All @@ -138,7 +154,7 @@ final List<ExtendedPostCardActions> postCardActionItems = [
),
ExtendedPostCardActions(
postCardAction: PostCardAction.save,
label: AppLocalizations.of(GlobalContext.context)!.save,
label: l10n.save,
icon: Icons.star_border_rounded,
color: Colors.purple,
getForegroundColor: (postView) => postView.saved ? Colors.purple : null,
Expand All @@ -147,7 +163,7 @@ final List<ExtendedPostCardActions> postCardActionItems = [
),
ExtendedPostCardActions(
postCardAction: PostCardAction.toggleRead,
label: AppLocalizations.of(GlobalContext.context)!.toggelRead,
label: l10n.toggelRead,
icon: Icons.mail_outline_outlined,
color: Colors.teal.shade300,
getOverrideIcon: (postView) => postView.read ? Icons.mark_email_unread_rounded : Icons.mark_email_read_outlined,
Expand All @@ -156,7 +172,7 @@ final List<ExtendedPostCardActions> postCardActionItems = [
ExtendedPostCardActions(
postCardAction: PostCardAction.share,
icon: Icons.share_rounded,
label: AppLocalizations.of(GlobalContext.context)!.share,
label: l10n.share,
)
];

Expand All @@ -177,6 +193,11 @@ void showPostActionBottomModalSheet(
postCardActionItemsToUse.removeWhere((ExtendedPostCardActions postCardActionItem) => postCardActionItem.postCardAction == PostCardAction.blockInstance);
}

// Hide the option to block a community if the user is subscribed to it
if (actionsToInclude.contains(PostCardAction.blockCommunity) && postViewMedia.postView.subscribed != SubscribedType.notSubscribed) {
postCardActionItemsToUse.removeWhere((ExtendedPostCardActions postCardActionItem) => postCardActionItem.postCardAction == PostCardAction.blockCommunity);
}

multiActionsToInclude ??= [];
final multiPostCardActionItemsToUse = postCardActionItems.where((extendedAction) => multiActionsToInclude!.any((action) => extendedAction.postCardAction == action)).toList();

Expand Down Expand Up @@ -332,5 +353,11 @@ void onSelected(BuildContext context, PostCardAction postCardAction, PostViewMed
case PostCardAction.blockUser:
context.read<UserBloc>().add(BlockUserEvent(personId: postViewMedia.postView.creator.id, blocked: true));
break;
case PostCardAction.subscribeToCommunity:
context.read<CommunityBloc>().add(CommunityActionEvent(communityAction: CommunityAction.follow, communityId: postViewMedia.postView.community.id, value: true));
break;
case PostCardAction.unsubscribeFromCommunity:
context.read<CommunityBloc>().add(CommunityActionEvent(communityAction: CommunityAction.follow, communityId: postViewMedia.postView.community.id, value: false));
break;
}
}
1 change: 1 addition & 0 deletions lib/community/widgets/post_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class _PostCardState extends State<PostCard> {
PostCardAction.blockUser,
PostCardAction.blockInstance,
PostCardAction.visitCommunity,
widget.postViewMedia.postView.subscribed == SubscribedType.notSubscribed ? PostCardAction.subscribeToCommunity : PostCardAction.unsubscribeFromCommunity,
PostCardAction.blockCommunity,
],
multiActionsToInclude: [
Expand Down
1 change: 1 addition & 0 deletions lib/community/widgets/post_card_view_comfortable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ class PostCardViewComfortable extends StatelessWidget {
PostCardAction.blockUser,
PostCardAction.blockInstance,
PostCardAction.visitCommunity,
postViewMedia.postView.subscribed == SubscribedType.notSubscribed ? PostCardAction.subscribeToCommunity : PostCardAction.unsubscribeFromCommunity,
PostCardAction.blockCommunity,
],
multiActionsToInclude: [
Expand Down
18 changes: 16 additions & 2 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
"@accessibility": {},
"accessibilityProfilesDescription": "Accessibility profiles allows applying several settings at once to accommodate a particular accessibility requirement.",
"@accessibilityProfilesDescription": {},
"account": "Account",
"@account": {},
"account": "{count, plural, zero {Account} one {Account} other {Accounts} } ",
"@account": {
"description": "Describes the user account"
},
"accountSettings": "Account Settings",
"@accountSettings": {},
"actions": "Actions",
Expand Down Expand Up @@ -251,6 +253,10 @@
"@creator": {
"description": "The creator filter for searches."
},
"crossPostedFrom": "cross-posted from: {postUrl}",
"@crossPostedFrom": {
"description": "Initial heading for text-based cross-post"
},
"crossPostedTo": "Cross-posted to",
"@crossPostedTo": {},
"currentLongPress": "Currently set as long press",
Expand Down Expand Up @@ -885,6 +891,10 @@
"@submit": {},
"subscribe": "Subscribe",
"@subscribe": {},
"subscribeToCommunity": "Subscribe to Community",
"@subscribeToCommunity": {
"description": "Action for subscribing to a community"
},
"subscribed": "Subscribed",
"@subscribed": {},
"subscriptions": "Subscriptions",
Expand Down Expand Up @@ -1005,6 +1015,10 @@
"@unexpectedError": {},
"unsubscribe": "Unsubscribe",
"@unsubscribe": {},
"unsubscribeFromCommunity": "Unsubscribe from Community",
"@unsubscribeFromCommunity": {
"description": "Action for unsubscribing from a community"
},
"unsubscribePending": "Unsubscribe (subscription pending)",
"@unsubscribePending": {},
"unsubscribed": "Unsubscribed",
Expand Down
20 changes: 20 additions & 0 deletions lib/post/pages/post_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import 'package:thunder/post/pages/post_page_success.dart';
import 'package:thunder/post/pages/create_comment_page.dart';
import 'package:thunder/shared/comment_navigator_fab.dart';
import 'package:thunder/shared/comment_sort_picker.dart';
import 'package:thunder/shared/cross_posts.dart';
import 'package:thunder/shared/error_message.dart';
import 'package:thunder/shared/input_dialogs.dart';
import 'package:thunder/shared/snackbar.dart';
Expand Down Expand Up @@ -201,6 +202,25 @@ class _PostPageState extends State<PostPage> {
showSortBottomSheet(context, state);
},
),
PopupMenuButton(
itemBuilder: (context) => [
PopupMenuItem(
onTap: () => createCrossPost(
context,
title: widget.postView?.postView.post.name ?? '',
url: widget.postView?.postView.post.url,
text: widget.postView?.postView.post.body,
postUrl: widget.postView?.postView.post.apId,
),
child: ListTile(
dense: true,
horizontalTitleGap: 5,
leading: const Icon(Icons.repeat_rounded, size: 20),
title: Text(l10n.createNewCrossPost),
),
),
],
),
],
centerTitle: false,
toolbarHeight: 70.0,
Expand Down
2 changes: 1 addition & 1 deletion lib/settings/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SettingsPage extends StatelessWidget {
SettingTopic(title: l10n.gestures, icon: Icons.swipe, path: '/settings/gestures'),
SettingTopic(title: l10n.floatingActionButton, icon: Icons.settings_applications_rounded, path: '/settings/fab'),
SettingTopic(title: l10n.accessibility, icon: Icons.accessibility, path: '/settings/accessibility'),
SettingTopic(title: l10n.account, icon: Icons.person_rounded, path: '/settings/account'),
SettingTopic(title: l10n.account(0), icon: Icons.person_rounded, path: '/settings/account'),
SettingTopic(title: l10n.about, icon: Icons.info_rounded, path: '/settings/about'),
SettingTopic(title: l10n.debug, icon: Icons.developer_mode_rounded, path: '/settings/debug'),
];
Expand Down
30 changes: 22 additions & 8 deletions lib/shared/cross_posts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,7 @@ class _CrossPostsState extends State<CrossPosts> with SingleTickerProviderStateM
),
widget.isNewPost != true
? InkWell(
onTap: () async {
await navigateToCreatePostPage(
context,
title: widget.originalPost!.postView.post.name,
url: widget.originalPost!.postView.post.url,
prePopulated: true,
);
},
onTap: () => createCrossPost(context, title: widget.originalPost!.postView.post.name, url: widget.originalPost!.postView.post.url),
borderRadius: BorderRadius.circular(10),
child: Padding(
padding: const EdgeInsets.all(5),
Expand All @@ -198,3 +191,24 @@ class _CrossPostsState extends State<CrossPosts> with SingleTickerProviderStateM
);
}
}

void createCrossPost(BuildContext context, {required String title, String? url, String? text, String? postUrl}) async {
assert((text == null) == (postUrl == null));

final AppLocalizations l10n = AppLocalizations.of(context)!;

if (url?.isNotEmpty == true) {
text = null;
} else {
final String? quotedText = text?.split('\n').map((value) => '> $value\n').join();
text = "${l10n.crossPostedFrom(postUrl ?? '')}\n\n$quotedText";
}

await navigateToCreatePostPage(
context,
title: title,
url: url,
text: text,
prePopulated: true,
);
}
Loading

0 comments on commit d22dc2e

Please sign in to comment.