This commit was merged in pull request #45.
This commit is contained in:
@@ -43,4 +43,35 @@ object UiConstants {
|
||||
WindowSizeClass.Expanded -> 24.dp
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Grid configuration driven by [WindowSizeClass].
|
||||
*
|
||||
* Determines total column count and per-item spans so that:
|
||||
* - **Compact** (phone): 2 attribute cards / row, 1 talent card / row
|
||||
* - **Medium** (tablet): 4 attribute cards / row, 2 talent cards / row
|
||||
* - **Expanded** (desktop): 4 attribute cards / row, 2 talent cards / row
|
||||
*/
|
||||
object Grid {
|
||||
/** Total number of grid columns for the given [sizeClass]. */
|
||||
fun totalColumns(sizeClass: WindowSizeClass): Int = when (sizeClass) {
|
||||
WindowSizeClass.Compact -> 2
|
||||
WindowSizeClass.Medium -> 4
|
||||
WindowSizeClass.Expanded -> 4
|
||||
}
|
||||
|
||||
/** Span occupied by a single attribute card. */
|
||||
fun attributeSpan(sizeClass: WindowSizeClass): Int = when (sizeClass) {
|
||||
WindowSizeClass.Compact -> 1
|
||||
WindowSizeClass.Medium -> 1
|
||||
WindowSizeClass.Expanded -> 1
|
||||
}
|
||||
|
||||
/** Span occupied by a single talent card. */
|
||||
fun talentSpan(sizeClass: WindowSizeClass): Int = when (sizeClass) {
|
||||
WindowSizeClass.Compact -> 2
|
||||
WindowSizeClass.Medium -> 2
|
||||
WindowSizeClass.Expanded -> 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,12 @@ fun ColumnScope.AttributesPage(character: ShadowrunCharacter) {
|
||||
val gridPadding = UiConstants.Spacing.medium(windowSizeClass)
|
||||
val dividerPadding = UiConstants.Spacing.medium(windowSizeClass)
|
||||
|
||||
val totalColumns = UiConstants.Grid.totalColumns(windowSizeClass)
|
||||
val attributeSpan = UiConstants.Grid.attributeSpan(windowSizeClass)
|
||||
val talentSpan = UiConstants.Grid.talentSpan(windowSizeClass)
|
||||
|
||||
LazyVerticalGrid(
|
||||
columns = GridCells.Adaptive(minSize = 75.dp),
|
||||
columns = GridCells.Fixed(totalColumns),
|
||||
state = gridState,
|
||||
modifier = Modifier.fillMaxSize().padding(gridPadding),
|
||||
horizontalArrangement = Arrangement.spacedBy(gridSpacing),
|
||||
@@ -38,7 +42,7 @@ fun ColumnScope.AttributesPage(character: ShadowrunCharacter) {
|
||||
items(
|
||||
items = character.attributes.getAllAttributes(),
|
||||
span = {
|
||||
GridItemSpan(2)
|
||||
GridItemSpan(attributeSpan)
|
||||
}) { attribute ->
|
||||
Attribute(attribute)
|
||||
}
|
||||
@@ -53,11 +57,11 @@ fun ColumnScope.AttributesPage(character: ShadowrunCharacter) {
|
||||
items(
|
||||
items = character.talents.talents,
|
||||
span = {
|
||||
GridItemSpan(3)
|
||||
GridItemSpan(talentSpan)
|
||||
}
|
||||
) { talent ->
|
||||
Talent(talent, character.attributes)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user