Refactor typography.
This commit is contained in:
parent
82ce19ec4d
commit
ff1ac694bb
18 changed files with 148 additions and 196 deletions
|
|
@ -14,13 +14,13 @@ import androidx.compose.material3.Text
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
import com.pixelized.rplexicon.utilitary.annotateWithDropCap
|
||||
import com.pixelized.rplexicon.utilitary.extentions.lexicon
|
||||
|
||||
|
||||
|
|
@ -38,22 +38,14 @@ fun GenericHeader(
|
|||
) {
|
||||
Text(
|
||||
modifier = Modifier.padding(paddingValues = padding),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
text = stringResource(id = label).let {
|
||||
AnnotatedString(
|
||||
text = it,
|
||||
spanStyles = listOf(
|
||||
AnnotatedString.Range(
|
||||
item = MaterialTheme.lexicon.typography.bodyDropCapSpan,
|
||||
start = 0,
|
||||
end = Integer.min(1, it.length),
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
text = annotateWithDropCap(
|
||||
text = stringResource(id = label),
|
||||
style = MaterialTheme.lexicon.typography.titleMediumDropCap,
|
||||
),
|
||||
)
|
||||
}
|
||||
Divider(
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import androidx.compose.runtime.Stable
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
|
|
@ -27,6 +27,7 @@ import androidx.compose.ui.unit.dp
|
|||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.common.CounterButton
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
import com.pixelized.rplexicon.utilitary.annotateWithDropCap
|
||||
import com.pixelized.rplexicon.utilitary.extentions.lexicon
|
||||
|
||||
@Stable
|
||||
|
|
@ -64,26 +65,19 @@ fun SpellHeader(
|
|||
.weight(1f)
|
||||
.alignByBaseline(),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
text = annotateWithDropCap(
|
||||
text = stringResource(
|
||||
id = when (header.level) {
|
||||
0 -> R.string.character_sheet_action_spell_level_0
|
||||
else -> R.string.character_sheet_action_spell_level_X
|
||||
},
|
||||
header.level
|
||||
).let { label ->
|
||||
AnnotatedString(
|
||||
text = label,
|
||||
spanStyles = listOf(
|
||||
AnnotatedString.Range(
|
||||
item = MaterialTheme.lexicon.typography.bodyDropCapSpan,
|
||||
start = 0,
|
||||
end = Integer.min(1, label.length),
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
),
|
||||
style = MaterialTheme.lexicon.typography.titleMediumDropCap,
|
||||
),
|
||||
)
|
||||
header.count?.let { count ->
|
||||
CounterButton(
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ fun ActionsPageContent(
|
|||
}
|
||||
}
|
||||
|
||||
spells.value.forEach { entry ->
|
||||
spells.value.forEachIndexed { index, entry ->
|
||||
stickyHeader {
|
||||
SpellHeader(
|
||||
header = entry.first,
|
||||
|
|
@ -242,6 +242,11 @@ fun ActionsPageContent(
|
|||
onCast = onCast,
|
||||
)
|
||||
}
|
||||
if (index != spells.value.lastIndex) {
|
||||
items(count = 1) {
|
||||
Spacer(modifier = Modifier.height(height = 16.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ fun SkillDetail(
|
|||
text = detail.name,
|
||||
spanStyles = listOf(
|
||||
AnnotatedString.Range(
|
||||
item = MaterialTheme.lexicon.typography.bodyDropCapSpan,
|
||||
item = MaterialTheme.lexicon.typography.titleMediumDropCap,
|
||||
start = 0,
|
||||
end = Integer.min(1, detail.name.length),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
|
|
@ -34,6 +33,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.dp
|
||||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
import com.pixelized.rplexicon.utilitary.annotateWithDropCap
|
||||
import com.pixelized.rplexicon.utilitary.extentions.ddBorder
|
||||
import com.pixelized.rplexicon.utilitary.extentions.lexicon
|
||||
|
||||
|
|
@ -77,17 +77,12 @@ fun AlterationDetail(
|
|||
Text(
|
||||
modifier = Modifier.alignByBaseline(),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
maxLines = 1,
|
||||
fontWeight = FontWeight.Bold,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
text = AnnotatedString(
|
||||
maxLines = 1,
|
||||
text = annotateWithDropCap(
|
||||
text = detail.name,
|
||||
spanStyles = listOf(
|
||||
AnnotatedString.Range(
|
||||
item = MaterialTheme.lexicon.typography.bodyDropCapSpan,
|
||||
start = 0,
|
||||
end = Integer.min(1, detail.name.length),
|
||||
)
|
||||
)
|
||||
style = MaterialTheme.lexicon.typography.titleMediumDropCap,
|
||||
),
|
||||
)
|
||||
detail.original?.let {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import androidx.compose.ui.graphics.ColorFilter
|
|||
import androidx.compose.ui.graphics.RectangleShape
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
|
|
@ -37,6 +36,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
|||
import androidx.compose.ui.unit.dp
|
||||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
import com.pixelized.rplexicon.utilitary.annotateWithDropCap
|
||||
import com.pixelized.rplexicon.utilitary.extentions.lexicon
|
||||
|
||||
@Stable
|
||||
|
|
@ -115,15 +115,9 @@ private fun LandingHorizontalItem(
|
|||
modifier = Modifier.alignByBaseline(),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
fontWeight = FontWeight.Normal,
|
||||
text = AnnotatedString(
|
||||
text = annotateWithDropCap(
|
||||
text = it,
|
||||
spanStyles = listOf(
|
||||
AnnotatedString.Range(
|
||||
item = MaterialTheme.lexicon.typography.bodyDropCapSpan,
|
||||
start = 0,
|
||||
end = Integer.min(1, it.length),
|
||||
)
|
||||
),
|
||||
style = MaterialTheme.lexicon.typography.titleLargeDropCap,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import androidx.compose.ui.unit.Dp
|
|||
import androidx.compose.ui.unit.dp
|
||||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
import com.pixelized.rplexicon.utilitary.annotateWithDropCap
|
||||
import com.pixelized.rplexicon.utilitary.extentions.lexicon
|
||||
|
||||
@Composable
|
||||
|
|
@ -45,15 +46,9 @@ private fun LandingContent(
|
|||
Text(
|
||||
modifier = Modifier.padding(horizontal = padding),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
text = AnnotatedString(
|
||||
text = annotateWithDropCap(
|
||||
text = "Feuilles de personnages",
|
||||
spanStyles = listOf(
|
||||
AnnotatedString.Range(
|
||||
item = MaterialTheme.lexicon.typography.titleDropCapSpan,
|
||||
start = 0,
|
||||
end = Integer.min(1, "Character".length),
|
||||
)
|
||||
),
|
||||
style = MaterialTheme.lexicon.typography.titleLargeDropCap,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -72,15 +67,9 @@ private fun LandingContent(
|
|||
Text(
|
||||
modifier = Modifier.padding(horizontal = padding),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
text = AnnotatedString(
|
||||
text = annotateWithDropCap(
|
||||
text = "Lexique",
|
||||
spanStyles = listOf(
|
||||
AnnotatedString.Range(
|
||||
item = MaterialTheme.lexicon.typography.titleDropCapSpan,
|
||||
start = 0,
|
||||
end = Integer.min(1, "Lexique".length),
|
||||
)
|
||||
),
|
||||
MaterialTheme.lexicon.typography.titleLargeDropCap,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ fun LexiconItem(
|
|||
modifier = Modifier
|
||||
.alignByBaseline()
|
||||
.placeholder { item.placeholder },
|
||||
style = typography.base.titleMedium,
|
||||
text = if (item.isPlayingCharacter) LOS_FULL else LOS_HOLLOW,
|
||||
)
|
||||
|
||||
|
|
@ -94,7 +95,7 @@ fun LexiconItem(
|
|||
modifier = Modifier
|
||||
.alignByBaseline()
|
||||
.placeholder { item.placeholder },
|
||||
style = typography.base.bodyLarge,
|
||||
style = typography.base.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
|
|
@ -104,7 +105,7 @@ fun LexiconItem(
|
|||
true -> emptyList()
|
||||
else -> listOf(
|
||||
AnnotatedString.Range(
|
||||
item = typography.bodyDropCapSpan,
|
||||
item = typography.titleMediumDropCap,
|
||||
start = 0,
|
||||
end = 1,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import androidx.compose.runtime.Stable
|
|||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
|
|
@ -39,10 +40,10 @@ fun FantasyMap(
|
|||
state: FantasyMapState,
|
||||
model: Any?,
|
||||
contentScale: ContentScale = ContentScale.Fit,
|
||||
items: State<List<AnnotatedMarqueeUio>>,
|
||||
items: State<List<MarqueeUio>>,
|
||||
highlight: State<Offset>,
|
||||
selectedItem: State<Int>,
|
||||
onMarquee: (AnnotatedMarqueeUio) -> Unit,
|
||||
onMarquee: (MarqueeUio) -> Unit,
|
||||
onTap: (Offset) -> Unit,
|
||||
) {
|
||||
val lexiconTheme = MaterialTheme.lexicon
|
||||
|
|
@ -197,7 +198,7 @@ class FantasyMapState(
|
|||
private val maxY by derivedStateOf { imageSize.height * scale / 2f }
|
||||
private val minY by derivedStateOf { -maxY }
|
||||
|
||||
private val _scale: MutableState<Float> = mutableStateOf(initialScale)
|
||||
private val _scale: MutableState<Float> = mutableFloatStateOf(initialScale)
|
||||
val scale: Float by _scale
|
||||
|
||||
private val _offset: MutableState<Offset> = mutableStateOf(initialOffset)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.pixelized.rplexicon.ui.screens.location.detail
|
|||
import android.content.res.Configuration
|
||||
import android.net.Uri
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.ScrollState
|
||||
import androidx.compose.foundation.gestures.scrollBy
|
||||
import androidx.compose.foundation.layout.Box
|
||||
|
|
@ -48,9 +47,7 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.graphics.RectangleShape
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
|
|
@ -61,7 +58,6 @@ import androidx.compose.ui.platform.LocalDensity
|
|||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.IntOffset
|
||||
|
|
@ -73,6 +69,7 @@ import com.pixelized.rplexicon.R
|
|||
import com.pixelized.rplexicon.ui.composable.Handle
|
||||
import com.pixelized.rplexicon.ui.navigation.LocalScreenNavHost
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
import com.pixelized.rplexicon.utilitary.annotateWithDropCap
|
||||
import com.pixelized.rplexicon.utilitary.extentions.lexicon
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
|
|
@ -86,13 +83,6 @@ data class LocationDetailUio(
|
|||
val marquees: List<MarqueeUio>,
|
||||
)
|
||||
|
||||
@Stable
|
||||
data class AnnotatedLocationDetailUio(
|
||||
val name: AnnotatedString,
|
||||
val map: Uri,
|
||||
val marquees: List<AnnotatedMarqueeUio>,
|
||||
)
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun LocationDetail(
|
||||
|
|
@ -114,7 +104,6 @@ fun LocationDetail(
|
|||
|
||||
val ok = stringResource(id = android.R.string.ok)
|
||||
|
||||
val location = rememberAnnotation(item = viewModel.location)
|
||||
val snackJob = remember { mutableStateOf<Job?>(null) }
|
||||
val mapHighlight = remember { mutableStateOf(Offset.Unspecified) }
|
||||
val selectedIndex = remember { mutableIntStateOf(0) }
|
||||
|
|
@ -128,7 +117,7 @@ fun LocationDetail(
|
|||
scrollState = scroll,
|
||||
pagerState = pager,
|
||||
fantasyMapState = fantasy,
|
||||
item = location,
|
||||
item = viewModel.location,
|
||||
selectedIndex = selectedIndex,
|
||||
mapHighlight = mapHighlight,
|
||||
onBack = {
|
||||
|
|
@ -136,7 +125,7 @@ fun LocationDetail(
|
|||
},
|
||||
onMarquee = {
|
||||
scope.launch {
|
||||
val index = max(location.value.marquees.indexOf(it), 0)
|
||||
val index = max(viewModel.location.value.marquees.indexOf(it), 0)
|
||||
selectedIndex.value = index
|
||||
pager.animateScrollToPage(page = index)
|
||||
}
|
||||
|
|
@ -225,11 +214,11 @@ private fun LocationContent(
|
|||
scrollState: ScrollState,
|
||||
pagerState: PagerState,
|
||||
fantasyMapState: FantasyMapState,
|
||||
item: State<AnnotatedLocationDetailUio>,
|
||||
item: State<LocationDetailUio>,
|
||||
selectedIndex: State<Int>,
|
||||
mapHighlight: State<Offset>,
|
||||
onBack: () -> Unit,
|
||||
onMarquee: (AnnotatedMarqueeUio) -> Unit,
|
||||
onMarquee: (MarqueeUio) -> Unit,
|
||||
onMapTap: (Offset) -> Unit,
|
||||
onTouch: (Boolean) -> Unit,
|
||||
onCenter: () -> Unit,
|
||||
|
|
@ -366,7 +355,10 @@ private fun LocationContent(
|
|||
Text(
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
text = annotateWithDropCap(
|
||||
text = item.value.name,
|
||||
style = MaterialTheme.lexicon.typography.headlineSmallDropCap,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -411,31 +403,6 @@ private fun HandlePagerScroll(
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Stable
|
||||
fun rememberAnnotation(item: State<LocationDetailUio>): State<AnnotatedLocationDetailUio> {
|
||||
val typography = MaterialTheme.lexicon.typography
|
||||
|
||||
return remember(item) {
|
||||
derivedStateOf {
|
||||
AnnotatedLocationDetailUio(
|
||||
name = AnnotatedString(
|
||||
text = item.value.name,
|
||||
spanStyles = listOf(
|
||||
AnnotatedString.Range(
|
||||
item = typography.titleDropCapSpan,
|
||||
start = 0,
|
||||
end = Integer.min(1, item.value.name.length),
|
||||
)
|
||||
)
|
||||
),
|
||||
map = item.value.map,
|
||||
marquees = item.value.marquees.map { it.annotate(typography) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Stable
|
||||
private fun rememberSnapConnection(
|
||||
|
|
@ -505,7 +472,7 @@ private fun LocationPreview() {
|
|||
scrollState = rememberScrollState(),
|
||||
pagerState = rememberPagerState(pageCount = { 2 }),
|
||||
fantasyMapState = rememberFantasyMapState(),
|
||||
item = rememberAnnotation(item = remember {
|
||||
item = remember {
|
||||
mutableStateOf(
|
||||
LocationDetailUio(
|
||||
name = "Daggerfall",
|
||||
|
|
@ -524,7 +491,7 @@ private fun LocationPreview() {
|
|||
),
|
||||
)
|
||||
)
|
||||
}),
|
||||
},
|
||||
selectedIndex = remember { mutableStateOf(0) },
|
||||
mapHighlight = remember { mutableStateOf(Offset(0.5f, 0.5f)) },
|
||||
onBack = { },
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.pixelized.rplexicon.ui.screens.location.detail
|
|||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
|
|
@ -13,15 +14,14 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
import com.pixelized.rplexicon.ui.theme.typography.LexiconTypography
|
||||
import com.pixelized.rplexicon.utilitary.LOS_HOLLOW
|
||||
import com.pixelized.rplexicon.utilitary.extentions.annotateWithDropCap
|
||||
import com.pixelized.rplexicon.utilitary.annotateWithDropCap
|
||||
import com.pixelized.rplexicon.utilitary.extentions.lexicon
|
||||
|
||||
@Stable
|
||||
|
|
@ -31,32 +31,10 @@ data class MarqueeUio(
|
|||
val description: String?,
|
||||
)
|
||||
|
||||
@Stable
|
||||
data class AnnotatedMarqueeUio(
|
||||
val name: AnnotatedString?,
|
||||
val position: Offset,
|
||||
val description: AnnotatedString?,
|
||||
)
|
||||
|
||||
@Stable
|
||||
fun MarqueeUio.annotate(
|
||||
typography: LexiconTypography
|
||||
): AnnotatedMarqueeUio {
|
||||
return AnnotatedMarqueeUio(
|
||||
name = name?.annotateWithDropCap(
|
||||
style = typography.bodyDropCapSpan,
|
||||
),
|
||||
position = position,
|
||||
description = description?.annotateWithDropCap(
|
||||
style = typography.bodyDropCapSpan,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun MarqueeItem(
|
||||
modifier: Modifier = Modifier,
|
||||
marquee: AnnotatedMarqueeUio,
|
||||
marquee: MarqueeUio,
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier,
|
||||
|
|
@ -73,10 +51,14 @@ fun MarqueeItem(
|
|||
Text(
|
||||
modifier = Modifier.alignByBaseline(),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
textAlign = TextAlign.Center,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 3,
|
||||
text = marquee.name,
|
||||
text = annotateWithDropCap(
|
||||
text = it,
|
||||
style = MaterialTheme.lexicon.typography.titleMediumDropCap,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -84,7 +66,10 @@ fun MarqueeItem(
|
|||
Text(
|
||||
modifier = Modifier.verticalScroll(rememberScrollState()),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
text = annotateWithDropCap(
|
||||
text = it,
|
||||
style = MaterialTheme.lexicon.typography.bodyMediumDropCap,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -96,14 +81,14 @@ private fun MarqueeItemPreview() {
|
|||
LexiconTheme {
|
||||
Surface {
|
||||
MarqueeItem(
|
||||
modifier = Modifier.padding(all = 16.dp),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(all = 16.dp),
|
||||
marquee = MarqueeUio(
|
||||
name = "Name",
|
||||
name = "Barovie",
|
||||
position = Offset.Zero,
|
||||
description = "description",
|
||||
).annotate(
|
||||
typography = MaterialTheme.lexicon.typography,
|
||||
)
|
||||
description = "Village lugubre à la population clairsemé théatre récent d'une d'une rebelion sanglante.",
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
|
|
@ -63,6 +65,7 @@ fun LocationItem(
|
|||
true -> Modifier.placeholder { true }
|
||||
else -> Modifier.alignByBaseline()
|
||||
},
|
||||
style = typography.base.titleMedium,
|
||||
text = LOS_HOLLOW,
|
||||
)
|
||||
Text(
|
||||
|
|
@ -70,6 +73,10 @@ fun LocationItem(
|
|||
true -> Modifier.placeholder { true }
|
||||
else -> Modifier.alignByBaseline()
|
||||
},
|
||||
style = typography.base.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
text = remember(item.placeholder) {
|
||||
AnnotatedString(
|
||||
text = item.title,
|
||||
|
|
@ -77,7 +84,7 @@ fun LocationItem(
|
|||
true -> emptyList()
|
||||
else -> listOf(
|
||||
AnnotatedString.Range(
|
||||
item = typography.bodyDropCapSpan,
|
||||
item = typography.titleMediumDropCap,
|
||||
start = 0,
|
||||
end = 1,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ import com.pixelized.rplexicon.ui.navigation.screens.navigateToLocationDetail
|
|||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
import com.pixelized.rplexicon.utilitary.LOS_FULL
|
||||
import com.pixelized.rplexicon.utilitary.LOS_HOLLOW
|
||||
import com.pixelized.rplexicon.utilitary.extentions.annotateWithDropCap
|
||||
import com.pixelized.rplexicon.utilitary.annotateWithDropCap
|
||||
import com.pixelized.rplexicon.utilitary.extentions.lexicon
|
||||
import com.pixelized.rplexicon.utilitary.extentions.scrollOffset
|
||||
|
||||
|
|
@ -183,7 +183,8 @@ private fun QuestDetailContent(
|
|||
.padding(bottom = 16.dp),
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.headlineLarge,
|
||||
text = quest.title.annotateWithDropCap(
|
||||
text = annotateWithDropCap(
|
||||
text = quest.title,
|
||||
style = MaterialTheme.lexicon.typography.headlineLargeDropCap,
|
||||
),
|
||||
)
|
||||
|
|
@ -201,7 +202,8 @@ private fun QuestDetailContent(
|
|||
textAlign = TextAlign.Center,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 3,
|
||||
text = subtitle.annotateWithDropCap(
|
||||
text = annotateWithDropCap(
|
||||
text = subtitle,
|
||||
style = MaterialTheme.lexicon.typography.titleLargeDropCap,
|
||||
),
|
||||
)
|
||||
|
|
@ -292,7 +294,8 @@ private fun QuestDetailContent(
|
|||
Text(
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
text = quest.description.annotateWithDropCap(
|
||||
text = annotateWithDropCap(
|
||||
text = quest.description,
|
||||
style = MaterialTheme.lexicon.typography.bodyMediumDropCap,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
|
|
@ -67,6 +69,7 @@ fun QuestItem(
|
|||
true -> Modifier.placeholder { true }
|
||||
else -> Modifier.alignByBaseline()
|
||||
},
|
||||
style = typography.base.titleMedium,
|
||||
text = if (item.complete) LOS_FULL else LOS_HOLLOW,
|
||||
)
|
||||
Text(
|
||||
|
|
@ -74,6 +77,10 @@ fun QuestItem(
|
|||
true -> Modifier.placeholder { true }
|
||||
else -> Modifier.alignByBaseline()
|
||||
},
|
||||
style = typography.base.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
text = remember(item.placeholder) {
|
||||
AnnotatedString(
|
||||
text = item.title,
|
||||
|
|
@ -81,7 +88,7 @@ fun QuestItem(
|
|||
true -> emptyList()
|
||||
else -> listOf(
|
||||
AnnotatedString.Range(
|
||||
item = typography.bodyDropCapSpan,
|
||||
item = typography.titleMediumDropCap,
|
||||
start = 0,
|
||||
end = 1,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
|
|
@ -164,12 +166,15 @@ private fun RollOverlayContent(
|
|||
Text(
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Normal,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
text = stringResource(id = R.string.dice_roll_alteration_action).let {
|
||||
AnnotatedString(
|
||||
text = it,
|
||||
spanStyles = listOf(
|
||||
AnnotatedString.Range(
|
||||
item = MaterialTheme.lexicon.typography.bodyDropCapSpan,
|
||||
item = MaterialTheme.lexicon.typography.titleMediumDropCap,
|
||||
start = 0,
|
||||
end = Integer.min(1, it.length),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import androidx.compose.ui.text.font.Font
|
|||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.BaselineShift
|
||||
import androidx.compose.ui.unit.TextUnit
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.pixelized.rplexicon.R
|
||||
|
||||
|
|
@ -28,43 +29,42 @@ class LexiconTypography(
|
|||
val stamp: TextStyle = base.headlineLarge.copy(
|
||||
fontFamily = stampFontFamily,
|
||||
),
|
||||
@Deprecated("")
|
||||
val bodyDropCap: TextStyle = base.headlineLarge.copy(
|
||||
fontFamily = zallFontFamily,
|
||||
baselineShift = BaselineShift(-0.1f),
|
||||
letterSpacing = (-3).sp
|
||||
),
|
||||
@Deprecated("")
|
||||
val titleDropCap: TextStyle = base.displayMedium.copy(
|
||||
fontFamily = zallFontFamily,
|
||||
baselineShift = BaselineShift(-0.1f),
|
||||
letterSpacing = (-4).sp
|
||||
),
|
||||
@Deprecated("")
|
||||
val bodyDropCapSpan: SpanStyle = bodyDropCap.toSpanStyle(),
|
||||
@Deprecated("")
|
||||
val titleDropCapSpan: SpanStyle = titleDropCap.toSpanStyle(),
|
||||
|
||||
val bodyMediumDropCap: SpanStyle = base.bodyMedium.toDropCapSpan(
|
||||
sizeRatio = 1.8f,
|
||||
antiLetterSpacing = 1.sp,
|
||||
baselineShift = BaselineShift(-0.08f),
|
||||
),
|
||||
val titleMediumDropCap: SpanStyle = base.titleMedium.toDropCapSpan(
|
||||
sizeRatio = 1.8f,
|
||||
antiLetterSpacing = 2.sp,
|
||||
baselineShift = BaselineShift(-0.04f),
|
||||
),
|
||||
|
||||
val titleLargeDropCap: SpanStyle = base.titleLarge.toDropCapSpan(
|
||||
sizeRatio = 1.4f,
|
||||
antiLetterSpacing = 2.sp,
|
||||
baselineShift = BaselineShift(-0.04f),
|
||||
),
|
||||
val headlineSmallDropCap: SpanStyle = base.headlineSmall.toDropCapSpan(
|
||||
antiLetterSpacing = 4.sp,
|
||||
sizeRatio = 1.2f,
|
||||
),
|
||||
|
||||
val headlineLargeDropCap: SpanStyle = base.headlineLarge.toDropCapSpan(
|
||||
antiLetterSpacing = 4.sp,
|
||||
sizeRatio = 1.2f,
|
||||
),
|
||||
)
|
||||
|
||||
private fun TextStyle.toDropCapSpan(
|
||||
sizeRatio : Float,
|
||||
sizeRatio: Float = 1.5f,
|
||||
antiLetterSpacing: TextUnit? = null,
|
||||
baselineShift: BaselineShift? = null,
|
||||
): SpanStyle {
|
||||
return copy(
|
||||
fontFamily = zallFontFamily,
|
||||
fontSize = fontSize * sizeRatio,
|
||||
letterSpacing = antiLetterSpacing?.let { -it } ?: this.letterSpacing,
|
||||
baselineShift = baselineShift ?: this.baselineShift
|
||||
).toSpanStyle()
|
||||
}
|
||||
|
||||
fun lexiconTypography() = LexiconTypography()
|
||||
fun lexiconTypography(): LexiconTypography = LexiconTypography()
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.pixelized.rplexicon.utilitary
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import com.pixelized.rplexicon.utilitary.extentions.annotatedSpan
|
||||
|
||||
private val dropCapRegex = Regex(
|
||||
pattern = "(?:^|\n\n)([A-Z])"
|
||||
)
|
||||
|
||||
@Stable
|
||||
fun annotateWithDropCap(
|
||||
text: String,
|
||||
style: SpanStyle,
|
||||
) = AnnotatedString(
|
||||
text = text,
|
||||
spanStyles = dropCapRegex.annotatedSpan(
|
||||
input = text,
|
||||
spanStyle = style,
|
||||
)
|
||||
)
|
||||
|
|
@ -6,10 +6,6 @@ import androidx.compose.ui.text.AnnotatedString
|
|||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.core.net.toUri
|
||||
|
||||
private val dropCapRegex = Regex(
|
||||
pattern = "(?:^|\n\n)([A-Z])"
|
||||
)
|
||||
|
||||
val String.ARG: String get() = "$this={$this}"
|
||||
|
||||
@Stable
|
||||
|
|
@ -41,17 +37,6 @@ val List<String>.finderRegex: Regex?
|
|||
)
|
||||
} else null
|
||||
|
||||
@Stable
|
||||
fun String.annotateWithDropCap(
|
||||
style: SpanStyle,
|
||||
) = AnnotatedString(
|
||||
text = this,
|
||||
spanStyles = dropCapRegex.annotatedSpan(
|
||||
input = this,
|
||||
spanStyle = style,
|
||||
)
|
||||
)
|
||||
|
||||
@Stable
|
||||
fun String?.toUriOrNull(): Uri? = try {
|
||||
this?.takeIf { it.isNotBlank() }?.toUri()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue