Skip to content

Commit 9f4fabb

Browse files
author
Fastace
committed
UI:M3E风格-Test-首页
1 parent 0f0c00a commit 9f4fabb

6 files changed

Lines changed: 68 additions & 70 deletions

File tree

source/core/ui/src/main/kotlin/com/xayah/core/ui/component/Chip.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ fun ActionChip(
402402
enabled = enabled,
403403
icon = if (selected) Icons.Rounded.Check else icon,
404404
colorContainer = if (selected) ThemedColorSchemeKeyTokens.PrimaryContainer else ThemedColorSchemeKeyTokens.SurfaceContainerHigh,
405-
colorL80D20 = if (selected) ThemedColorSchemeKeyTokens.OnPrimaryContainer else ThemedColorSchemeKeyTokens.SurfaceDim,
406405
onColorContainer = if (selected) ThemedColorSchemeKeyTokens.PrimaryContainer else ThemedColorSchemeKeyTokens.OnSurface,
407406
onClick = onClick
408407
) {

source/core/ui/src/main/kotlin/com/xayah/core/ui/component/Common.kt

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import androidx.compose.foundation.layout.size
1919
import androidx.compose.foundation.layout.wrapContentHeight
2020
import androidx.compose.foundation.shape.CircleShape
2121
import androidx.compose.foundation.shape.RoundedCornerShape
22+
import androidx.compose.foundation.layout.heightIn
2223
import androidx.compose.material.icons.Icons
2324
import androidx.compose.material.icons.outlined.Close
2425
import androidx.compose.material.icons.outlined.Folder
@@ -75,44 +76,33 @@ fun ActionButton(
7576
enabled: Boolean = true,
7677
icon: ImageVector,
7778
colorContainer: ThemedColorSchemeKeyTokens,
78-
colorL80D20: ThemedColorSchemeKeyTokens,
7979
onColorContainer: ThemedColorSchemeKeyTokens,
8080
trailingIcon: @Composable (RowScope.() -> Unit)? = null,
8181
onClick: () -> Unit = {},
8282
content: @Composable RowScope.() -> Unit
8383
) {
84-
val interactionSource = remember { MutableInteractionSource() }
8584
Card(
86-
modifier = modifier.wrapContentHeight(),
87-
shape = MaterialTheme.shapes.medium,
85+
modifier = modifier
86+
.wrapContentHeight()
87+
.heightIn(min = SizeTokens.Level56),
88+
shape = MaterialTheme.shapes.large,
8889
colors = CardDefaults.cardColors(containerColor = colorContainer.value.withState(enabled)),
8990
onClick = onClick,
9091
enabled = enabled,
91-
interactionSource = interactionSource,
9292
) {
9393
Row(
9494
modifier = Modifier
95-
.padding(SizeTokens.Level12)
95+
.padding(horizontal = SizeTokens.Level16, vertical = SizeTokens.Level12)
9696
.fillMaxWidth(),
9797
verticalAlignment = Alignment.CenterVertically,
98-
horizontalArrangement = Arrangement.spacedBy(SizeTokens.Level10)
98+
horizontalArrangement = Arrangement.spacedBy(SizeTokens.Level12)
9999
) {
100-
Surface(
101-
modifier = Modifier.size(SizeTokens.Level36),
102-
shape = CircleShape,
103-
color = colorL80D20.value.withState(enabled),
104-
enabled = enabled,
105-
onClick = onClick,
106-
indication = null,
107-
interactionSource = interactionSource
108-
) {
109-
Icon(
110-
modifier = Modifier.padding(SizeTokens.Level8),
111-
imageVector = icon,
112-
tint = onColorContainer.value.withState(enabled),
113-
contentDescription = null,
114-
)
115-
}
100+
Icon(
101+
modifier = Modifier.size(SizeTokens.Level24),
102+
imageVector = icon,
103+
tint = onColorContainer.value.withState(enabled),
104+
contentDescription = null,
105+
)
116106
content()
117107
trailingIcon?.invoke(this)
118108
}

source/feature/main/dashboard/src/main/kotlin/com/xayah/feature/main/dashboard/Component.kt

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ package com.xayah.feature.main.dashboard
22

33
import android.annotation.SuppressLint
44
import androidx.compose.foundation.ExperimentalFoundationApi
5+
import androidx.compose.foundation.layout.PaddingValues
6+
import androidx.compose.foundation.layout.Spacer
7+
import androidx.compose.foundation.layout.heightIn
8+
import androidx.compose.foundation.layout.size
9+
import androidx.compose.foundation.layout.width
10+
import androidx.compose.material3.Button
11+
import androidx.compose.material3.ButtonDefaults
12+
import androidx.compose.material3.MaterialTheme
13+
import androidx.compose.material3.Text
14+
import androidx.compose.ui.text.style.TextOverflow
515
import androidx.compose.material.icons.Icons
616
import androidx.compose.material.icons.outlined.Settings
717
import androidx.compose.material.icons.rounded.KeyboardArrowRight
@@ -16,8 +26,8 @@ import androidx.compose.ui.graphics.vector.ImageVector
1626
import androidx.compose.ui.platform.LocalContext
1727
import androidx.compose.ui.res.stringResource
1828
import androidx.compose.ui.res.vectorResource
19-
import com.xayah.core.ui.component.ActionButton
20-
import com.xayah.core.ui.component.AutoLabelLargeText
29+
//import com.xayah.core.ui.component.ActionButton
30+
//import com.xayah.core.ui.component.AutoLabelLargeText
2131
import com.xayah.core.ui.component.BodyMediumText
2232
import com.xayah.core.ui.component.OverviewCard
2333
import com.xayah.core.ui.component.SegmentProgressIndicator
@@ -27,7 +37,7 @@ import com.xayah.core.ui.component.paddingTop
2737
import com.xayah.core.ui.model.SegmentProgress
2838
import com.xayah.core.ui.theme.ThemedColorSchemeKeyTokens
2939
import com.xayah.core.ui.theme.value
30-
import com.xayah.core.ui.theme.withState
40+
//import com.xayah.core.ui.theme.withState
3141
import com.xayah.core.ui.token.SizeTokens
3242
import com.xayah.core.util.DateUtil
3343

@@ -128,28 +138,47 @@ fun QuickActionsButton(
128138
title: String,
129139
icon: ImageVector,
130140
colorContainer: ThemedColorSchemeKeyTokens,
131-
colorL80D20: ThemedColorSchemeKeyTokens,
132141
onColorContainer: ThemedColorSchemeKeyTokens,
133142
actionIcon: ImageVector? = null,
134143
onClick: () -> Unit = {},
135144
) {
136-
ActionButton(
137-
modifier = modifier,
145+
Button(
146+
modifier = modifier.heightIn(min = SizeTokens.Level56),
138147
enabled = enabled,
139-
icon = icon,
140-
colorContainer = colorContainer,
141-
colorL80D20 = colorL80D20,
142-
onColorContainer = onColorContainer,
143-
trailingIcon = {
144-
if (actionIcon != null)
145-
Icon(
146-
imageVector = actionIcon,
147-
tint = onColorContainer.value.withState(enabled),
148-
contentDescription = null
149-
)
150-
},
151-
onClick = onClick
148+
onClick = onClick,
149+
colors = ButtonDefaults.buttonColors(
150+
containerColor = colorContainer.value,
151+
contentColor = onColorContainer.value,
152+
disabledContainerColor = colorContainer.value.copy(alpha = 0.38f),
153+
disabledContentColor = onColorContainer.value.copy(alpha = 0.38f),
154+
),
155+
contentPadding = PaddingValues(
156+
start = SizeTokens.Level16,
157+
end = if (actionIcon != null) SizeTokens.Level12 else SizeTokens.Level16,
158+
top = SizeTokens.Level8,
159+
bottom = SizeTokens.Level8,
160+
),
152161
) {
153-
AutoLabelLargeText(modifier = Modifier.weight(1f), text = title, color = onColorContainer.value.withState(enabled), enabled = enabled)
162+
Icon(
163+
imageVector = icon,
164+
contentDescription = null,
165+
modifier = Modifier.size(SizeTokens.Level20),
166+
)
167+
Spacer(modifier = Modifier.width(SizeTokens.Level8))
168+
Text(
169+
text = title,
170+
modifier = Modifier.weight(1f),
171+
maxLines = 1,
172+
overflow = TextOverflow.Ellipsis,
173+
style = MaterialTheme.typography.labelLarge,
174+
)
175+
if (actionIcon != null) {
176+
Spacer(modifier = Modifier.width(SizeTokens.Level4))
177+
Icon(
178+
imageVector = actionIcon,
179+
contentDescription = null,
180+
modifier = Modifier.size(SizeTokens.Level20),
181+
)
182+
}
154183
}
155184
}

source/feature/main/dashboard/src/main/kotlin/com/xayah/feature/main/dashboard/Index.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fun PageDashboard() {
153153
title = stringResource(id = R.string.backup_apps),
154154
icon = ImageVector.vectorResource(id = R.drawable.ic_rounded_acute),
155155
colorContainer = ThemedColorSchemeKeyTokens.RedPrimaryContainer,
156-
colorL80D20 = ThemedColorSchemeKeyTokens.RedL80D20,
156+
//colorL80D20 = ThemedColorSchemeKeyTokens.RedL80D20,
157157
onColorContainer = ThemedColorSchemeKeyTokens.RedOnPrimaryContainer
158158
) {
159159
navController.navigateSingle(MainRoutes.List.getRoute(target = Target.Apps, opType = OpType.BACKUP))
@@ -164,7 +164,7 @@ fun PageDashboard() {
164164
title = stringResource(id = R.string.backup_files),
165165
icon = ImageVector.vectorResource(id = R.drawable.ic_rounded_acute),
166166
colorContainer = ThemedColorSchemeKeyTokens.YellowPrimaryContainer,
167-
colorL80D20 = ThemedColorSchemeKeyTokens.YellowL80D20,
167+
//colorL80D20 = ThemedColorSchemeKeyTokens.YellowL80D20,
168168
onColorContainer = ThemedColorSchemeKeyTokens.YellowOnPrimaryContainer
169169
) {
170170
navController.navigateSingle(MainRoutes.List.getRoute(target = Target.Files, opType = OpType.BACKUP))
@@ -194,7 +194,7 @@ fun PageDashboard() {
194194
title = stringResource(id = R.string.cloud),
195195
icon = Icons.Outlined.Cloud,
196196
colorContainer = ThemedColorSchemeKeyTokens.PurplePrimaryContainer,
197-
colorL80D20 = ThemedColorSchemeKeyTokens.PurpleL80D20,
197+
//colorL80D20 = ThemedColorSchemeKeyTokens.PurpleL80D20,
198198
onColorContainer = ThemedColorSchemeKeyTokens.PurpleOnPrimaryContainer,
199199
actionIcon = Icons.Rounded.KeyboardArrowRight
200200
) {
@@ -206,7 +206,7 @@ fun PageDashboard() {
206206
title = stringResource(id = R.string.restore),
207207
icon = ImageVector.vectorResource(id = R.drawable.ic_rounded_history),
208208
colorContainer = ThemedColorSchemeKeyTokens.OrangePrimaryContainer,
209-
colorL80D20 = ThemedColorSchemeKeyTokens.OrangeL80D20,
209+
//colorL80D20 = ThemedColorSchemeKeyTokens.OrangeL80D20,
210210
onColorContainer = ThemedColorSchemeKeyTokens.OrangeOnPrimaryContainer,
211211
actionIcon = Icons.Rounded.KeyboardArrowRight
212212
) {
@@ -218,7 +218,7 @@ fun PageDashboard() {
218218
title = stringResource(R.string.history),
219219
icon = Icons.Rounded.ListAlt,
220220
colorContainer = ThemedColorSchemeKeyTokens.PinkPrimaryContainer,
221-
colorL80D20 = ThemedColorSchemeKeyTokens.PinkL80D20,
221+
//colorL80D20 = ThemedColorSchemeKeyTokens.PinkL80D20,
222222
onColorContainer = ThemedColorSchemeKeyTokens.PinkOnPrimaryContainer,
223223
actionIcon = Icons.Rounded.KeyboardArrowRight
224224
) {

source/feature/setup/src/main/kotlin/com/xayah/feature/setup/Component.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ fun PermissionButton(
8888
enabled = enabled,
8989
icon = envState.icon,
9090
colorContainer = envState.colorContainer,
91-
colorL80D20 = envState.colorL80D20,
9291
onColorContainer = envState.onColorContainer,
9392
trailingIcon = {
9493
if (onSetting != null) {

source/feature/setup/src/main/kotlin/com/xayah/feature/setup/Model.kt

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,6 @@ sealed class EnvState {
3434
}
3535
}
3636

37-
val colorL80D20: ThemedColorSchemeKeyTokens
38-
get() = when (this) {
39-
Idle -> {
40-
ThemedColorSchemeKeyTokens.SurfaceDimBaselineFixed
41-
}
42-
43-
Processing -> {
44-
ThemedColorSchemeKeyTokens.OnSecondaryContainer
45-
}
46-
47-
Succeed -> {
48-
ThemedColorSchemeKeyTokens.OnPrimaryContainer
49-
}
50-
51-
Failed -> {
52-
ThemedColorSchemeKeyTokens.OnErrorContainer
53-
}
54-
}
55-
5637
val onColorContainer: ThemedColorSchemeKeyTokens
5738
get() = when (this) {
5839
Idle -> {
@@ -80,4 +61,4 @@ sealed class EnvState {
8061
Succeed -> Icons.Rounded.Done
8162
Failed -> Icons.Rounded.PriorityHigh
8263
}
83-
}
64+
}

0 commit comments

Comments
 (0)