Skip to content

Commit

Permalink
fixed slight issue where comment modal would not pop up
Browse files Browse the repository at this point in the history
  • Loading branch information
hjiangsu committed Jul 1, 2023
1 parent 8927816 commit e872889
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Added initial support for viewing user profiles - including their posts and comments
- Added top sort options - contribution from @JulianPaulus
- Upvoting and downvoting posts/comments now provides you with immediate feedback rather than waiting for the instance to respond back
- Added initial ability to edit comments. This action replaces the reply action when swiping on your own comment

### Changed
- Adjusted thickness of divider between posts to help differentiate
Expand Down
6 changes: 3 additions & 3 deletions lib/post/widgets/comment_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ class _CommentCardState extends State<CommentCard> with SingleTickerProviderStat

final bool isOwnComment = widget.commentViewTree.comment?.creator.name == context.read<AuthBloc>().state.account?.username;

print(isOwnComment);

final bool isUserLoggedIn = context.read<AuthBloc>().state.isLoggedIn;

bool collapseParentCommentOnGesture = context.read<ThunderBloc>().state.preferences?.getBool('setting_comments_collapse_parent_comment_on_gesture') ?? true;
Expand Down Expand Up @@ -157,6 +155,8 @@ class _CommentCardState extends State<CommentCard> with SingleTickerProviderStat
if (swipeAction == SwipeAction.edit) {
PostBloc postBloc = context.read<PostBloc>();

print('editing');

showModalBottomSheet(
isScrollControlled: true,
context: context,
Expand Down Expand Up @@ -234,7 +234,7 @@ class _CommentCardState extends State<CommentCard> with SingleTickerProviderStat
duration: const Duration(milliseconds: 200),
child: SizedBox(
width: MediaQuery.of(context).size.width * dismissThreshold,
child: Icon(dismissThreshold < secondActionThreshold ? Icons.reply : Icons.star_rounded),
child: Icon(dismissThreshold < secondActionThreshold ? (isOwnComment ? Icons.edit : Icons.reply) : Icons.star_rounded),
),
),
child: Column(
Expand Down
16 changes: 9 additions & 7 deletions lib/post/widgets/create_comment_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ class _CreateCommentModalState extends State<CreateCommentModal> {
if (widget.isEdit) {
String content = widget.commentView?.comment?.comment.content ?? '';

setState(() {
description = content;
});
setState(() => description = content);

_bodyTextController.value = TextEditingValue(
text: content,
Expand All @@ -76,12 +74,16 @@ class _CreateCommentModalState extends State<CreateCommentModal> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return BlocBuilder<PostBloc, PostState>(
builder: (context, state) {
return BlocConsumer<PostBloc, PostState>(
listenWhen: (previous, current) {
return previous.status != current.status;
},
listener: (context, state) {
if (state.status == PostStatus.success) {
Navigator.of(context).pop();
}

},
builder: (context, state) {
return SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
Expand All @@ -99,7 +101,7 @@ class _CreateCommentModalState extends State<CreateCommentModal> {
? null
: () {
if (widget.isEdit) {
context.read<PostBloc>().add(EditCommentEvent(content: _bodyTextController.text, commentId: widget.commentView!.comment!.comment.id));
return context.read<PostBloc>().add(EditCommentEvent(content: _bodyTextController.text, commentId: widget.commentView!.comment!.comment.id));
}

if (widget.comment != null) {
Expand Down

0 comments on commit e872889

Please sign in to comment.