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