improved UI.

This commit is contained in:
Livinglist
2022-03-08 18:34:24 -08:00
parent 26ffe7535f
commit cf366927bc
3 changed files with 34 additions and 38 deletions

View File

@ -40,6 +40,8 @@ class CommentsCubit<T extends Item> extends Cubit<CommentsState> {
return; return;
} }
emit(state.copyWith(status: CommentsStatus.loading));
if (state.item is Story) { if (state.item is Story) {
final story = state.item; final story = state.item;
final updatedStory = state.offlineReading final updatedStory = state.offlineReading
@ -68,10 +70,11 @@ class CommentsCubit<T extends Item> extends Cubit<CommentsState> {
} }
} }
} }
if (!isClosed) {
emit(state.copyWith( emit(state.copyWith(
status: CommentsStatus.loaded, status: CommentsStatus.loaded,
)); ));
}
} else { } else {
final comment = state.item as Comment; final comment = state.item as Comment;
@ -97,9 +100,11 @@ class CommentsCubit<T extends Item> extends Cubit<CommentsState> {
} }
} }
emit(state.copyWith( if (!isClosed) {
status: CommentsStatus.loaded, emit(state.copyWith(
)); status: CommentsStatus.loaded,
));
}
} }
} }
@ -206,7 +211,7 @@ class CommentsCubit<T extends Item> extends Cubit<CommentsState> {
} }
void _onCommentFetched(Comment? comment) { void _onCommentFetched(Comment? comment) {
if (comment != null) { if (comment != null && !isClosed) {
_cacheService.cacheComment(comment); _cacheService.cacheComment(comment);
emit(state.copyWith(comments: List.from(state.comments)..add(comment))); emit(state.copyWith(comments: List.from(state.comments)..add(comment)));
} }

View File

@ -471,12 +471,6 @@ class _StoryScreenState extends State<StoryScreen> {
if (state.comments.length == state.item.kids.length) if (state.comments.length == state.item.kids.length)
const SizedBox( const SizedBox(
height: 240, height: 240,
child: Center(
child: Text(
'The End',
style: TextStyle(color: Colors.grey),
),
),
), ),
], ],
), ),

View File

@ -209,31 +209,28 @@ class CommentTile extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.only(left: 12), padding: const EdgeInsets.only(left: 12),
child: Column( child: Column(
children: state.comments children: [
.map( ...state.comments.map(
(e) => FadeIn( (e) => FadeIn(
child: CommentTile( child: CommentTile(
comment: e, comment: e,
onlyShowTargetComment: onlyShowTargetComment:
onlyShowTargetComment && onlyShowTargetComment &&
targetComments.length > 1, targetComments.length > 1,
targetComments: targetComments targetComments: targetComments.isNotEmpty
.isNotEmpty ? targetComments.sublist(0,
? targetComments.sublist( max(targetComments.length - 1, 0))
0, : [],
max(targetComments.length - 1, myUsername: myUsername,
0)) onReplyTapped: onReplyTapped,
: [], onMoreTapped: onMoreTapped,
myUsername: myUsername, onEditTapped: onEditTapped,
onReplyTapped: onReplyTapped, level: level + 1,
onMoreTapped: onMoreTapped, onStoryLinkTapped: onStoryLinkTapped,
onEditTapped: onEditTapped,
level: level + 1,
onStoryLinkTapped: onStoryLinkTapped,
),
), ),
) ),
.toList(), ),
],
), ),
), ),
], ],