@@ -50,33 +50,35 @@ fun CommentSection(
5050 val nestedScrollInterop = rememberNestedScrollInteropConnection()
5151 val state = rememberLazyListState()
5252
53- LazyColumnScrollbar (state = state) {
54- LazyColumn (modifier = Modifier .nestedScroll(nestedScrollInterop), state = state) {
55- if (parentComment != null ) {
56- item {
57- CommentRepliesHeader (comment = parentComment)
58- HorizontalDivider (thickness = 1 .dp)
53+ Surface (color = MaterialTheme .colorScheme.background) {
54+ LazyColumnScrollbar (state = state) {
55+ LazyColumn (modifier = Modifier .nestedScroll(nestedScrollInterop), state = state) {
56+ if (parentComment != null ) {
57+ item {
58+ CommentRepliesHeader (comment = parentComment)
59+ HorizontalDivider (thickness = 1 .dp)
60+ }
5961 }
60- }
6162
62- if (itemCount == 0 ) {
63- item {
64- val refresh = comments.loadState.refresh
65- if (refresh is LoadState .Loading ) {
66- LoadingIndicator (modifier = Modifier .padding(top = 8 .dp))
67- } else {
68- val error = (refresh as ? LoadState .Error )?.error
69- val message = if (error is CommentsDisabledException ) {
70- R .string.comments_are_disabled
63+ if (itemCount == 0 ) {
64+ item {
65+ val refresh = comments.loadState.refresh
66+ if (refresh is LoadState .Loading ) {
67+ LoadingIndicator (modifier = Modifier .padding(top = 8 .dp))
7168 } else {
72- R .string.no_comments
69+ val error = (refresh as ? LoadState .Error )?.error
70+ val message = if (error is CommentsDisabledException ) {
71+ R .string.comments_are_disabled
72+ } else {
73+ R .string.no_comments
74+ }
75+ NoItemsMessage (message)
7376 }
74- NoItemsMessage (message)
7577 }
76- }
77- } else {
78- items(itemCount) {
79- Comment (comment = comments[it] !! )
78+ } else {
79+ items(itemCount) {
80+ Comment (comment = comments[it] !! )
81+ }
8082 }
8183 }
8284 }
@@ -116,9 +118,7 @@ private fun CommentSectionPreview(
116118 @PreviewParameter(CommentDataProvider ::class ) pagingData : PagingData <CommentsInfoItem >
117119) {
118120 AppTheme {
119- Surface (color = MaterialTheme .colorScheme.background) {
120- CommentSection (commentsFlow = flowOf(pagingData))
121- }
121+ CommentSection (commentsFlow = flowOf(pagingData))
122122 }
123123}
124124
@@ -142,8 +142,6 @@ private fun CommentRepliesPreview() {
142142 val flow = flowOf(PagingData .from(replies))
143143
144144 AppTheme {
145- Surface (color = MaterialTheme .colorScheme.background) {
146- CommentSection (parentComment = comment, commentsFlow = flow)
147- }
145+ CommentSection (parentComment = comment, commentsFlow = flow)
148146 }
149147}
0 commit comments