Skip to content

Commit 78ca4c5

Browse files
authored
Merge pull request #609 from DimensionDev/feature/theme
update large screen theme and design
2 parents 8dddb2d + 2fc5714 commit 78ca4c5

File tree

3 files changed

+106
-33
lines changed

3 files changed

+106
-33
lines changed

app/src/main/java/dev/dimension/flare/ui/component/status/LazyStatusItems.kt

Lines changed: 79 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package dev.dimension.flare.ui.component.status
22

3-
import androidx.compose.foundation.background
43
import androidx.compose.foundation.clickable
54
import androidx.compose.foundation.layout.Arrangement
65
import androidx.compose.foundation.layout.Box
@@ -15,9 +14,12 @@ import androidx.compose.foundation.layout.width
1514
import androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridScope
1615
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridItemSpan
1716
import androidx.compose.foundation.shape.CircleShape
17+
import androidx.compose.material3.Card
18+
import androidx.compose.material3.CardDefaults
1819
import androidx.compose.material3.HorizontalDivider
1920
import androidx.compose.material3.MaterialTheme
2021
import androidx.compose.material3.Text
22+
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
2123
import androidx.compose.runtime.Composable
2224
import androidx.compose.ui.Alignment
2325
import androidx.compose.ui.Modifier
@@ -27,6 +29,7 @@ import androidx.compose.ui.platform.LocalUriHandler
2729
import androidx.compose.ui.res.stringResource
2830
import androidx.compose.ui.unit.Dp
2931
import androidx.compose.ui.unit.dp
32+
import androidx.window.core.layout.WindowWidthSizeClass
3033
import com.ramcosta.composedestinations.generated.destinations.ServiceSelectRouteDestination
3134
import compose.icons.FontAwesomeIcons
3235
import 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
174221
private 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

app/src/main/java/dev/dimension/flare/ui/screen/profile/ProfileScreen.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -510,14 +510,10 @@ private fun ProfileScreen(
510510
}
511511
},
512512
colors =
513-
if (!bigScreen) {
514-
TopAppBarDefaults.centerAlignedTopAppBarColors(
515-
containerColor = Color.Transparent,
516-
scrolledContainerColor = Color.Transparent,
517-
)
518-
} else {
519-
TopAppBarDefaults.centerAlignedTopAppBarColors()
520-
},
513+
TopAppBarDefaults.centerAlignedTopAppBarColors(
514+
containerColor = Color.Transparent,
515+
scrolledContainerColor = Color.Transparent,
516+
),
521517
modifier =
522518
Modifier.let {
523519
if (!bigScreen) {

app/src/main/java/dev/dimension/flare/ui/theme/Theme.kt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.os.Build
55
import androidx.compose.foundation.isSystemInDarkTheme
66
import androidx.compose.material3.ColorScheme
77
import androidx.compose.material3.MaterialTheme
8+
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
89
import androidx.compose.material3.dynamicDarkColorScheme
910
import androidx.compose.material3.dynamicLightColorScheme
1011
import androidx.compose.runtime.Composable
@@ -15,6 +16,7 @@ import androidx.compose.ui.graphics.luminance
1516
import androidx.compose.ui.platform.LocalContext
1617
import androidx.compose.ui.platform.LocalView
1718
import androidx.core.view.WindowCompat
19+
import androidx.window.core.layout.WindowWidthSizeClass
1820
import com.materialkolor.rememberDynamicColorScheme
1921
import dev.dimension.flare.data.model.LocalAppearanceSettings
2022
import dev.dimension.flare.data.model.Theme
@@ -46,6 +48,20 @@ private fun ColorScheme.withPureColorLightMode(): ColorScheme =
4648
onSurfaceVariant = MoreColors.Gray800,
4749
)
4850

51+
private fun ColorScheme.withPureColorLightModeInBigScreen(): ColorScheme =
52+
copy(
53+
background = MoreColors.Gray50,
54+
surface = MoreColors.Gray50,
55+
onBackground = Color.Black,
56+
onSurface = Color.Black,
57+
surfaceContainer = Color.White,
58+
surfaceContainerLow = Color.White,
59+
surfaceContainerHigh = Color.White,
60+
surfaceContainerLowest = Color.White,
61+
surfaceContainerHighest = Color.White,
62+
onSurfaceVariant = Color.Black,
63+
)
64+
4965
private fun ColorScheme.withPureColorDarkMode(): ColorScheme =
5066
copy(
5167
background = Color.Black,
@@ -69,6 +85,8 @@ fun FlareTheme(
6985
) {
7086
val seed = Color(LocalAppearanceSettings.current.colorSeed)
7187
val pureColorMode = LocalAppearanceSettings.current.pureColorMode
88+
val windowInfo = currentWindowAdaptiveInfo()
89+
val bigScreen = windowInfo.windowSizeClass.windowWidthSizeClass == WindowWidthSizeClass.EXPANDED
7290
val colorScheme =
7391
when {
7492
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
@@ -90,7 +108,11 @@ fun FlareTheme(
90108
dynamicLightColorScheme(context)
91109
.let {
92110
if (pureColorMode) {
93-
it.withPureColorLightMode()
111+
if (bigScreen) {
112+
it.withPureColorLightModeInBigScreen()
113+
} else {
114+
it.withPureColorLightMode()
115+
}
94116
} else {
95117
it
96118
}

0 commit comments

Comments
 (0)