From cf366927bcf1af5f56adaa919f5dbd0f30110fae Mon Sep 17 00:00:00 2001 From: Livinglist Date: Tue, 8 Mar 2022 18:34:24 -0800 Subject: [PATCH] improved UI. --- lib/cubits/comments/comments_cubit.dart | 21 +++++++----- lib/screens/story/story_screen.dart | 6 ---- lib/screens/widgets/comment_tile.dart | 45 ++++++++++++------------- 3 files changed, 34 insertions(+), 38 deletions(-) diff --git a/lib/cubits/comments/comments_cubit.dart b/lib/cubits/comments/comments_cubit.dart index 3818878..545ee0a 100644 --- a/lib/cubits/comments/comments_cubit.dart +++ b/lib/cubits/comments/comments_cubit.dart @@ -40,6 +40,8 @@ class CommentsCubit extends Cubit { return; } + emit(state.copyWith(status: CommentsStatus.loading)); + if (state.item is Story) { final story = state.item; final updatedStory = state.offlineReading @@ -68,10 +70,11 @@ class CommentsCubit extends Cubit { } } } - - emit(state.copyWith( - status: CommentsStatus.loaded, - )); + if (!isClosed) { + emit(state.copyWith( + status: CommentsStatus.loaded, + )); + } } else { final comment = state.item as Comment; @@ -97,9 +100,11 @@ class CommentsCubit extends Cubit { } } - emit(state.copyWith( - status: CommentsStatus.loaded, - )); + if (!isClosed) { + emit(state.copyWith( + status: CommentsStatus.loaded, + )); + } } } @@ -206,7 +211,7 @@ class CommentsCubit extends Cubit { } void _onCommentFetched(Comment? comment) { - if (comment != null) { + if (comment != null && !isClosed) { _cacheService.cacheComment(comment); emit(state.copyWith(comments: List.from(state.comments)..add(comment))); } diff --git a/lib/screens/story/story_screen.dart b/lib/screens/story/story_screen.dart index ed8271a..475b309 100644 --- a/lib/screens/story/story_screen.dart +++ b/lib/screens/story/story_screen.dart @@ -471,12 +471,6 @@ class _StoryScreenState extends State { if (state.comments.length == state.item.kids.length) const SizedBox( height: 240, - child: Center( - child: Text( - 'The End', - style: TextStyle(color: Colors.grey), - ), - ), ), ], ), diff --git a/lib/screens/widgets/comment_tile.dart b/lib/screens/widgets/comment_tile.dart index 28c3aa9..e6dcfe7 100644 --- a/lib/screens/widgets/comment_tile.dart +++ b/lib/screens/widgets/comment_tile.dart @@ -209,31 +209,28 @@ class CommentTile extends StatelessWidget { Padding( padding: const EdgeInsets.only(left: 12), child: Column( - children: state.comments - .map( - (e) => FadeIn( - child: CommentTile( - comment: e, - onlyShowTargetComment: - onlyShowTargetComment && - targetComments.length > 1, - targetComments: targetComments - .isNotEmpty - ? targetComments.sublist( - 0, - max(targetComments.length - 1, - 0)) - : [], - myUsername: myUsername, - onReplyTapped: onReplyTapped, - onMoreTapped: onMoreTapped, - onEditTapped: onEditTapped, - level: level + 1, - onStoryLinkTapped: onStoryLinkTapped, - ), + children: [ + ...state.comments.map( + (e) => FadeIn( + child: CommentTile( + comment: e, + onlyShowTargetComment: + onlyShowTargetComment && + targetComments.length > 1, + targetComments: targetComments.isNotEmpty + ? targetComments.sublist(0, + max(targetComments.length - 1, 0)) + : [], + myUsername: myUsername, + onReplyTapped: onReplyTapped, + onMoreTapped: onMoreTapped, + onEditTapped: onEditTapped, + level: level + 1, + onStoryLinkTapped: onStoryLinkTapped, ), - ) - .toList(), + ), + ), + ], ), ), ],