Skip to content

Commit 9b3d573

Browse files
committed
refactor(ui): elevate click handling to ExpressiveCard
This commit refactors the click handling logic for repository items by moving the `clickable` interaction from the inner content containers to the `ExpressiveCard` component itself. This ensures a more consistent ripple effect and simplifies the internal layout structure. - **refactor(core)**: Updated `ExpressiveCard` to conditionally support an `onClick` parameter, leveraging `ElevatedCard` overloads for better accessibility and interaction handling. - **refactor(apps)**: Moved repo click logic from the inner `Column` to the `ExpressiveCard` in `AppsRoot.kt`. - **refactor(dev-profile)**: Moved repo click logic from the inner `Column` to the `ExpressiveCard` in `DeveloperRepoItem.kt`.
1 parent fca8393 commit 9b3d573

3 files changed

Lines changed: 25 additions & 14 deletions

File tree

  • core/presentation/src/commonMain/kotlin/zed/rainxch/core/presentation/components
  • feature
    • apps/presentation/src/commonMain/kotlin/zed/rainxch/apps/presentation
    • dev-profile/presentation/src/commonMain/kotlin/zed/rainxch/devprofile/presentation/components

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

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,24 @@ fun ExpressiveCard(
1515
onClick: (() -> Unit)? = null,
1616
content: @Composable () -> Unit
1717
) {
18-
ElevatedCard(
19-
modifier = modifier.fillMaxWidth(),
20-
colors = CardDefaults.elevatedCardColors(
21-
containerColor = MaterialTheme.colorScheme.surfaceContainer
22-
),
23-
onClick = {
24-
onClick?.invoke()
25-
},
26-
shape = RoundedCornerShape(32.dp),
27-
content = { content() }
28-
)
18+
if (onClick != null) {
19+
ElevatedCard(
20+
modifier = modifier.fillMaxWidth(),
21+
colors = CardDefaults.elevatedCardColors(
22+
containerColor = MaterialTheme.colorScheme.surfaceContainer
23+
),
24+
onClick = onClick,
25+
shape = RoundedCornerShape(32.dp),
26+
content = { content() }
27+
)
28+
} else {
29+
ElevatedCard(
30+
modifier = modifier.fillMaxWidth(),
31+
colors = CardDefaults.elevatedCardColors(
32+
containerColor = MaterialTheme.colorScheme.surfaceContainer
33+
),
34+
shape = RoundedCornerShape(32.dp),
35+
content = { content() }
36+
)
37+
}
2938
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,13 @@ fun AppItemCard(
375375
) {
376376
val app = appItem.installedApp
377377

378-
ExpressiveCard(modifier = modifier) {
378+
ExpressiveCard(
379+
onClick = onRepoClick,
380+
modifier = modifier
381+
) {
379382
Column(
380383
modifier = Modifier
381384
.clip(RoundedCornerShape(32.dp))
382-
.clickable { onRepoClick() }
383385
.padding(16.dp)
384386
) {
385387
Row(

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
@@ -57,12 +57,12 @@ fun DeveloperRepoItem(
5757
modifier: Modifier = Modifier
5858
) {
5959
ExpressiveCard(
60+
onClick = onItemClick,
6061
modifier = modifier.fillMaxWidth(),
6162
) {
6263
Column(
6364
modifier = Modifier
6465
.fillMaxWidth()
65-
.clickable(onClick = onItemClick)
6666
.padding(16.dp)
6767
) {
6868
Row(

0 commit comments

Comments
 (0)