Skip to content

Commit deeaf85

Browse files
committed
feat: make experience card layout responsive
1 parent fbe29f9 commit deeaf85

File tree

3 files changed

+61
-35
lines changed

3 files changed

+61
-35
lines changed

composeApp/src/wasmJsMain/kotlin/org/nsh07/nsh07/ui/homeScreen/AppHomeScreen.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ fun AppHomeScreen(
134134
experiences,
135135
projectState,
136136
cardPadding,
137-
uriHandler
137+
uriHandler,
138+
wide = true
138139
)
139140
}
140141
}
@@ -237,6 +238,7 @@ fun AppHomeScreen(
237238
projectState,
238239
cardPadding,
239240
uriHandler,
241+
wide = false,
240242
topPadding = 96.dp
241243
)
242244
}

composeApp/src/wasmJsMain/kotlin/org/nsh07/nsh07/ui/homeScreen/ExperienceCard.kt

Lines changed: 51 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,53 +34,71 @@ import kotlin.text.Typography.nbsp
3434
fun ExperienceCard(
3535
experience: Experience,
3636
cardPadding: Dp,
37+
wide: Boolean,
3738
modifier: Modifier = Modifier
3839
) {
39-
val colorScheme = colorScheme
40+
colorScheme
4041
val uriHandler = LocalUriHandler.current
4142

4243
Box(
4344
modifier
4445
.clip(shapes.largeIncreased)
4546
.clickable { uriHandler.openUri(experience.companyUrl) }
4647
) {
47-
Row(Modifier.fillMaxWidth().padding(cardPadding)) {
48-
Text(
49-
remember {
50-
"${experience.start.replace(' ', nbsp)} $mdash ${
51-
experience.end.replace(
52-
' ',
53-
nbsp
54-
)
55-
}".toUpperCase(Locale.current)
56-
},
57-
style = typography.labelMedium,
58-
color = colorScheme.outline,
59-
modifier = Modifier.padding(top = 4.dp, end = 16.dp).weight(1f)
60-
)
61-
Column(Modifier.weight(3f)) {
62-
FlowRow(itemVerticalAlignment = Alignment.CenterVertically) {
63-
Text(experience.position, style = typography.bodyLarge, fontWeight = FontWeight.Medium)
64-
Text(" $bullet ", style = typography.bodyLarge, fontWeight = FontWeight.Medium)
65-
Text(experience.company, style = typography.bodyLarge, fontWeight = FontWeight.Medium)
66-
Icon(
67-
painterResource(Res.drawable.open_in_browser),
68-
null,
69-
modifier = Modifier.padding(start = 4.dp).size(16.dp)
70-
)
71-
}
72-
Text(
73-
experience.description,
74-
style = typography.bodyMedium,
75-
color = colorScheme.onSurfaceVariant,
76-
modifier = Modifier.padding(top = 8.dp)
77-
)
78-
if (experience.skills.isNotEmpty()) LabelRow(experience.skills, Modifier.padding(top = 16.dp))
48+
if (wide) {
49+
Row(Modifier.fillMaxWidth().padding(cardPadding)) {
50+
ExperienceCardDurationText(experience, Modifier.weight(1f))
51+
ExperienceCardMainContent(experience, Modifier.weight(3f))
52+
}
53+
} else {
54+
Column(Modifier.fillMaxWidth().padding(cardPadding)) {
55+
ExperienceCardDurationText(experience)
56+
ExperienceCardMainContent(experience)
7957
}
8058
}
8159
}
8260
}
8361

62+
@Composable
63+
fun ExperienceCardDurationText(experience: Experience, modifier: Modifier = Modifier) {
64+
Text(
65+
remember {
66+
"${experience.start.replace(' ', nbsp)} $mdash ${
67+
experience.end.replace(
68+
' ',
69+
nbsp
70+
)
71+
}".toUpperCase(Locale.current)
72+
},
73+
style = typography.labelMedium,
74+
color = colorScheme.outline,
75+
modifier = Modifier.padding(top = 4.dp, bottom = 8.dp, end = 16.dp).then(modifier)
76+
)
77+
}
78+
79+
@Composable
80+
fun ExperienceCardMainContent(experience: Experience, modifier: Modifier = Modifier) {
81+
Column(modifier) {
82+
FlowRow(itemVerticalAlignment = Alignment.CenterVertically) {
83+
Text(experience.position, style = typography.bodyLarge, fontWeight = FontWeight.Medium)
84+
Text(" $bullet ", style = typography.bodyLarge, fontWeight = FontWeight.Medium)
85+
Text(experience.company, style = typography.bodyLarge, fontWeight = FontWeight.Medium)
86+
Icon(
87+
painterResource(Res.drawable.open_in_browser),
88+
null,
89+
modifier = Modifier.padding(start = 4.dp).size(16.dp)
90+
)
91+
}
92+
Text(
93+
experience.description,
94+
style = typography.bodyMedium,
95+
color = colorScheme.onSurfaceVariant,
96+
modifier = Modifier.padding(top = 8.dp)
97+
)
98+
if (experience.skills.isNotEmpty()) LabelRow(experience.skills, Modifier.padding(top = 16.dp))
99+
}
100+
}
101+
84102
@Composable
85103
fun LabelRow(list: List<String>, modifier: Modifier = Modifier) {
86104
FlowRow(

composeApp/src/wasmJsMain/kotlin/org/nsh07/nsh07/ui/homeScreen/HomeScreenContent.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ fun LazyListScope.mainContent(
8989
projectState: ProjectsState,
9090
cardPadding: Dp,
9191
uriHandler: UriHandler,
92+
wide: Boolean,
9293
topPadding: Dp = 0.dp
9394
) {
9495
items(paragraphs, key = { it.substring(0, 16) }) {
@@ -102,7 +103,12 @@ fun LazyListScope.mainContent(
102103
}
103104
item("experience spacer") { Spacer(Modifier.height(112.dp)) }
104105
items(experiences, key = { it.start }) {
105-
ExperienceCard(experience = it, cardPadding = cardPadding, modifier = Modifier.padding(bottom = 32.dp))
106+
ExperienceCard(
107+
experience = it,
108+
cardPadding = cardPadding,
109+
wide = wide,
110+
modifier = Modifier.padding(bottom = 32.dp)
111+
)
106112
}
107113
item("linkedin link text") {
108114
Row(

0 commit comments

Comments
 (0)