11package dev.dimension.flare.ui.component.status
22
3- import androidx.compose.foundation.background
43import androidx.compose.foundation.clickable
54import androidx.compose.foundation.layout.Arrangement
65import androidx.compose.foundation.layout.Box
@@ -15,9 +14,12 @@ import androidx.compose.foundation.layout.width
1514import androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridScope
1615import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridItemSpan
1716import androidx.compose.foundation.shape.CircleShape
17+ import androidx.compose.material3.Card
18+ import androidx.compose.material3.CardDefaults
1819import androidx.compose.material3.HorizontalDivider
1920import androidx.compose.material3.MaterialTheme
2021import androidx.compose.material3.Text
22+ import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
2123import androidx.compose.runtime.Composable
2224import androidx.compose.ui.Alignment
2325import androidx.compose.ui.Modifier
@@ -27,6 +29,7 @@ import androidx.compose.ui.platform.LocalUriHandler
2729import androidx.compose.ui.res.stringResource
2830import androidx.compose.ui.unit.Dp
2931import androidx.compose.ui.unit.dp
32+ import androidx.window.core.layout.WindowWidthSizeClass
3033import com.ramcosta.composedestinations.generated.destinations.ServiceSelectRouteDestination
3134import compose.icons.FontAwesomeIcons
3235import compose.icons.fontawesomeicons.Solid
@@ -66,13 +69,17 @@ internal fun LazyStaggeredGridScope.status(
6669 it.itemType
6770 },
6871 ) {
69- Column {
70- val item = get(it)
71- StatusItem (
72- item,
73- detailStatusKey = detailStatusKey,
74- modifier =
75- Modifier
72+ val item = get(it)
73+ AdaptiveCard (
74+ content = {
75+ val windowInfo = currentWindowAdaptiveInfo()
76+ val bigScreen = windowInfo.windowSizeClass.windowWidthSizeClass != WindowWidthSizeClass .COMPACT
77+ Column {
78+ StatusItem (
79+ item,
80+ detailStatusKey = detailStatusKey,
81+ // modifier =
82+ // Modifier
7683// .let {
7784// if (item != null) {
7885// it.sharedBounds(
@@ -90,15 +97,18 @@ internal fun LazyStaggeredGridScope.status(
9097// it
9198// }
9299// }
93- .background(MaterialTheme .colorScheme.background),
94- )
95- if (it != itemCount - 1 ) {
96- HorizontalDivider (
97- color = FlareDividerDefaults .color,
98- thickness = FlareDividerDefaults .thickness,
99- )
100- }
101- }
100+ // .background(MaterialTheme.colorScheme.background),
101+ )
102+
103+ if (it != itemCount - 1 && ! bigScreen) {
104+ HorizontalDivider (
105+ color = FlareDividerDefaults .color,
106+ thickness = FlareDividerDefaults .thickness,
107+ )
108+ }
109+ }
110+ },
111+ )
102112 }
103113 appendState
104114 .onError {
@@ -109,7 +119,11 @@ internal fun LazyStaggeredGridScope.status(
109119 }
110120 }.onLoading {
111121 items(10 ) {
112- OnLoading ()
122+ AdaptiveCard (
123+ content = {
124+ OnLoading ()
125+ },
126+ )
113127 }
114128 }.onEndOfList {
115129 item(
@@ -140,7 +154,11 @@ internal fun LazyStaggeredGridScope.status(
140154 }
141155 onLoading {
142156 items(10 ) {
143- OnLoading ()
157+ AdaptiveCard (
158+ content = {
159+ OnLoading ()
160+ },
161+ )
144162 }
145163 }
146164 onEmpty {
@@ -170,18 +188,55 @@ internal fun LazyStaggeredGridScope.status(
170188 }
171189}
172190
191+ @Composable
192+ private fun AdaptiveCard (
193+ content : @Composable () -> Unit ,
194+ modifier : Modifier = Modifier ,
195+ ) {
196+ val windowInfo = currentWindowAdaptiveInfo()
197+ val bigScreen = windowInfo.windowSizeClass.windowWidthSizeClass != WindowWidthSizeClass .COMPACT
198+ if (bigScreen) {
199+ Card (
200+ modifier =
201+ modifier
202+ .padding(
203+ horizontal = 2 .dp,
204+ vertical = 6 .dp,
205+ ),
206+ elevation = CardDefaults .elevatedCardElevation(),
207+ colors = CardDefaults .elevatedCardColors(),
208+ ) {
209+ content.invoke()
210+ }
211+ } else {
212+ Box (
213+ modifier = modifier,
214+ ) {
215+ content.invoke()
216+ }
217+ }
218+ }
219+
173220@Composable
174221private fun OnLoading (modifier : Modifier = Modifier ) {
175222 Column (
176223 modifier = modifier,
177224 ) {
178225 StatusPlaceholder (
179- modifier = Modifier .padding(horizontal = screenHorizontalPadding),
180- )
181- Spacer (modifier = Modifier .height(8 .dp))
182- HorizontalDivider (
183- modifier = Modifier .alpha(DisabledAlpha ),
226+ modifier =
227+ Modifier
228+ .padding(
229+ horizontal = screenHorizontalPadding,
230+ vertical = 8 .dp,
231+ ),
184232 )
233+ val windowInfo = currentWindowAdaptiveInfo()
234+ val bigScreen = windowInfo.windowSizeClass.windowWidthSizeClass != WindowWidthSizeClass .COMPACT
235+ if (! bigScreen) {
236+ HorizontalDivider (
237+ modifier = Modifier .alpha(DisabledAlpha ),
238+ )
239+ }
185240 }
186241}
187242
0 commit comments