Fix shadows, padding, and scroll on characterSheetScreen.
This commit is contained in:
parent
9e5655c7d7
commit
bd4de62841
4 changed files with 317 additions and 279 deletions
|
|
@ -3,7 +3,6 @@ package com.pixelized.rplexicon.ui.screens.character
|
|||
import android.content.res.Configuration
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.ScrollState
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
|
|
@ -57,6 +56,9 @@ import com.pixelized.rplexicon.ui.screens.character.composable.LabelPoint
|
|||
import com.pixelized.rplexicon.ui.screens.character.composable.LabelPointUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.ProficiencyUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.StatUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.pages.ActionsPages
|
||||
import com.pixelized.rplexicon.ui.screens.character.pages.ProficiencyPage
|
||||
import com.pixelized.rplexicon.ui.screens.character.preview.rememberCharacterSheetPreview
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
|
@ -93,7 +95,6 @@ fun CharacterSheetScreen(
|
|||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.systemBarsPadding(),
|
||||
state = rememberScrollState(),
|
||||
pagerState = rememberPagerState {
|
||||
if (viewModel.actions.value.isNotEmpty() || viewModel.counter.value.isNotEmpty()) {
|
||||
2
|
||||
|
|
@ -185,7 +186,6 @@ fun CharacterSheetScreen(
|
|||
@Composable
|
||||
private fun CharacterSheetContent(
|
||||
modifier: Modifier = Modifier,
|
||||
state: ScrollState,
|
||||
pagerState: PagerState,
|
||||
refreshState: PullRefreshState,
|
||||
refreshing: State<Boolean>,
|
||||
|
|
@ -254,19 +254,24 @@ private fun CharacterSheetContent(
|
|||
}
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
HorizontalPager(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.pullRefresh(refreshState)
|
||||
.verticalScroll(state = state),
|
||||
.pullRefresh(refreshState),
|
||||
state = pagerState,
|
||||
contentPadding = PaddingValues(all = 16.dp),
|
||||
contentPadding = PaddingValues(horizontal = 16.dp),
|
||||
pageSpacing = 8.dp,
|
||||
verticalAlignment = Alignment.Top,
|
||||
) {
|
||||
when (it) {
|
||||
0 -> ProficiencyPage(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.verticalScroll(state = rememberScrollState())
|
||||
.padding(vertical = 16.dp),
|
||||
sheet = sheet,
|
||||
onInitiative = onInitiative,
|
||||
onStats = onStats,
|
||||
|
|
@ -274,7 +279,10 @@ private fun CharacterSheetContent(
|
|||
)
|
||||
|
||||
1 -> ActionsPages(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.verticalScroll(state = rememberScrollState())
|
||||
.padding(vertical = 16.dp),
|
||||
actions = actions,
|
||||
counter = counter,
|
||||
alterations = alterations,
|
||||
|
|
@ -283,14 +291,7 @@ private fun CharacterSheetContent(
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(paddingValues = paddingValues)
|
||||
.fillMaxWidth(),
|
||||
) {
|
||||
Loader(
|
||||
modifier = Modifier.align(Alignment.TopCenter),
|
||||
refreshState = refreshState,
|
||||
|
|
@ -298,6 +299,8 @@ private fun CharacterSheetContent(
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class, ExperimentalFoundationApi::class)
|
||||
|
|
@ -306,194 +309,14 @@ private fun CharacterSheetContent(
|
|||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
private fun CharacterScreenPreview() {
|
||||
LexiconTheme {
|
||||
val bru = remember {
|
||||
CharacterSheetUio(
|
||||
armorClass = LabelPointUio(
|
||||
label = R.string.character_sheet_title_ca,
|
||||
value = "15",
|
||||
),
|
||||
hitPoint = LabelPointUio(
|
||||
label = R.string.character_sheet_title_hp,
|
||||
value = "125",
|
||||
max = "/ 150",
|
||||
),
|
||||
speed = LabelPointUio(
|
||||
label = R.string.character_sheet_title_speed,
|
||||
value = "30",
|
||||
max = "m",
|
||||
),
|
||||
initiative = LabelPointUio(
|
||||
label = R.string.character_sheet_title_initiative,
|
||||
value = "+2",
|
||||
),
|
||||
stats = listOf(
|
||||
StatUio(
|
||||
id = StatUio.ID.STRENGTH,
|
||||
value = 16,
|
||||
modifier = 3,
|
||||
),
|
||||
StatUio(
|
||||
id = StatUio.ID.DEXTERITY,
|
||||
value = 10,
|
||||
modifier = 0,
|
||||
),
|
||||
StatUio(
|
||||
id = StatUio.ID.CONSTITUTION,
|
||||
value = 16,
|
||||
modifier = 3,
|
||||
),
|
||||
StatUio(
|
||||
id = StatUio.ID.INTELLIGENCE,
|
||||
value = 8,
|
||||
modifier = 1,
|
||||
),
|
||||
StatUio(
|
||||
id = StatUio.ID.WISDOM,
|
||||
value = 14,
|
||||
modifier = 2,
|
||||
),
|
||||
StatUio(
|
||||
id = StatUio.ID.CHARISMA,
|
||||
value = 10,
|
||||
modifier = 0,
|
||||
),
|
||||
),
|
||||
savingThrows = listOf(
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.STRENGTH_SAVING_THROW,
|
||||
multiplier = 1,
|
||||
modifier = 5,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.DEXTERITY_SAVING_THROW,
|
||||
multiplier = 0,
|
||||
modifier = 0,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.CONSTITUTION_SAVING_THROW,
|
||||
multiplier = 1,
|
||||
modifier = +5,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.INTELLIGENCE_SAVING_THROW,
|
||||
multiplier = 0,
|
||||
modifier = -1,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.WISDOM_SAVING_THROW,
|
||||
multiplier = 0,
|
||||
modifier = +2,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.CHARISMA_SAVING_THROW,
|
||||
multiplier = 0,
|
||||
modifier = +0,
|
||||
),
|
||||
),
|
||||
proficiencies = listOf(
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.ACROBATICS,
|
||||
multiplier = 0,
|
||||
modifier = +0,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.ANIMAL_HANDLING,
|
||||
multiplier = 0,
|
||||
modifier = 2,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.ARCANA,
|
||||
multiplier = 0,
|
||||
modifier = -1,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.ATHLETICS,
|
||||
multiplier = 1,
|
||||
modifier = 5,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.DECEPTION,
|
||||
multiplier = 0,
|
||||
modifier = 0,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.HISTORY,
|
||||
multiplier = 0,
|
||||
modifier = -1,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.INSIGHT,
|
||||
multiplier = 1,
|
||||
modifier = 4,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.INTIMIDATION,
|
||||
multiplier = 1,
|
||||
modifier = 2,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.INVESTIGATION,
|
||||
multiplier = 0,
|
||||
modifier = -1,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.MEDICINE,
|
||||
multiplier = 0,
|
||||
modifier = 2,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.NATURE,
|
||||
multiplier = 0,
|
||||
modifier = -1,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.PERCEPTION,
|
||||
multiplier = 1,
|
||||
modifier = 4,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.PERFORMANCE,
|
||||
multiplier = 0,
|
||||
modifier = 0,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.PERSUASION,
|
||||
multiplier = 0,
|
||||
modifier = 0,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.RELIGION,
|
||||
multiplier = 0,
|
||||
modifier = -1,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.SLEIGHT_OF_HAND,
|
||||
multiplier = 0,
|
||||
modifier = 0,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.STEALTH,
|
||||
multiplier = 0,
|
||||
modifier = 0,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.SURVIVAL,
|
||||
multiplier = 1,
|
||||
modifier = 4,
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
Surface {
|
||||
CharacterSheetContent(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
state = rememberScrollState(),
|
||||
pagerState = rememberPagerState { 1 },
|
||||
refreshState = rememberPullRefreshState(refreshing = false, onRefresh = { }),
|
||||
refreshing = remember { mutableStateOf(false) },
|
||||
onRefresh = { },
|
||||
sheet = bru,
|
||||
sheet = rememberCharacterSheetPreview(),
|
||||
actions = remember {
|
||||
mutableStateOf(
|
||||
listOf(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.pixelized.rplexicon.ui.screens.character
|
||||
package com.pixelized.rplexicon.ui.screens.character.pages
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
package com.pixelized.rplexicon.ui.screens.character
|
||||
package com.pixelized.rplexicon.ui.screens.character.pages
|
||||
|
||||
import android.content.res.Configuration.UI_MODE_NIGHT_NO
|
||||
import android.content.res.Configuration.UI_MODE_NIGHT_YES
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.padding
|
||||
|
|
@ -9,6 +12,7 @@ import androidx.compose.foundation.layout.sizeIn
|
|||
import androidx.compose.foundation.shape.CutCornerShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
|
|
@ -20,13 +24,17 @@ import androidx.compose.ui.layout.Measurable
|
|||
import androidx.compose.ui.layout.layoutId
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.ui.screens.character.CharacterSheetUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.Proficiency
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.ProficiencyUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.Stat
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.StatUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.preview.rememberCharacterSheetPreview
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
import com.pixelized.rplexicon.utilitary.extentions.ddBorder
|
||||
|
||||
@Composable
|
||||
|
|
@ -39,8 +47,8 @@ fun ProficiencyPage(
|
|||
onStats: (StatUio) -> Unit,
|
||||
onProficiencies: (ProficiencyUio) -> Unit,
|
||||
) {
|
||||
Box(modifier = modifier) {
|
||||
ProficiencyLayout(
|
||||
modifier = modifier,
|
||||
inner = inner,
|
||||
outline = outline,
|
||||
stats = {
|
||||
|
|
@ -97,11 +105,11 @@ fun ProficiencyPage(
|
|||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ProficiencyLayout(
|
||||
modifier: Modifier = Modifier,
|
||||
spacing: Dp = 16.dp,
|
||||
inner: Shape,
|
||||
outline: Shape,
|
||||
|
|
@ -111,7 +119,6 @@ private fun ProficiencyLayout(
|
|||
) {
|
||||
val density = LocalDensity.current
|
||||
Layout(
|
||||
modifier = modifier,
|
||||
content = {
|
||||
Column(
|
||||
modifier = Modifier.layoutId("StatsId"),
|
||||
|
|
@ -183,3 +190,20 @@ private fun ProficiencyLayout(
|
|||
val List<Measurable>.stats get() = first { it.layoutId == "StatsId" }
|
||||
val List<Measurable>.savingThrows get() = first { it.layoutId == "SavingThrowsId" }
|
||||
val List<Measurable>.proficiencies get() = first { it.layoutId == "ProficienciesId" }
|
||||
|
||||
@Composable
|
||||
@Preview(uiMode = UI_MODE_NIGHT_NO, heightDp = 1060)
|
||||
@Preview(uiMode = UI_MODE_NIGHT_YES, heightDp = 1060)
|
||||
private fun ProficiencyPreview() {
|
||||
LexiconTheme {
|
||||
Surface {
|
||||
ProficiencyPage(
|
||||
modifier = Modifier.padding(all = 16.dp),
|
||||
sheet = rememberCharacterSheetPreview(),
|
||||
onInitiative = { },
|
||||
onStats = { },
|
||||
onProficiencies = { },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,191 @@
|
|||
package com.pixelized.rplexicon.ui.screens.character.preview
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.runtime.remember
|
||||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.ui.screens.character.CharacterSheetUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.LabelPointUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.ProficiencyUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.StatUio
|
||||
|
||||
@Stable
|
||||
@Composable
|
||||
fun rememberCharacterSheetPreview() = remember {
|
||||
CharacterSheetUio(
|
||||
armorClass = LabelPointUio(
|
||||
label = R.string.character_sheet_title_ca,
|
||||
value = "15",
|
||||
),
|
||||
hitPoint = LabelPointUio(
|
||||
label = R.string.character_sheet_title_hp,
|
||||
value = "125",
|
||||
max = "/ 150",
|
||||
),
|
||||
speed = LabelPointUio(
|
||||
label = R.string.character_sheet_title_speed,
|
||||
value = "30",
|
||||
max = "m",
|
||||
),
|
||||
initiative = LabelPointUio(
|
||||
label = R.string.character_sheet_title_initiative,
|
||||
value = "+2",
|
||||
),
|
||||
stats = listOf(
|
||||
StatUio(
|
||||
id = StatUio.ID.STRENGTH,
|
||||
value = 16,
|
||||
modifier = 3,
|
||||
),
|
||||
StatUio(
|
||||
id = StatUio.ID.DEXTERITY,
|
||||
value = 10,
|
||||
modifier = 0,
|
||||
),
|
||||
StatUio(
|
||||
id = StatUio.ID.CONSTITUTION,
|
||||
value = 16,
|
||||
modifier = 3,
|
||||
),
|
||||
StatUio(
|
||||
id = StatUio.ID.INTELLIGENCE,
|
||||
value = 8,
|
||||
modifier = 1,
|
||||
),
|
||||
StatUio(
|
||||
id = StatUio.ID.WISDOM,
|
||||
value = 14,
|
||||
modifier = 2,
|
||||
),
|
||||
StatUio(
|
||||
id = StatUio.ID.CHARISMA,
|
||||
value = 10,
|
||||
modifier = 0,
|
||||
),
|
||||
),
|
||||
savingThrows = listOf(
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.STRENGTH_SAVING_THROW,
|
||||
multiplier = 1,
|
||||
modifier = 5,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.DEXTERITY_SAVING_THROW,
|
||||
multiplier = 0,
|
||||
modifier = 0,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.CONSTITUTION_SAVING_THROW,
|
||||
multiplier = 1,
|
||||
modifier = +5,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.INTELLIGENCE_SAVING_THROW,
|
||||
multiplier = 0,
|
||||
modifier = -1,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.WISDOM_SAVING_THROW,
|
||||
multiplier = 0,
|
||||
modifier = +2,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.CHARISMA_SAVING_THROW,
|
||||
multiplier = 0,
|
||||
modifier = +0,
|
||||
),
|
||||
),
|
||||
proficiencies = listOf(
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.ACROBATICS,
|
||||
multiplier = 0,
|
||||
modifier = +0,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.ANIMAL_HANDLING,
|
||||
multiplier = 0,
|
||||
modifier = 2,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.ARCANA,
|
||||
multiplier = 0,
|
||||
modifier = -1,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.ATHLETICS,
|
||||
multiplier = 1,
|
||||
modifier = 5,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.DECEPTION,
|
||||
multiplier = 0,
|
||||
modifier = 0,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.HISTORY,
|
||||
multiplier = 0,
|
||||
modifier = -1,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.INSIGHT,
|
||||
multiplier = 1,
|
||||
modifier = 4,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.INTIMIDATION,
|
||||
multiplier = 1,
|
||||
modifier = 2,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.INVESTIGATION,
|
||||
multiplier = 0,
|
||||
modifier = -1,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.MEDICINE,
|
||||
multiplier = 0,
|
||||
modifier = 2,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.NATURE,
|
||||
multiplier = 0,
|
||||
modifier = -1,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.PERCEPTION,
|
||||
multiplier = 1,
|
||||
modifier = 4,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.PERFORMANCE,
|
||||
multiplier = 0,
|
||||
modifier = 0,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.PERSUASION,
|
||||
multiplier = 0,
|
||||
modifier = 0,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.RELIGION,
|
||||
multiplier = 0,
|
||||
modifier = -1,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.SLEIGHT_OF_HAND,
|
||||
multiplier = 0,
|
||||
modifier = 0,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.STEALTH,
|
||||
multiplier = 0,
|
||||
modifier = 0,
|
||||
),
|
||||
ProficiencyUio(
|
||||
id = ProficiencyUio.ID.SURVIVAL,
|
||||
multiplier = 1,
|
||||
modifier = 4,
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue