Add shadow on circle + change map structure
This commit is contained in:
parent
01e312fce1
commit
dc35ac0ef9
7 changed files with 60 additions and 31 deletions
|
|
@ -49,7 +49,7 @@ class LocationParser @Inject constructor() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val COLUMNS = listOf(
|
private val COLUMNS = listOf(
|
||||||
"nom", "carte"
|
"Nom", "Carte"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.pixelized.rplexicon.facotry
|
package com.pixelized.rplexicon.facotry
|
||||||
|
|
||||||
|
import androidx.compose.ui.geometry.Offset
|
||||||
import com.google.api.services.sheets.v4.model.ValueRange
|
import com.google.api.services.sheets.v4.model.ValueRange
|
||||||
import com.pixelized.rplexicon.model.Location
|
import com.pixelized.rplexicon.model.Location
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.checkSheetStructure
|
import com.pixelized.rplexicon.utilitary.extentions.checkSheetStructure
|
||||||
|
|
@ -30,12 +31,14 @@ class MarqueeParser @Inject constructor() {
|
||||||
?.toFloatOrNull()
|
?.toFloatOrNull()
|
||||||
val description = item.getOrNull(structure.description) as? String?
|
val description = item.getOrNull(structure.description) as? String?
|
||||||
|
|
||||||
if (map != null && name != null && x != null && y != null) {
|
if (map != null && name != null) {
|
||||||
Location.Marquee(
|
Location.Marquee(
|
||||||
map = map,
|
map = map,
|
||||||
name = name,
|
name = name,
|
||||||
x = x,
|
position = when {
|
||||||
y = y,
|
x != null && y != null -> Offset(x, y)
|
||||||
|
else -> Offset.Unspecified
|
||||||
|
},
|
||||||
description = description,
|
description = description,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -56,7 +59,7 @@ class MarqueeParser @Inject constructor() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val COLUMNS = listOf(
|
private val COLUMNS = listOf(
|
||||||
"carte", "nom", "x", "y", "description"
|
"Carte", "Nom", "X", "Y", "Description"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package com.pixelized.rplexicon.model
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
|
import androidx.compose.ui.geometry.Offset
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
data class Location(
|
data class Location(
|
||||||
|
|
@ -15,8 +16,7 @@ data class Location(
|
||||||
data class Marquee(
|
data class Marquee(
|
||||||
val map: String,
|
val map: String,
|
||||||
val name: String,
|
val name: String,
|
||||||
val x: Float,
|
val position: Offset,
|
||||||
val y: Float,
|
|
||||||
val description: String?,
|
val description: String?,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -6,6 +6,7 @@ import androidx.compose.animation.core.animateOffsetAsState
|
||||||
import androidx.compose.foundation.gestures.detectTapGestures
|
import androidx.compose.foundation.gestures.detectTapGestures
|
||||||
import androidx.compose.foundation.gestures.detectTransformGestures
|
import androidx.compose.foundation.gestures.detectTransformGestures
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
|
|
@ -28,6 +29,7 @@ import androidx.compose.ui.layout.onSizeChanged
|
||||||
import androidx.compose.ui.unit.IntSize
|
import androidx.compose.ui.unit.IntSize
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.pixelized.rplexicon.ui.composable.AsyncImage
|
import com.pixelized.rplexicon.ui.composable.AsyncImage
|
||||||
|
import com.pixelized.rplexicon.utilitary.extentions.lexicon
|
||||||
import com.skydoves.landscapist.ImageOptions
|
import com.skydoves.landscapist.ImageOptions
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -40,6 +42,7 @@ fun FantasyMap(
|
||||||
selectedItem: State<Int>,
|
selectedItem: State<Int>,
|
||||||
onMarquee: (MarqueeUio) -> Unit,
|
onMarquee: (MarqueeUio) -> Unit,
|
||||||
) {
|
) {
|
||||||
|
val colorScheme = MaterialTheme.lexicon.colorScheme
|
||||||
val animatedScale = animateFloatAsState(targetValue = state.scale, label = "ScaleAnimation")
|
val animatedScale = animateFloatAsState(targetValue = state.scale, label = "ScaleAnimation")
|
||||||
val animatedOffset = animateOffsetAsState(targetValue = state.offset, label = "OffsetAnimation")
|
val animatedOffset = animateOffsetAsState(targetValue = state.offset, label = "OffsetAnimation")
|
||||||
|
|
||||||
|
|
@ -82,20 +85,33 @@ fun FantasyMap(
|
||||||
.drawWithContent {
|
.drawWithContent {
|
||||||
drawContent()
|
drawContent()
|
||||||
item.value.marquees.forEachIndexed { index, item ->
|
item.value.marquees.forEachIndexed { index, item ->
|
||||||
drawCircle(
|
if (item.position != Offset.Unspecified) {
|
||||||
color = when (selectedItem.value) {
|
drawCircle(
|
||||||
index -> Color.Cyan
|
color = colorScheme.shadow,
|
||||||
else -> Color.White
|
radius = 12.dp.toPx() / animatedScale.value,
|
||||||
},
|
style = Stroke(
|
||||||
radius = 12.dp.toPx() / animatedScale.value,
|
width = 2.dp.toPx() / animatedScale.value,
|
||||||
style = Stroke(
|
),
|
||||||
width = 2.dp.toPx() / animatedScale.value
|
center = Offset(
|
||||||
),
|
x = size.width * item.position.x,
|
||||||
center = Offset(
|
y = size.height * item.position.y + 2.dp.toPx() / animatedScale.value,
|
||||||
x = size.width * item.position.x,
|
)
|
||||||
y = size.height * item.position.y
|
|
||||||
)
|
)
|
||||||
)
|
drawCircle(
|
||||||
|
color = when (selectedItem.value) {
|
||||||
|
index -> Color.Cyan
|
||||||
|
else -> Color.White
|
||||||
|
},
|
||||||
|
radius = 12.dp.toPx() / animatedScale.value,
|
||||||
|
style = Stroke(
|
||||||
|
width = 2.dp.toPx() / animatedScale.value,
|
||||||
|
),
|
||||||
|
center = Offset(
|
||||||
|
x = size.width * item.position.x,
|
||||||
|
y = size.height * item.position.y,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.pointerInput("DetectTapGestures") {
|
.pointerInput("DetectTapGestures") {
|
||||||
|
|
@ -169,10 +185,12 @@ class FantasyMapState(
|
||||||
fun pan(
|
fun pan(
|
||||||
offset: Offset,
|
offset: Offset,
|
||||||
) {
|
) {
|
||||||
_offset.value = Offset(
|
if (offset != Offset.Unspecified) {
|
||||||
x = maxOf(minX, minOf(maxX, offset.x)),
|
_offset.value = Offset(
|
||||||
y = maxOf(minY, minOf(maxY, offset.y)),
|
x = maxOf(minX, minOf(maxX, offset.x)),
|
||||||
)
|
y = maxOf(minY, minOf(maxY, offset.y)),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
|
|
@ -180,9 +198,13 @@ class FantasyMapState(
|
||||||
origin: Offset,
|
origin: Offset,
|
||||||
size: IntSize = imageSize,
|
size: IntSize = imageSize,
|
||||||
): Offset {
|
): Offset {
|
||||||
return Offset(
|
return when (origin != Offset.Unspecified) {
|
||||||
x = (size.width / 2f - origin.x * size.width) * scale,
|
true -> Offset(
|
||||||
y = (size.height / 2f - origin.y * size.height) * scale,
|
x = (size.width / 2f - origin.x * size.width) * scale,
|
||||||
)
|
y = (size.height / 2f - origin.y * size.height) * scale,
|
||||||
|
)
|
||||||
|
|
||||||
|
else -> origin
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -28,7 +28,7 @@ class LocationDetailViewModel @Inject constructor(
|
||||||
marquees = source.marquees.map { marquee ->
|
marquees = source.marquees.map { marquee ->
|
||||||
MarqueeUio(
|
MarqueeUio(
|
||||||
name = marquee.name,
|
name = marquee.name,
|
||||||
position = Offset(x = marquee.x, y = marquee.y),
|
position = marquee.position,
|
||||||
description = marquee.description,
|
description = marquee.description,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import androidx.compose.ui.graphics.Color
|
||||||
@Immutable
|
@Immutable
|
||||||
class LexiconColors(
|
class LexiconColors(
|
||||||
val base: ColorScheme,
|
val base: ColorScheme,
|
||||||
|
val shadow: Color,
|
||||||
val status: Color,
|
val status: Color,
|
||||||
val navigation: Color,
|
val navigation: Color,
|
||||||
val placeholder: Color,
|
val placeholder: Color,
|
||||||
|
|
@ -25,11 +26,13 @@ fun darkColorScheme(
|
||||||
tertiary = BaseDark.Pink80,
|
tertiary = BaseDark.Pink80,
|
||||||
onPrimary = Color.White,
|
onPrimary = Color.White,
|
||||||
),
|
),
|
||||||
|
shadow: Color = ShadowPalette.shadow,
|
||||||
status: Color = Color.Transparent,
|
status: Color = Color.Transparent,
|
||||||
navigation: Color = Color.Transparent,
|
navigation: Color = Color.Transparent,
|
||||||
placeholder: Color = Color(red = 49, green = 48, blue = 51),
|
placeholder: Color = Color(red = 49, green = 48, blue = 51),
|
||||||
) = LexiconColors(
|
) = LexiconColors(
|
||||||
base = base,
|
base = base,
|
||||||
|
shadow = shadow,
|
||||||
status = status,
|
status = status,
|
||||||
navigation = navigation,
|
navigation = navigation,
|
||||||
placeholder = placeholder,
|
placeholder = placeholder,
|
||||||
|
|
@ -44,11 +47,13 @@ fun lightColorScheme(
|
||||||
tertiary = BaseLight.Pink40,
|
tertiary = BaseLight.Pink40,
|
||||||
onPrimary = Color.White,
|
onPrimary = Color.White,
|
||||||
),
|
),
|
||||||
|
shadow: Color = ShadowPalette.shadow,
|
||||||
status: Color = Color.Transparent,
|
status: Color = Color.Transparent,
|
||||||
navigation: Color = Color.Transparent,
|
navigation: Color = Color.Transparent,
|
||||||
placeholder: Color = Color(red = 230, green = 225, blue = 229),
|
placeholder: Color = Color(red = 230, green = 225, blue = 229),
|
||||||
) = LexiconColors(
|
) = LexiconColors(
|
||||||
base = base,
|
base = base,
|
||||||
|
shadow = shadow,
|
||||||
status = status,
|
status = status,
|
||||||
navigation = navigation,
|
navigation = navigation,
|
||||||
placeholder = placeholder,
|
placeholder = placeholder,
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,5 @@ import androidx.compose.ui.graphics.Color
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
object ShadowPalette {
|
object ShadowPalette {
|
||||||
val system: Color = Color.Black.copy(alpha = 0.37f)
|
val shadow: Color = Color.Black.copy(alpha = 0.25f)
|
||||||
val scrim: Color = Color.Black.copy(alpha = 0.37f)
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue