Skip to content

Commit 8ffe343

Browse files
committed
refactor(core): consolidate and promote ExpressiveCard to core components
This commit moves the `ExpressiveCard` component from the `dev-profile` feature to the `core` presentation module to allow for consistent styling and reuse across different features. It also updates the component to support optional click handling. - **refactor(core)**: Relocated `ExpressiveCard` to `zed.rainxch.core.presentation.components` and added an `onClick` parameter. - **refactor(apps)**: Removed local `ExpressiveCard` implementation in `AppsRoot.kt` in favor of the core component. - **refactor(profile)**: Removed local `ExpressiveCard` implementation in `Appearance.kt` and updated imports. - **refactor(dev-profile)**: Deleted redundant `ExpressiveCard.kt` and updated `StatsRow.kt`, `DeveloperRepoItem.kt`, and `ProfileInfoCard.kt` to use the core component. - **refactor(core)**: Updated `RepositoryCard` to use `ExpressiveCard` instead of a standard `Card`, ensuring UI consistency.
1 parent 4bfecde commit 8ffe343

7 files changed

Lines changed: 15 additions & 43 deletions

File tree

feature/dev-profile/presentation/src/commonMain/kotlin/zed/rainxch/devprofile/presentation/components/ExpressiveCard.kt renamed to core/presentation/src/commonMain/kotlin/zed/rainxch/core/presentation/components/ExpressiveCard.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package zed.rainxch.devprofile.presentation.components
1+
package zed.rainxch.core.presentation.components
22

