Skip to content

Commit 49b797b

Browse files
authored
Merge pull request #88 from fmasa/career-scroll
Make career level list scrollable
2 parents f369bde + 9db7803 commit 49b797b

File tree

1 file changed

+87
-82
lines changed

1 file changed

+87
-82
lines changed

common/src/commonMain/kotlin/cz/frantisekmasa/wfrp_master/common/compendium/career/CareerDetailScreen.kt

Lines changed: 87 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package cz.frantisekmasa.wfrp_master.common.compendium.career
22

33
import androidx.compose.foundation.clickable
4+
import androidx.compose.foundation.layout.Box
45
import androidx.compose.foundation.layout.Column
56
import androidx.compose.foundation.layout.PaddingValues
67
import androidx.compose.foundation.layout.fillMaxWidth
78
import androidx.compose.foundation.layout.padding
89
import androidx.compose.foundation.lazy.LazyColumn
10+
import androidx.compose.foundation.rememberScrollState
11+
import androidx.compose.foundation.verticalScroll
912
import androidx.compose.material.Card
1013
import androidx.compose.material.FloatingActionButton
1114
import androidx.compose.material.Icon
@@ -261,110 +264,112 @@ private fun LevelList(
261264
return
262265
}
263266

264-
DraggableListFor(
265-
items = levels,
266-
onReorder = if (isGameMaster) onReorder else ({}),
267-
) { levelIndex, level, isDragged ->
268-
val modifier = Modifier.fillMaxWidth()
269-
270-
Card(
271-
elevation = if (isDragged) 6.dp else 2.dp,
272-
modifier = if (isGameMaster)
273-
modifier.clickable { onClick(level) }
274-
else modifier
275-
) {
276-
ListItem(
277-
modifier = Modifier.padding(Spacing.medium),
278-
text = {
279-
Text(
280-
buildAnnotatedString {
281-
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
282-
append((levelIndex + 1).toString())
283-
append(". ")
284-
append(level.name)
285-
}
286-
287-
append("")
288-
append(level.status.tier.localizedName)
289-
append(' ')
290-
append(level.status.standing.toString())
291-
}
292-
)
293-
},
294-
secondaryText = {
295-
Column {
267+
Box(Modifier.verticalScroll(rememberScrollState())) {
268+
DraggableListFor(
269+
items = levels,
270+
onReorder = if (isGameMaster) onReorder else ({}),
271+
) { levelIndex, level, isDragged ->
272+
val modifier = Modifier.fillMaxWidth()
273+
274+
Card(
275+
elevation = if (isDragged) 6.dp else 2.dp,
276+
modifier = if (isGameMaster)
277+
modifier.clickable { onClick(level) }
278+
else modifier
279+
) {
280+
ListItem(
281+
modifier = Modifier.padding(Spacing.medium),
282+
text = {
296283
Text(
297284
buildAnnotatedString {
298285
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
299-
append(LocalStrings.current.skills.titleSkills)
300-
append(": ")
286+
append((levelIndex + 1).toString())
287+
append(". ")
288+
append(level.name)
301289
}
302290

303-
if (level.skills.isEmpty()) {
304-
append("")
305-
}
291+
append("")
292+
append(level.status.tier.localizedName)
293+
append(' ')
294+
append(level.status.standing.toString())
295+
}
296+
)
297+
},
298+
secondaryText = {
299+
Column {
300+
Text(
301+
buildAnnotatedString {
302+
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
303+
append(LocalStrings.current.skills.titleSkills)
304+
append(": ")
305+
}
306+
307+
if (level.skills.isEmpty()) {
308+
append("")
309+
}
306310

307-
derivedStateOf { level.skills.sortedBy { it.expression.lowercase() } }.value
308-
.forEachIndexed { index, skill ->
309-
if (skill.isIncomeSkill) {
310-
withStyle(SpanStyle(fontStyle = FontStyle.Italic)) {
311+
derivedStateOf { level.skills.sortedBy { it.expression.lowercase() } }.value
312+
.forEachIndexed { index, skill ->
313+
if (skill.isIncomeSkill) {
314+
withStyle(SpanStyle(fontStyle = FontStyle.Italic)) {
315+
append(skill.expression)
316+
}
317+
} else {
311318
append(skill.expression)
312319
}
313-
} else {
314-
append(skill.expression)
315-
}
316320

317-
if (index != level.skills.lastIndex) {
318-
append(", ")
321+
if (index != level.skills.lastIndex) {
322+
append(", ")
323+
}
319324
}
320-
}
321-
}
322-
)
323-
Text(
324-
buildAnnotatedString {
325-
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
326-
append(LocalStrings.current.talents.titleTalents)
327-
append(": ")
328325
}
326+
)
327+
Text(
328+
buildAnnotatedString {
329+
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
330+
append(LocalStrings.current.talents.titleTalents)
331+
append(": ")
332+
}
329333

330-
if (level.talents.isEmpty()) {
331-
append("")
332-
}
334+
if (level.talents.isEmpty()) {
335+
append("")
336+
}
333337

334-
derivedStateOf { level.talents.sortedBy { it.lowercase() } }.value
335-
.forEachIndexed { index, talent ->
336-
append(talent)
338+
derivedStateOf { level.talents.sortedBy { it.lowercase() } }.value
339+
.forEachIndexed { index, talent ->
340+
append(talent)
337341

338-
if (index != level.talents.lastIndex) {
339-
append(", ")
342+
if (index != level.talents.lastIndex) {
343+
append(", ")
344+
}
340345
}
341-
}
342-
}
343-
)
344-
345-
Text(
346-
buildAnnotatedString {
347-
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
348-
append(LocalStrings.current.trappings.title)
349-
append(": ")
350346
}
347+
)
351348

352-
if (level.trappings.isEmpty()) {
353-
append("")
354-
}
349+
Text(
350+
buildAnnotatedString {
351+
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
352+
append(LocalStrings.current.trappings.title)
353+
append(": ")
354+
}
355355

356-
level.trappings.forEachIndexed { index, talent ->
357-
append(talent)
356+
if (level.trappings.isEmpty()) {
357+
append("")
358+
}
358359

359-
if (index != level.trappings.lastIndex) {
360-
append(", ")
360+
level.trappings.forEachIndexed { index, talent ->
361+
append(talent)
362+
363+
if (index != level.trappings.lastIndex) {
364+
append(", ")
365+
}
361366
}
362367
}
363-
}
364-
)
368+
)
369+
}
365370
}
366-
}
367-
)
371+
)
372+
}
368373
}
369374
}
370375
}

0 commit comments

Comments
 (0)