Skip to content

Commit 675fd89

Browse files
committed
update browse ui
1 parent b090a52 commit 675fd89

File tree

7 files changed

+49
-88
lines changed

7 files changed

+49
-88
lines changed

app/src/main/java/com/vanced/store/ui/component/AppCard.kt

+21-35
Original file line numberDiff line numberDiff line change
@@ -10,56 +10,42 @@ import com.vanced.store.ui.theme.VSTheme
1010

1111
@Composable
1212
fun BrowseAppCard(
13+
onClick: (() -> Unit)?,
1314
icon: @Composable () -> Unit,
1415
title: @Composable () -> Unit,
1516
description: @Composable () -> Unit,
1617
labels: @Composable () -> Unit,
17-
actions: @Composable () -> Unit,
1818
modifier: Modifier = Modifier,
1919
) {
2020
VSElevatedCard(
21+
onClick = onClick,
2122
modifier = modifier,
2223
shape = VSTheme.shapes.large
2324
) {
24-
Box(
25-
modifier = Modifier
26-
.fillMaxSize()
27-
.padding(VSTheme.spacing.extraLarge)
28-
) {
29-
Row(
30-
modifier = Modifier.align(Alignment.TopEnd),
31-
horizontalArrangement = Arrangement.spacedBy(VSTheme.spacing.extraSmall),
32-
verticalAlignment = Alignment.CenterVertically
25+
Column {
26+
Box(
27+
modifier = Modifier
28+
.clip(VSTheme.shapes.medium)
29+
.fillMaxWidth()
30+
.aspectRatio(1f / 1f)
3331
) {
34-
labels()
32+
icon()
3533
}
36-
Row(
37-
modifier = Modifier
38-
.fillMaxSize()
39-
.align(Alignment.Center),
40-
horizontalArrangement = Arrangement.spacedBy(VSTheme.spacing.large)
34+
Column(
35+
modifier = Modifier.fillMaxWidth().padding(VSTheme.spacing.medium),
36+
verticalArrangement = Arrangement.spacedBy(VSTheme.spacing.small)
4137
) {
42-
Box(modifier = Modifier.clip(VSTheme.shapes.medium)) {
43-
icon()
38+
ProvideTextStyle(VSTheme.typography.titleMedium) {
39+
title()
40+
}
41+
ProvideTextStyle(VSTheme.typography.bodySmall) {
42+
description()
4443
}
45-
Column(
46-
modifier = Modifier
47-
.fillMaxWidth()
48-
.padding(top = VSTheme.spacing.extraSmall),
49-
verticalArrangement = Arrangement.spacedBy(VSTheme.spacing.medium)
44+
Row(
45+
modifier = Modifier.align(Alignment.End),
46+
horizontalArrangement = Arrangement.spacedBy(VSTheme.spacing.extraSmall)
5047
) {
51-
ProvideTextStyle(VSTheme.typography.titleMedium) {
52-
title()
53-
}
54-
ProvideTextStyle(VSTheme.typography.bodySmall) {
55-
description()
56-
}
57-
Row(
58-
modifier = Modifier.align(Alignment.End),
59-
horizontalArrangement = Arrangement.spacedBy(VSTheme.spacing.small)
60-
) {
61-
actions()
62-
}
48+
labels()
6349
}
6450
}
6551
}

app/src/main/java/com/vanced/store/ui/screen/BrowseScreen.kt

+4-10
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,8 @@ private fun BrowseScreenSuccess(
109109
}) {
110110
items(pinnedApps) { app ->
111111
BrowseAppCardLoaded(
112-
appName = app.appName,
113-
appDescription = app.appDescription,
114-
supportsNonroot = app.supportsNonroot,
115-
supportsRoot = app.supportsRoot,
116-
onDetailsClick = {
112+
app = app,
113+
onClick = {
117114

118115
}
119116
)
@@ -126,11 +123,8 @@ private fun BrowseScreenSuccess(
126123
}) {
127124
items(repositoryApps) { app ->
128125
BrowseAppCardLoaded(
129-
appName = app.appName,
130-
appDescription = app.appDescription,
131-
supportsNonroot = app.supportsNonroot,
132-
supportsRoot = app.supportsRoot,
133-
onDetailsClick = {
126+
app = app,
127+
onClick = {
134128

135129
}
136130
)

app/src/main/java/com/vanced/store/ui/util/Grid.kt

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.vanced.store.ui.util
22

3-
import androidx.compose.foundation.layout.Spacer
4-
import androidx.compose.foundation.layout.height
3+
import androidx.compose.foundation.layout.Box
4+
import androidx.compose.foundation.layout.padding
55
import androidx.compose.foundation.lazy.grid.GridItemSpan
66
import androidx.compose.foundation.lazy.grid.LazyGridScope
77
import androidx.compose.material3.ProvideTextStyle
@@ -16,11 +16,10 @@ inline fun LazyGridScope.category(
1616
) {
1717
item(span = { GridItemSpan(maxCurrentLineSpan) }) {
1818
ProvideTextStyle(VSTheme.typography.headlineSmall.copy(fontWeight = FontWeight.Medium)) {
19-
title()
19+
Box(Modifier.padding(VSTheme.spacing.small)) {
20+
title()
21+
}
2022
}
2123
}
2224
block()
23-
item(span = { GridItemSpan(maxCurrentLineSpan) }) {
24-
Spacer(Modifier.height(VSTheme.spacing.small))
25-
}
2625
}

app/src/main/java/com/vanced/store/ui/widget/BrowseAppCard.kt

+13-28
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,47 @@ package com.vanced.store.ui.widget
22

33
import androidx.compose.foundation.background
44
import androidx.compose.foundation.layout.*
5-
import androidx.compose.foundation.shape.CircleShape
6-
import androidx.compose.material3.Button
75
import androidx.compose.material3.Text
86
import androidx.compose.runtime.Composable
97
import androidx.compose.ui.Modifier
108
import androidx.compose.ui.draw.clip
119
import androidx.compose.ui.unit.dp
10+
import com.vanced.store.domain.model.DomainBrowseApp
1211
import com.vanced.store.ui.component.BrowseAppCard
1312
import com.vanced.store.ui.theme.VSTheme
1413

1514
@Composable
1615
fun BrowseAppCardLoaded(
17-
onDetailsClick: () -> Unit,
18-
appName: String,
19-
appDescription: String,
20-
supportsRoot: Boolean,
21-
supportsNonroot: Boolean,
16+
onClick: () -> Unit,
17+
app: DomainBrowseApp,
2218
modifier: Modifier = Modifier,
2319
) {
2420
BrowseAppCard(
2521
modifier = modifier,
22+
onClick = onClick,
2623
icon = {
2724
Box(modifier = Modifier
28-
.size(48.dp)
29-
.background(VSTheme.colorScheme.primary))
25+
.fillMaxSize()
26+
.background(VSTheme.colorScheme.secondary))
3027
},
3128
title = {
32-
Text(appName)
29+
Text(app.appName)
3330
},
3431
description = {
35-
Text(appDescription)
32+
Text(app.appDescription)
3633
},
3734
labels = {
38-
if (supportsNonroot) {
35+
if (app.supportsNonroot) {
3936
Label {
4037
Text(text = "Nonroot")
4138
}
4239
}
43-
if (supportsRoot) {
40+
if (app.supportsRoot) {
4441
Label {
4542
Text(text = "Root")
4643
}
4744
}
4845
},
49-
actions = {
50-
Button(onClick = onDetailsClick) {
51-
Text("Details")
52-
}
53-
}
5446
)
5547
}
5648

@@ -62,9 +54,8 @@ fun BrowseAppCardLoading(
6254
modifier = modifier,
6355
icon = {
6456
Box(modifier = Modifier
65-
.size(48.dp)
66-
.clip(VSTheme.shapes.medium)
67-
.background(VSTheme.colorScheme.primary))
57+
.fillMaxSize()
58+
.background(VSTheme.colorScheme.secondary))
6859
},
6960
title = {
7061
Box(modifier = Modifier
@@ -88,12 +79,6 @@ fun BrowseAppCardLoading(
8879
.width(36.dp)
8980
.height(24.dp)) {}
9081
},
91-
actions = {
92-
Box(modifier = Modifier
93-
.width(72.dp)
94-
.height(36.dp)
95-
.clip(CircleShape)
96-
.background(VSTheme.colorScheme.primary))
97-
}
82+
onClick = null
9883
)
9984
}

app/src/main/java/com/vanced/store/ui/widget/Labels.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fun Label(
3434
Row(
3535
modifier = Modifier
3636
.padding(
37-
horizontal = VSTheme.spacing.large,
37+
horizontal = VSTheme.spacing.medium,
3838
vertical = VSTheme.spacing.small
3939
),
4040
horizontalArrangement = Arrangement.Center,

app/src/main/java/com/vanced/store/ui/widget/Lazy.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ fun CardLazyVerticalGrid(
3939
LazyVerticalGrid(
4040
modifier = modifier,
4141
state = state,
42-
columns = GridCells.Adaptive(300.dp),
43-
verticalArrangement = Arrangement.spacedBy(VSTheme.spacing.medium),
44-
horizontalArrangement = Arrangement.spacedBy(VSTheme.spacing.medium),
45-
contentPadding = PaddingValues(VSTheme.spacing.extraLarge),
42+
columns = GridCells.Adaptive(125.dp),
43+
verticalArrangement = Arrangement.spacedBy(VSTheme.spacing.large),
44+
horizontalArrangement = Arrangement.spacedBy(VSTheme.spacing.large),
45+
contentPadding = PaddingValues(16.dp),
4646
userScrollEnabled = scrollEnabled,
4747
content = content
4848
)

app/src/main/java/com/vanced/store/ui/widget/ScreenScaffold.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import androidx.compose.animation.rememberSplineBasedDecay
44
import androidx.compose.foundation.layout.PaddingValues
55
import androidx.compose.material3.*
66
import androidx.compose.runtime.Composable
7-
import androidx.compose.runtime.remember
87
import androidx.compose.ui.Modifier
98
import androidx.compose.ui.input.nestedscroll.nestedScroll
109

@@ -17,9 +16,7 @@ fun ScreenScaffold(
1716
floatingActionButtonPosition: FabPosition = FabPosition.End,
1817
content: @Composable (PaddingValues) -> Unit
1918
) {
20-
val topbarScrollState = rememberTopAppBarScrollState()
21-
val decayAnimationSpec = rememberSplineBasedDecay<Float>()
22-
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(decayAnimationSpec, topbarScrollState)
19+
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
2320
Scaffold(
2421
modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
2522
topBar = { topBar(scrollBehavior) },

0 commit comments

Comments
 (0)