Skip to content

Commit df11e53

Browse files
committed
Refactor EmptyStateComposable to remove modifier from EmptyStateSpec and fix modifier usage ...
1 parent 1d94fd1 commit df11e53

1 file changed

Lines changed: 17 additions & 27 deletions

File tree

app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateComposable.kt

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.schabi.newpipe.ui.emptystate
33
import android.graphics.Color
44
import androidx.compose.foundation.layout.Arrangement
55
import androidx.compose.foundation.layout.Column
6-
import androidx.compose.foundation.layout.fillMaxSize
76
import androidx.compose.foundation.layout.fillMaxWidth
87
import androidx.compose.foundation.layout.heightIn
98
import androidx.compose.foundation.layout.padding
@@ -24,9 +23,9 @@ fun EmptyStateComposable(
2423
spec: EmptyStateSpec,
2524
modifier: Modifier = Modifier,
2625
) = EmptyStateComposable(
27-
modifier = spec.modifier(modifier),
2826
emojiText = spec.emojiText(),
2927
descriptionText = spec.descriptionText(),
28+
modifier = modifier
3029
)
3130

3231
@Composable
@@ -61,54 +60,51 @@ private fun EmptyStateComposable(
6160
@Composable
6261
fun EmptyStateComposableGenericErrorPreview() {
6362
AppTheme {
64-
EmptyStateComposable(EmptyStateSpec.GenericError)
63+
EmptyStateComposable(
64+
spec = EmptyStateSpec.GenericError,
65+
modifier = Modifier
66+
.fillMaxWidth()
67+
.heightIn(min = 128.dp)
68+
)
6569
}
6670
}
6771

6872
@Preview(showBackground = true, backgroundColor = Color.WHITE.toLong())
6973
@Composable
7074
fun EmptyStateComposableNoCommentPreview() {
7175
AppTheme {
72-
EmptyStateComposable(EmptyStateSpec.NoComments)
76+
EmptyStateComposable(
77+
spec = EmptyStateSpec.NoComments,
78+
modifier = Modifier
79+
.fillMaxWidth()
80+
.heightIn(min = 128.dp)
81+
)
7382
}
7483
}
7584

7685
data class EmptyStateSpec(
77-
val modifier: (Modifier) -> Modifier,
7886
val emojiText: @Composable () -> String,
7987
val descriptionText: @Composable () -> String,
8088
) {
8189
companion object {
8290

8391
val GenericError =
8492
EmptyStateSpec(
85-
modifier = {
86-
it
87-
.fillMaxWidth()
88-
.heightIn(min = 128.dp)
89-
},
93+
9094
emojiText = { "¯\\_(ツ)_/¯" },
9195
descriptionText = { stringResource(id = R.string.empty_list_subtitle) },
9296
)
9397

9498
val NoVideos =
9599
EmptyStateSpec(
96-
modifier = {
97-
it
98-
.fillMaxWidth()
99-
.heightIn(min = 128.dp)
100-
},
100+
101101
emojiText = { "(╯°-°)╯" },
102102
descriptionText = { stringResource(id = R.string.no_videos) },
103103
)
104104

105105
val NoComments =
106106
EmptyStateSpec(
107-
modifier = {
108-
it
109-
.fillMaxWidth()
110-
.heightIn(min = 128.dp)
111-
},
107+
112108
emojiText = { "¯\\_(╹x╹)_/¯" },
113109
descriptionText = { stringResource(id = R.string.no_comments) },
114110
)
@@ -120,33 +116,27 @@ data class EmptyStateSpec(
120116

121117
val NoSearchResult =
122118
NoComments.copy(
123-
modifier = { it },
124119
emojiText = { "╰(°●°╰)" },
125120
descriptionText = { stringResource(id = R.string.search_no_results) }
126121
)
127122

128123
val NoSearchMaxSizeResult =
129-
NoSearchResult.copy(
130-
modifier = { it.fillMaxSize() },
131-
)
124+
NoSearchResult
132125

133126
val ContentNotSupported =
134127
NoComments.copy(
135-
modifier = { it.padding(top = 90.dp) },
136128
emojiText = { "(︶︹︺)" },
137129
descriptionText = { stringResource(id = R.string.content_not_supported) },
138130
)
139131

140132
val NoBookmarkedPlaylist =
141133
EmptyStateSpec(
142-
modifier = { it },
143134
emojiText = { "(╥﹏╥)" },
144135
descriptionText = { stringResource(id = R.string.no_playlist_bookmarked_yet) },
145136
)
146137

147138
val NoSubscriptionsHint =
148139
EmptyStateSpec(
149-
modifier = { it },
150140
emojiText = { "(꩜ᯅ꩜)" },
151141
descriptionText = { stringResource(id = R.string.import_subscriptions_hint) },
152142
)

0 commit comments

Comments
 (0)