Skip to content

Commit 0be1df0

Browse files
style: change card ui
1 parent 27b376f commit 0be1df0

5 files changed

Lines changed: 45 additions & 13 deletions

File tree

.idea/deploymentTargetDropDown.xml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/davedevab/composetutorial/data/remote/model/GameModel.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ data class GameModel(
55
val title: String,
66
val thumbnail: String,
77
val short_description: String,
8-
val game_url: String
8+
val game_url: String,
9+
val genre: String,
10+
val platform: String
911
)

app/src/main/java/com/davedevab/composetutorial/domain/item/GameItem.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ data class GameItem(
88
val title: String,
99
val thumbnail: String,
1010
val short_description: String,
11-
val game_url: String
11+
val game_url: String,
12+
val genre: String,
13+
val platform: String
1214

1315
)
1416

15-
fun GameModel.toGameItem() = GameItem(id, title, thumbnail, short_description, game_url)
17+
fun GameModel.toGameItem() = GameItem(id, title, thumbnail, short_description, game_url, genre, platform)

app/src/main/java/com/davedevab/composetutorial/ui/home/Home.kt

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ import androidx.activity.compose.rememberLauncherForActivityResult
66
import androidx.activity.result.contract.ActivityResultContracts
77
import androidx.compose.foundation.Image
88
import androidx.compose.foundation.clickable
9+
import androidx.compose.foundation.layout.Arrangement
910
import androidx.compose.foundation.layout.Column
11+
import androidx.compose.foundation.layout.Row
1012
import androidx.compose.foundation.layout.fillMaxSize
1113
import androidx.compose.foundation.layout.fillMaxWidth
1214
import androidx.compose.foundation.layout.height
1315
import androidx.compose.foundation.layout.padding
1416
import androidx.compose.foundation.lazy.LazyColumn
1517
import androidx.compose.foundation.lazy.items
18+
import androidx.compose.foundation.shape.CornerSize
1619
import androidx.compose.foundation.shape.RoundedCornerShape
20+
import androidx.compose.material3.AssistChip
1721
import androidx.compose.material3.Button
1822
import androidx.compose.material3.Card
1923
import androidx.compose.material3.Text
@@ -23,11 +27,13 @@ import androidx.compose.runtime.getValue
2327
import androidx.compose.runtime.mutableStateOf
2428
import androidx.compose.runtime.remember
2529
import androidx.compose.runtime.setValue
30+
import androidx.compose.ui.Alignment
2631
import androidx.compose.ui.Modifier
2732
import androidx.compose.ui.layout.ContentScale
2833
import androidx.compose.ui.text.font.FontWeight
2934
import androidx.compose.ui.text.style.TextOverflow
3035
import androidx.compose.ui.unit.dp
36+
import androidx.compose.ui.unit.sp
3137
import androidx.lifecycle.viewmodel.compose.viewModel
3238
import coil.compose.rememberAsyncImagePainter
3339
import com.davedevab.composetutorial.domain.item.GameItem
@@ -57,7 +63,7 @@ fun GameCard(game: GameItem){
5763
Card(
5864
shape = RoundedCornerShape(16.dp),
5965
modifier = Modifier
60-
.padding(10.dp)
66+
.padding(16.dp)
6167
.fillMaxSize()
6268
) {
6369
Column {
@@ -69,27 +75,50 @@ fun GameCard(game: GameItem){
6975
.fillMaxWidth()
7076
.height(250.dp)
7177
)
72-
Column(modifier = Modifier.padding(8.dp)) {
73-
Text(text = game.title, fontWeight = FontWeight.Bold)
78+
Column(modifier = Modifier.padding(8.dp),
79+
horizontalAlignment = Alignment.CenterHorizontally) {
80+
Text(text = game.title, fontWeight = FontWeight.Bold, fontSize = 22.sp, modifier = Modifier.padding(bottom = 8.dp))
7481
Text(
7582
text = game.short_description,
7683
maxLines = if (isExpanded) Int.MAX_VALUE else 2,
7784
overflow = TextOverflow.Ellipsis,
85+
fontSize = 16.sp,
7886
modifier = Modifier
7987
.clickable {
8088
isExpanded = !isExpanded
8189
}
8290
)
91+
Row(
92+
modifier = Modifier
93+
.fillMaxWidth()
94+
.padding(4.dp),
95+
horizontalArrangement = Arrangement.Center
96+
) {
97+
AssistChip(
98+
modifier = Modifier.padding(end = 8.dp),
99+
onClick = { /* Do something! */ },
100+
label = { Text(game.genre) },
101+
shape = RoundedCornerShape(12.dp)
102+
)
103+
AssistChip(
104+
modifier = Modifier.padding(end = 8.dp),
105+
onClick = { /* Do something! */ },
106+
label = { Text(game.platform) },
107+
shape = RoundedCornerShape(12.dp)
108+
109+
)
110+
}
83111
Button(
84112
onClick = {
85113
// Acción para el primer botón
86114
val url = game.game_url // Supongamos que el modelo proporciona la URL
87115
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
88116
openUrl.launch(intent)
89117
},
90-
modifier = Modifier.padding(6.dp)
118+
modifier = Modifier
119+
.padding(6.dp)
91120
) {
92-
Text(text = "View Site Game")
121+
Text(text = "View Site Game", fontSize = 14.sp)
93122
}
94123
}
95124
}

0 commit comments

Comments
 (0)