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

Initial ability to view post/comment reports #1210

Merged
merged 10 commits into from
Mar 27, 2024
50 changes: 47 additions & 3 deletions lib/community/widgets/community_drawer.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import 'dart:io';
import 'dart:math';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'package:lemmy_api_client/v3.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:swipeable_page_route/swipeable_page_route.dart';

import 'package:thunder/account/bloc/account_bloc.dart';
import 'package:thunder/account/utils/profiles.dart';
import 'package:thunder/community/bloc/anonymous_subscriptions_bloc.dart';
import 'package:thunder/core/auth/bloc/auth_bloc.dart';
import 'package:thunder/feed/feed.dart';
import 'package:thunder/moderator/view/report_page.dart';
import 'package:thunder/shared/avatars/community_avatar.dart';
import 'package:thunder/shared/avatars/user_avatar.dart';
import 'package:thunder/thunder/bloc/thunder_bloc.dart';
Expand All @@ -33,8 +38,8 @@ class _CommunityDrawerState extends State<CommunityDrawer> {
void initState() {
super.initState();

context.read<AccountBloc>().add(GetAccountSubscriptions());
context.read<AccountBloc>().add(GetFavoritedCommunities());
context.read<AccountBloc>().add(const GetAccountSubscriptions());
context.read<AccountBloc>().add(const GetFavoritedCommunities());
}

@override
Expand Down Expand Up @@ -149,9 +154,11 @@ class FeedDrawerItems extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);
final l10n = AppLocalizations.of(context)!;
final feedBloc = context.watch<FeedBloc>();

FeedState feedState = context.watch<FeedBloc>().state;
FeedState feedState = feedBloc.state;
ThunderState thunderState = context.read<ThunderBloc>().state;
AccountState accountState = context.watch<AccountBloc>().state;

bool isLoggedIn = context.watch<AuthBloc>().state.isLoggedIn;

Expand All @@ -178,6 +185,36 @@ class FeedDrawerItems extends StatelessWidget {
},
).toList(),
),
if (accountState.moderates.isNotEmpty || accountState.personView?.isAdmin == true)
DrawerItem(
label: l10n.report(2),
onTap: () async {
HapticFeedback.mediumImpact();
ThunderBloc thunderBloc = context.read<ThunderBloc>();

await Navigator.of(context).push(
SwipeablePageRoute(
transitionDuration: thunderBloc.state.reduceAnimations ? const Duration(milliseconds: 100) : null,
backGestureDetectionStartOffset: !kIsWeb && Platform.isAndroid ? 45 : 0,
backGestureDetectionWidth: 45,
canOnlySwipeFromEdge: true,
builder: (otherContext) {
return MultiBlocProvider(
providers: [
BlocProvider.value(value: feedBloc),
BlocProvider.value(value: thunderBloc),
],
child: const ReportFeedPage(),
);
},
),
);
},
icon: Icons.report_rounded,
trailing: const Icon(Icons.arrow_forward_rounded),
disabled: false,
isSelected: false,
),
],
);
}
Expand Down Expand Up @@ -409,6 +446,7 @@ class DrawerItem extends StatelessWidget {
final VoidCallback onTap;
final String label;
final IconData icon;
final Widget? trailing;

final bool disabled;
final bool isSelected;
Expand All @@ -418,6 +456,7 @@ class DrawerItem extends StatelessWidget {
required this.onTap,
required this.label,
required this.icon,
this.trailing,
this.disabled = false,
required this.isSelected,
});
Expand Down Expand Up @@ -450,6 +489,11 @@ class DrawerItem extends StatelessWidget {
label,
style: disabled ? theme.textTheme.bodyMedium?.copyWith(color: theme.dividerColor) : null,
),
if (trailing != null) ...[
const Spacer(),
trailing!,
const SizedBox(width: 16),
]
],
),
],
Expand Down
8 changes: 5 additions & 3 deletions lib/community/widgets/post_card_view_compact.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class PostCardViewCompact extends StatelessWidget {
final ListingType? listingType;
final void Function({PostViewMedia? postViewMedia})? navigateToPost;
final bool? indicateRead;
final bool showMedia;

const PostCardViewCompact({
super.key,
Expand All @@ -32,6 +33,7 @@ class PostCardViewCompact extends StatelessWidget {
required this.listingType,
this.navigateToPost,
this.indicateRead,
this.showMedia = true,
});

@override
Expand All @@ -58,11 +60,11 @@ class PostCardViewCompact extends StatelessWidget {

return Container(
color: indicateRead && postViewMedia.postView.read ? theme.colorScheme.onBackground.withOpacity(darkTheme ? 0.05 : 0.075) : null,
padding: const EdgeInsets.only(bottom: 8.0, top: 6),
padding: showMedia ? const EdgeInsets.only(bottom: 8.0, top: 6) : const EdgeInsets.only(left: 4.0, top: 10.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
!showThumbnailPreviewOnRight && (postViewMedia.media.first.mediaType == MediaType.text ? showTextPostIndicator : true)
!showThumbnailPreviewOnRight && showMedia && (postViewMedia.media.first.mediaType == MediaType.text ? showTextPostIndicator : true)
? ThumbnailPreview(
postViewMedia: postViewMedia,
navigateToPost: navigateToPost,
Expand Down Expand Up @@ -166,7 +168,7 @@ class PostCardViewCompact extends StatelessWidget {
],
),
),
showThumbnailPreviewOnRight && (postViewMedia.media.first.mediaType == MediaType.text ? showTextPostIndicator : true)
showThumbnailPreviewOnRight && showMedia && (postViewMedia.media.first.mediaType == MediaType.text ? showTextPostIndicator : true)
? ThumbnailPreview(
postViewMedia: postViewMedia,
navigateToPost: navigateToPost,
Expand Down
1 change: 1 addition & 0 deletions lib/feed/widgets/feed_page_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ class FeedAppBarGeneralActions extends StatelessWidget {
},
),
PopupMenuButton(
onOpened: () => HapticFeedback.mediumImpact(),
itemBuilder: (context) => [
ThunderPopupMenuItem(
onTap: () async {
Expand Down
14 changes: 13 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@
"@replyToPost": {},
"replyingTo": "Replying to {author}",
"@replyingTo": {},
"report": "Report",
"report": "{count, plural, zero {Report} one {Report} other {Reports} } ",
"@report": {},
"reportComment": "Report Comment",
"@reportComment": {},
Expand Down Expand Up @@ -1521,6 +1521,10 @@
"@spoiler": {
"description": "Placeholder label for spoiler"
},
"status": "Status",
"@status": {
"description": "Status of the action"
},
"submit": "Submit",
"@submit": {},
"subscribe": "Subscribe",
Expand Down Expand Up @@ -1687,6 +1691,10 @@
"@unableToNavigateToInstance": {
"description": "Error message for when we can't navigate to a Lemmy instance"
},
"unableToResolveReport": "Unable to resolve report",
"@unableToResolveReport": {
"description": "Error message when we are unable to resolve a report"
},
"unableToRetrieveChangelog": "Unable to retrieve changelog for version {version}.",
"@unableToRetrieveChangelog": {
"description": "Error message for when we are unable to retrieve the changelog."
Expand Down Expand Up @@ -1733,6 +1741,10 @@
"@unreachable": {
"description": "Describes an instance that is currently unreachable"
},
"unresolved": "Unresolved",
"@unresolved": {
"description": "Description for unresolved status (e.g., unresolved reports)"
},
"unsubscribe": "Unsubscribe",
"@unsubscribe": {},
"unsubscribeFromCommunity": "Unsubscribe from Community",
Expand Down
Loading
Loading