Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
4 changes: 2 additions & 2 deletions lib/account/pages/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
isLoading = false;
});

showSnackbar(context, AppLocalizations.of(context)!.loginFailed(state.errorMessage ?? AppLocalizations.of(context)!.missingErrorMessage));
showSnackbar(AppLocalizations.of(context)!.loginFailed(state.errorMessage ?? AppLocalizations.of(context)!.missingErrorMessage));
} else if (state.status == AuthStatus.success && context.read<AuthBloc>().state.isLoggedIn) {
context.pop();

showSnackbar(context, AppLocalizations.of(context)!.loginSucceeded);
showSnackbar(AppLocalizations.of(context)!.loginSucceeded);
}
},
),
Expand Down
672 changes: 334 additions & 338 deletions lib/account/widgets/profile_modal_body.dart

Large diffs are not rendered by default.

28 changes: 6 additions & 22 deletions lib/community/pages/create_post_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'package:shared_preferences/shared_preferences.dart';

import 'package:thunder/account/models/account.dart';
import 'package:thunder/community/bloc/image_bloc.dart';
import 'package:thunder/community/utils/post_card_action_helpers.dart';
import 'package:thunder/core/auth/bloc/auth_bloc.dart';
import 'package:thunder/core/auth/helpers/fetch_account.dart';
import 'package:thunder/core/enums/local_settings.dart';
Expand Down Expand Up @@ -62,9 +63,6 @@ class CreatePostPage extends StatefulWidget {
/// Callback function that is triggered whenever the post is successfully created or updated
final Function(PostViewMedia postViewMedia)? onPostSuccess;

// The scaffold key for the main Thunder page
final GlobalKey<ScaffoldMessengerState>? scaffoldMessengerKey;

const CreatePostPage({
super.key,
required this.communityId,
Expand All @@ -76,7 +74,6 @@ class CreatePostPage extends StatefulWidget {
this.prePopulated = false,
this.postView,
this.onPostSuccess,
this.scaffoldMessengerKey,
});

@override
Expand Down Expand Up @@ -218,7 +215,7 @@ class _CreatePostPageState extends State<CreatePostPage> {

if (draftPost.isNotEmpty && draftPost.saveAsDraft) {
sharedPreferences?.setString(draftId, jsonEncode(draftPost.toJson()));
if (context.mounted) showSnackbar(context, AppLocalizations.of(context)!.postSavedAsDraft);
showSnackbar(l10n.postSavedAsDraft);
} else {
sharedPreferences?.remove(draftId);
}
Expand Down Expand Up @@ -260,7 +257,6 @@ class _CreatePostPageState extends State<CreatePostPage> {

if (context.mounted && draftPost.isNotEmpty) {
showSnackbar(
context,
AppLocalizations.of(context)!.restoredPostFromDraft,
trailingIcon: Icons.delete_forever_rounded,
trailingIconColor: Theme.of(context).colorScheme.errorContainer,
Expand Down Expand Up @@ -306,7 +302,7 @@ class _CreatePostPageState extends State<CreatePostPage> {
}

if (state.status == CreatePostStatus.error && state.message != null) {
showSnackbar(context, state.message!);
showSnackbar(state.message!);
context.read<CreatePostCubit>().clearMessage();
}

Expand All @@ -319,7 +315,7 @@ class _CreatePostPageState extends State<CreatePostPage> {
break;
case CreatePostStatus.imageUploadFailure:
case CreatePostStatus.postImageUploadFailure:
showSnackbar(context, l10n.postUploadImageError, leadingIcon: Icons.warning_rounded, leadingIconColor: theme.colorScheme.errorContainer);
showSnackbar(l10n.postUploadImageError, leadingIcon: Icons.warning_rounded, leadingIconColor: theme.colorScheme.errorContainer);
default:
break;
}
Expand All @@ -342,10 +338,10 @@ class _CreatePostPageState extends State<CreatePostPage> {
child: IconButton(
onPressed: isSubmitButtonDisabled
? null
: () async {
: () {
draftPost.saveAsDraft = false;

final int? postId = await context.read<CreatePostCubit>().createOrEditPost(
context.read<CreatePostCubit>().createOrEditPost(
communityId: communityId!,
name: _titleTextController.text,
body: _bodyTextController.text,
Expand All @@ -354,18 +350,6 @@ class _CreatePostPageState extends State<CreatePostPage> {
postIdBeingEdited: widget.postView?.post.id,
languageId: languageId,
);

if (context.mounted && widget.scaffoldMessengerKey?.currentContext != null && widget.postView?.post.id == null && postId != null) {
showSnackbar(
context,
l10n.postCreatedSuccessfully,
trailingIcon: Icons.remove_red_eye_rounded,
trailingAction: () {
navigateToPost(widget.scaffoldMessengerKey!.currentContext!, postId: postId);
},
customState: widget.scaffoldMessengerKey?.currentState,
);
}
},
icon: Icon(
widget.postView != null ? Icons.edit_rounded : Icons.send_rounded,
Expand Down
4 changes: 2 additions & 2 deletions lib/community/utils/post_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ void triggerPostAction({
bool downvotesEnabled = context.read<AuthBloc>().state.downvotesEnabled;

if (downvotesEnabled == false) {
showSnackbar(context, AppLocalizations.of(context)!.downvotesDisabled);
showSnackbar(AppLocalizations.of(context)!.downvotesDisabled);
return;
}

onVoteAction(postViewMedia.postView.post.id, voteType == -1 ? 0 : -1);
return;
case SwipeAction.reply:
case SwipeAction.edit:
showSnackbar(context, AppLocalizations.of(context)!.replyNotSupported);
showSnackbar(AppLocalizations.of(context)!.replyNotSupported);
break;
case SwipeAction.save:
onSaveAction(postViewMedia.postView.post.id, !(saved ?? false));
Expand Down
7 changes: 2 additions & 5 deletions lib/community/utils/post_card_action_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -308,20 +308,17 @@ void onSelected(BuildContext context, PostCardAction postCardAction, PostViewMed

if (media == null) {
// Tell user we're downloading the image
showSnackbar(context, AppLocalizations.of(context)!.downloadingMedia);
showSnackbar(AppLocalizations.of(context)!.downloadingMedia);

// Download
mediaFile = await DefaultCacheManager().getSingleFile(postViewMedia.media.first.mediaUrl!);

// Hide snackbar
hideSnackbar(context);
}

// Share
await Share.shareXFiles([XFile(mediaFile!.path)]);
} catch (e) {
// Tell the user that the download failed
showSnackbar(context, AppLocalizations.of(context)!.errorDownloadingMedia(e));
showSnackbar(AppLocalizations.of(context)!.errorDownloadingMedia(e));
}
}
break;
Expand Down
30 changes: 2 additions & 28 deletions lib/community/widgets/community_sidebar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:thunder/core/enums/full_name_separator.dart';
import 'package:thunder/core/singletons/lemmy_client.dart';
import 'package:thunder/feed/bloc/feed_bloc.dart';
import 'package:thunder/instance/instance_view.dart';
import 'package:thunder/post/utils/navigate_create_post.dart';
import 'package:thunder/shared/common_markdown_body.dart';
import 'package:thunder/shared/snackbar.dart';
import 'package:thunder/shared/avatars/user_avatar.dart';
Expand Down Expand Up @@ -291,7 +292,6 @@ class BlockCommunityButton extends StatelessWidget {
onPressed: isUserLoggedIn
? () {
HapticFeedback.heavyImpact();
hideSnackbar(context);
context.read<CommunityBloc>().add(CommunityActionEvent(communityAction: CommunityAction.block, communityId: communityView.community.id, value: !blocked));
}
: null,
Expand Down Expand Up @@ -332,33 +332,7 @@ class CommunityActions extends StatelessWidget {
onPressed: isUserLoggedIn
? () async {
HapticFeedback.mediumImpact();
CommunityBloc communityBloc = context.read<CommunityBloc>();
AccountBloc accountBloc = context.read<AccountBloc>();
ThunderBloc thunderBloc = context.read<ThunderBloc>();
FeedBloc feedBloc = context.read<FeedBloc>();

final ThunderState state = context.read<ThunderBloc>().state;
final bool reduceAnimations = state.reduceAnimations;

Navigator.of(context).push(SwipeablePageRoute(
transitionDuration: reduceAnimations ? const Duration(milliseconds: 100) : null,
canOnlySwipeFromEdge: true,
backGestureDetectionWidth: 45,
builder: (context) {
return MultiBlocProvider(
providers: [
BlocProvider<CommunityBloc>.value(value: communityBloc),
BlocProvider<AccountBloc>.value(value: accountBloc),
BlocProvider<ThunderBloc>.value(value: thunderBloc),
BlocProvider<FeedBloc>.value(value: feedBloc),
],
child: CreatePostPage(
communityId: communityView.community.id,
communityView: getCommunityResponse.communityView,
),
);
},
));
navigateToCreatePostPage(context, communityId: communityView.community.id, communityView: getCommunityResponse.communityView);
}
: null,
style: TextButton.styleFrom(
Expand Down
Loading