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;
}
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<T extends Item> extends Cubit<CommentsState> {
}
}
}
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<T extends Item> extends Cubit<CommentsState> {
}
}
emit(state.copyWith(
status: CommentsStatus.loaded,
));
if (!isClosed) {
emit(state.copyWith(
status: CommentsStatus.loaded,
));
}
}
}
@ -206,7 +211,7 @@ class CommentsCubit<T extends Item> extends Cubit<CommentsState> {
}
void _onCommentFetched(Comment? comment) {
if (comment != null) {
if (comment != null && !isClosed) {
_cacheService.cacheComment(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)
const SizedBox(
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: 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(),
),
),
],
),
),
],