33
import androidx.compose.foundation.layout.fillMaxWidth
44
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -12,13 +12,17 @@ import androidx.compose.ui.unit.dp
1212
@Composable
1313
fun ExpressiveCard(
1414
modifier: Modifier = Modifier,
15+
onClick: (() -> Unit)? = null,
1516
content: @Composable () -> Unit
1617
) {
1718
ElevatedCard(
1819
modifier = modifier.fillMaxWidth(),
1920
colors = CardDefaults.elevatedCardColors(
2021
containerColor = MaterialTheme.colorScheme.surfaceContainer
2122
),
23+
onClick = {
24+
onClick?.invoke()
25+
},
2226
shape = RoundedCornerShape(32.dp),
2327
content = { content() }
2428
)

core/presentation/src/commonMain/kotlin/zed/rainxch/core/presentation/components/RepositoryCard.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,9 @@ fun RepositoryCard(
6464
modifier: Modifier = Modifier
6565
) {
6666
val uriHandler = LocalUriHandler.current
67-
Card(
68-
modifier = modifier.fillMaxWidth(),
67+
ExpressiveCard(
6968
onClick = onClick,
70-
colors = CardDefaults.cardColors(
71-
containerColor = MaterialTheme.colorScheme.surfaceContainer
72-
),
73-
shape = RoundedCornerShape(24.dp)
69+
modifier = modifier
7470
) {
7571
Box {
7672
if (discoveryRepository.isFavourite) {

feature/apps/presentation/src/commonMain/kotlin/zed/rainxch/apps/presentation/AppsRoot.kt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import org.koin.compose.viewmodel.koinViewModel
7272
import zed.rainxch.apps.presentation.model.AppItem
7373
import zed.rainxch.apps.presentation.model.UpdateAllProgress
7474
import zed.rainxch.apps.presentation.model.UpdateState
75+
import zed.rainxch.core.presentation.components.ExpressiveCard
7576
import zed.rainxch.core.presentation.locals.LocalBottomNavigationHeight
7677
import zed.rainxch.core.presentation.locals.LocalBottomNavigationLiquid
7778
import zed.rainxch.core.presentation.theme.GithubStoreTheme
@@ -374,7 +375,7 @@ fun AppItemCard(
374375
) {
375376
val app = appItem.installedApp
376377

377-
ExpressiveCard (modifier = modifier) {
378+
ExpressiveCard(modifier = modifier) {
378379
Column(
379380
modifier = Modifier
380381
.clip(RoundedCornerShape(32.dp))
@@ -647,21 +648,6 @@ private fun formatLastChecked(timestamp: Long): String {
647648
}
648649
}
649650

650-
@Composable
651-
private fun ExpressiveCard(
652-
modifier: Modifier = Modifier,
653-
content: @Composable () -> Unit
654-
) {
655-
ElevatedCard(
656-
modifier = modifier.fillMaxWidth(),
657-
colors = CardDefaults.elevatedCardColors(
658-
containerColor = MaterialTheme.colorScheme.surfaceContainer
659-
),
660-
shape = RoundedCornerShape(32.dp),
661-
content = { content() }
662-
)
663-
}
664-
665651
@Preview
666652
@Composable
667653
private fun Preview() {

feature/dev-profile/presentation/src/commonMain/kotlin/zed/rainxch/devprofile/presentation/components/DeveloperRepoItem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import androidx.compose.material.icons.filled.Star
2222
import androidx.compose.material.icons.outlined.FavoriteBorder
2323
import androidx.compose.material.icons.outlined.Warning
2424
import androidx.compose.material3.Badge
25-
import androidx.compose.material3.Card
2625
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
2726
import androidx.compose.material3.FilledIconToggleButton
2827
import androidx.compose.material3.Icon
@@ -41,6 +40,7 @@ import androidx.compose.ui.unit.dp
4140
import zed.rainxch.githubstore.core.presentation.res.*
4241
import org.jetbrains.compose.resources.stringResource
4342
import androidx.compose.ui.tooling.preview.Preview
43+
import zed.rainxch.core.presentation.components.ExpressiveCard
4444
import zed.rainxch.core.presentation.theme.GithubStoreTheme
4545
import zed.rainxch.core.presentation.utils.formatCount
4646
import zed.rainxch.devprofile.domain.model.DeveloperRepository

feature/dev-profile/presentation/src/commonMain/kotlin/zed/rainxch/devprofile/presentation/components/ProfileInfoCard.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import androidx.compose.material.icons.filled.Link
1717
import androidx.compose.material.icons.filled.LocationOn
1818
import androidx.compose.material.icons.filled.Tag
1919
import androidx.compose.material3.AssistChip
20-
import androidx.compose.material3.Card
2120
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
2221
import androidx.compose.material3.Icon
2322
import androidx.compose.material3.MaterialTheme
@@ -32,6 +31,7 @@ import androidx.compose.ui.text.style.TextOverflow
3231
import androidx.compose.ui.unit.dp
3332
import com.skydoves.landscapist.ImageOptions
3433
import com.skydoves.landscapist.coil3.CoilImage
34+
import zed.rainxch.core.presentation.components.ExpressiveCard
3535
import zed.rainxch.devprofile.domain.model.DeveloperProfile
3636
import zed.rainxch.devprofile.presentation.DeveloperProfileAction
3737

@@ -130,7 +130,7 @@ fun ProfileInfoCard(
130130
maxLines = 1,
131131
overflow = TextOverflow.Ellipsis,
132132

133-
)
133+
)
134134
},
135135
leadingIcon = {
136136
Icon(

feature/dev-profile/presentation/src/commonMain/kotlin/zed/rainxch/devprofile/presentation/components/StatsRow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Column
55
import androidx.compose.foundation.layout.Row
66
import androidx.compose.foundation.layout.fillMaxWidth
77
import androidx.compose.foundation.layout.padding
8-
import androidx.compose.material3.Card
98
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
109
import androidx.compose.material3.MaterialTheme
1110
import androidx.compose.material3.Text
@@ -16,6 +15,7 @@ import androidx.compose.ui.text.style.TextOverflow
1615
import androidx.compose.ui.unit.dp
1716
import zed.rainxch.githubstore.core.presentation.res.*
1817
import org.jetbrains.compose.resources.stringResource
18+
import zed.rainxch.core.presentation.components.ExpressiveCard
1919
import zed.rainxch.core.presentation.utils.formatCount
2020
import zed.rainxch.devprofile.domain.model.DeveloperProfile
2121

feature/profile/presentation/src/commonMain/kotlin/zed/rainxch/profile/presentation/components/sections/Appearance.kt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import androidx.compose.ui.unit.dp
5757
import org.jetbrains.compose.resources.stringResource
5858
import zed.rainxch.core.domain.model.AppTheme
5959
import zed.rainxch.core.domain.model.FontTheme
60+
import zed.rainxch.core.presentation.components.ExpressiveCard
6061
import zed.rainxch.core.presentation.theme.isDynamicColorAvailable
6162
import zed.rainxch.core.presentation.utils.displayName
6263
import zed.rainxch.core.presentation.utils.primaryColor
@@ -137,7 +138,7 @@ private fun ThemeSelectionCard(
137138
isDarkTheme: Boolean?,
138139
onDarkThemeChange: (Boolean?) -> Unit
139140
) {
140-
ExpressiveCard{
141+
ExpressiveCard {
141142
Row(
142143
modifier = Modifier
143144
.fillMaxWidth()
@@ -398,19 +399,4 @@ private fun ToggleSettingCard(
398399
)
399400
}
400401
}
401-
}
402-
403-
@Composable
404-
private fun ExpressiveCard(
405-
modifier: Modifier = Modifier,
406-
content: @Composable () -> Unit
407-
) {
408-
ElevatedCard(
409-
modifier = modifier.fillMaxWidth(),
410-
colors = CardDefaults.elevatedCardColors(
411-
containerColor = MaterialTheme.colorScheme.surfaceContainer
412-
),
413-
shape = RoundedCornerShape(32.dp),
414-
content = { content() }
415-
)
416402
}

0 commit comments

Comments
 (0)