feat: 워치 앱 첫 장을 하늘 장 대신 주변 축제로 (축제가 없으면 오늘의 각부터)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c0e0363759
commit
1990a1f998
3 files changed
+5
-176
No files matched your search
@@ -50,7 +50,7 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private enum class Page { DETAIL, SKY, TOP, PICKS, EVENTS, SUNSET, HOURS }
|
||||
private enum class Page { DETAIL, EVENTS, TOP, PICKS, SUNSET, HOURS }
|
||||
|
||||
@Composable
|
||||
private fun App(s: Summary?, loading: Boolean, opened: String?, onRetry: () -> Unit) {
|
||||
@@ -65,14 +65,13 @@ private fun App(s: Summary?, loading: Boolean, opened: String?, onRetry: () -> U
|
||||
StatePage(loading, onRetry)
|
||||
return
|
||||
}
|
||||
// 스킨 링에서 누른 각이 있으면 그 상세부터, 아니면 하늘 장부터
|
||||
// 스킨 링에서 누른 각이 있으면 그 상세부터, 아니면 주변 축제부터 (축제가 없으면 오늘의 각부터)
|
||||
val detail = opened?.let { c -> (s.top + s.picks).firstOrNull { it.code == c } }
|
||||
val pages = buildList {
|
||||
if (detail != null) add(Page.DETAIL)
|
||||
add(Page.SKY)
|
||||
if (s.events.isNotEmpty()) add(Page.EVENTS)
|
||||
if (s.top.isNotEmpty()) add(Page.TOP)
|
||||
if (s.picks.isNotEmpty()) add(Page.PICKS)
|
||||
if (s.events.isNotEmpty()) add(Page.EVENTS)
|
||||
if (s.sunset != null) add(Page.SUNSET)
|
||||
if (s.slots.isNotEmpty()) add(Page.HOURS)
|
||||
}
|
||||
@@ -81,16 +80,15 @@ private fun App(s: Summary?, loading: Boolean, opened: String?, onRetry: () -> U
|
||||
VerticalPager(state = state, modifier = Modifier.fillMaxSize()) { i ->
|
||||
when (pages[i]) {
|
||||
Page.DETAIL -> DetailPage(detail!!, now)
|
||||
Page.SKY -> SkyPage(s, now)
|
||||
Page.EVENTS -> EventsPage(s.events, now)
|
||||
Page.TOP -> GakListPage("오늘의 각", s.top.take(3), bgButter, medals = true, now)
|
||||
Page.PICKS -> GakListPage("내 각", s.picks, bgMint, medals = false, now)
|
||||
Page.EVENTS -> EventsPage(s.events, now)
|
||||
Page.SUNSET -> SunsetPage(s.sunset!!, now)
|
||||
Page.HOURS -> HoursPage(s, now)
|
||||
}
|
||||
}
|
||||
val page = pages[state.currentPage]
|
||||
val dot = if (page == Page.SUNSET || (page == Page.SKY && isDark(s.mode))) Color.White else Tok.ink
|
||||
val dot = if (page == Page.SUNSET) Color.White else Tok.ink
|
||||
VerticalPageIndicator(pagerState = state, selectedColor = dot, unselectedColor = dot.copy(alpha = 0.35f), backgroundColor = Color.Transparent)
|
||||
}
|
||||
}
|
||||
@@ -56,17 +56,6 @@ import androidx.wear.compose.material3.Text
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
import kotlin.math.roundToInt
|
||||
import androidx.compose.animation.core.LinearEasing
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.withFrameNanos
|
||||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.ui.geometry.CornerRadius
|
||||
import java.time.format.TextStyle as DateTextStyle
|
||||
import java.util.Locale
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
// 시안 크기는 큰 원형(227dp) 기준. 작은 원형(192dp)에서도 넘치지 않게 비율과 여백으로 잡는다.
|
||||
|
||||
@@ -102,153 +91,6 @@ fun Clock(now: Instant, color: Color) {
|
||||
T(hhmm(now), 15.sp, FontFamily.Default, color.copy(alpha = 0.85f), Modifier.fillMaxWidth().padding(top = 6.dp), weight = FontWeight.Bold)
|
||||
}
|
||||
|
||||
// ───────────── 하늘 (앱 첫 장: 스킨은 초당 10장 안팎이라, 빠르게 흐르는 하늘은 여기서 60장으로) ─────────────
|
||||
|
||||
private val STARS = listOf(0.22f to 0.20f, 0.70f to 0.14f, 0.84f to 0.40f, 0.14f to 0.52f, 0.48f to 0.10f, 0.30f to 0.78f, 0.76f to 0.70f)
|
||||
|
||||
@Composable
|
||||
fun SkyPage(s: Summary, now: Instant) {
|
||||
val precip = s.precip
|
||||
val dark = isDark(s.mode)
|
||||
val night = s.mode == "night"
|
||||
val fg = if (dark) Color.White else Tok.ink
|
||||
val top = s.top.firstOrNull()
|
||||
BoxWithConstraints(Modifier.fillMaxSize().background(if (precip != null) precipBrush(precip, s.mode) else skyBrush(s.mode))) {
|
||||
val w = maxWidth
|
||||
if (night && precip == null) Canvas(Modifier.fillMaxSize()) {
|
||||
STARS.forEach { (x, y) -> drawCircle(Color.White, 1.4.dp.toPx(), Offset(size.width * x, size.height * y)) }
|
||||
}
|
||||
val cloudColor = when { precip == "rain" -> Color(0xFFDCE2EB); night -> Color(0xFFC9CDF0); else -> Color.White }
|
||||
SKY_CLOUDS.forEach { Cloud(cloudColor, it, w) }
|
||||
precip?.let { Precip(it, Modifier.fillMaxSize()) }
|
||||
Clock(now, fg)
|
||||
val day = now.atZone(KST).dayOfWeek.getDisplayName(DateTextStyle.FULL, Locale.KOREAN)
|
||||
T("$day · ${s.regionName.substringAfterLast(' ')}", 12.sp, color = fg, modifier = Modifier.fillMaxWidth().padding(top = 32.dp))
|
||||
if (!night) SunRays(Modifier.align(Alignment.Center).offset(y = (-6).dp).size(w * 0.62f))
|
||||
Orb(night, Modifier.align(Alignment.Center).offset(y = (-6).dp).size(w * 0.44f)) {
|
||||
T(top?.score?.toString() ?: "-", 38.sp, Tok.bagel, if (night) Color(0xFF2B2A5C) else Color.White)
|
||||
T(top?.name ?: "날씨각", 12.sp, color = if (night) Color(0xFF2B2A5C) else Color.White)
|
||||
}
|
||||
Row(Modifier.align(Alignment.BottomCenter).padding(bottom = w * 0.1f), horizontalArrangement = Arrangement.spacedBy(5.dp)) {
|
||||
Stat("thermo", s.tempC?.let { "${it.roundToInt()}°" } ?: "-°", dark)
|
||||
Stat("umbrella", s.rainLabel, dark)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 구슬 둘레의 끝이 둥근 햇살 12개. 1분에 한 바퀴 천천히 돈다 */
|
||||
@Composable
|
||||
private fun SunRays(modifier: Modifier) {
|
||||
val t = rememberInfiniteTransition(label = "rays")
|
||||
val turn by t.animateFloat(0f, 360f, infiniteRepeatable(tween(60_000, easing = LinearEasing)), label = "turn")
|
||||
Canvas(modifier.graphicsLayer { rotationZ = turn }) {
|
||||
val c = Offset(size.width / 2, size.height / 2)
|
||||
val r1 = size.width * 0.4f
|
||||
val r2 = size.width * 0.462f
|
||||
repeat(12) { i ->
|
||||
val a = Math.toRadians(i * 30.0)
|
||||
val dir = Offset(cos(a).toFloat(), sin(a).toFloat())
|
||||
drawLine(Color(0xFFFFB347), c + dir * r1, c + dir * r2, size.width * 0.044f, StrokeCap.Round)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 말랑 3D 해 구슬 (웹 .b-sun). 밤에는 달빛 보라 */
|
||||
@Composable
|
||||
private fun Orb(night: Boolean, modifier: Modifier, content: @Composable () -> Unit) {
|
||||
val stops = if (night) arrayOf(0f to Color.White, 0.35f to Color(0xFFE7E3FF), 0.72f to Color(0xFFB9B0F2), 1f to Color(0xFF8F86D9))
|
||||
else arrayOf(0f to Color(0xFFFFF5CF), 0.3f to Color(0xFFFFC86E), 0.68f to Color(0xFFFF8E4E), 1f to Color(0xFFEE6436))
|
||||
val glow = if (night) Color(0xFFBEB4FF) else Color(0xFFF06A3A)
|
||||
Box(
|
||||
modifier
|
||||
.shadow(18.dp, CircleShape, ambientColor = glow, spotColor = glow)
|
||||
.drawBehind {
|
||||
val c = Offset(size.width * 0.34f, size.height * 0.30f)
|
||||
drawCircle(Brush.radialGradient(*stops, center = c, radius = size.width * 0.96f))
|
||||
// 오른쪽 아래 그늘, 왼쪽 위 빛 (웹 inset 그림자 두 개)
|
||||
drawCircle(Brush.linearGradient(listOf(Color.Transparent, Color(if (night) 0x4D3C328C else 0x57AA3214)), Offset(size.width * 0.45f, size.height * 0.45f), Offset(size.width, size.height)))
|
||||
drawCircle(Brush.radialGradient(listOf(Color.White.copy(alpha = 0.45f), Color.Transparent), Offset(size.width * 0.28f, size.height * 0.25f), size.width * 0.35f))
|
||||
// 해에만 볼터치
|
||||
if (!night) listOf(0.18f, 0.82f).forEach { x ->
|
||||
drawOval(Color(0x73FF7A8A), Offset(size.width * x - size.width * 0.07f, size.height * 0.68f), Size(size.width * 0.14f, size.width * 0.08f))
|
||||
}
|
||||
},
|
||||
contentAlignment = Alignment.Center,
|
||||
) { Column(horizontalAlignment = Alignment.CenterHorizontally) { content() } }
|
||||
}
|
||||
|
||||
/** 구름 한 줄: 세로 위치·너비·높이(화면 비율), 한 번 가로지르는 초, 시작 위상 */
|
||||
private class SkyCloud(val y: Float, val w: Float, val h: Float, val sec: Int, val phase: Float)
|
||||
|
||||
// 위상을 엇갈려, 한쪽으로 빠질 때 다른 줄에서 새 구름이 들어온다
|
||||
private val SKY_CLOUDS = listOf(
|
||||
SkyCloud(0.30f, 0.19f, 0.07f, 9, 0f), SkyCloud(0.30f, 0.14f, 0.05f, 9, 0.5f),
|
||||
SkyCloud(0.56f, 0.13f, 0.05f, 6, 0.8f), SkyCloud(0.74f, 0.22f, 0.075f, 7, 0.45f),
|
||||
)
|
||||
|
||||
/** 왼쪽 밖에서 들어와 오른쪽 밖으로 빠지고 다시 왼쪽에서 (끝없이 흐르는 하늘) */
|
||||
@Composable
|
||||
private fun Cloud(c: Color, cl: SkyCloud, screen: Dp) {
|
||||
val t = rememberInfiniteTransition(label = "cloud")
|
||||
val p by t.animateFloat(0f, 1f, infiniteRepeatable(tween(cl.sec * 1000, easing = LinearEasing)), label = "drift")
|
||||
val w = screen * cl.w
|
||||
Canvas(Modifier.offset(y = screen * cl.y).size(w, screen * cl.h).graphicsLayer { translationX = ((p + cl.phase) % 1f) * (screen + w).toPx() - w.toPx() }) {
|
||||
drawCircle(c, size.height * 0.95f, Offset(size.width * 0.38f, size.height * 0.1f))
|
||||
drawRoundRect(c, cornerRadius = CornerRadius(size.height / 2))
|
||||
drawRoundRect(Color(0x33A0BEE6), Offset(0f, size.height * 0.55f), Size(size.width, size.height * 0.45f), CornerRadius(size.height / 2))
|
||||
}
|
||||
}
|
||||
|
||||
// 빗줄기·눈송이 하나: 가로 위치, 시작 위상, 한 번 떨어지는 데 걸리는 초, 크기 (모두 고정값이라 매번 같은 자리)
|
||||
private class Drop(val x: Float, val phase: Float, val sec: Float, val size: Float)
|
||||
|
||||
private val DROPS = java.util.Random(7).let { r -> List(42) { Drop(r.nextFloat(), r.nextFloat(), 0.7f + r.nextFloat() * 0.5f, 0.6f + r.nextFloat() * 0.4f) } }
|
||||
|
||||
/** 비는 추적추적 비스듬히, 눈은 천천히 흔들리며. 화면이 켜져 있는 동안만 그린다 */
|
||||
@Composable
|
||||
private fun Precip(kind: String, modifier: Modifier) {
|
||||
var time by remember { mutableFloatStateOf(0f) }
|
||||
LaunchedEffect(Unit) {
|
||||
val start = withFrameNanos { it }
|
||||
while (true) withFrameNanos { time = (it - start) / 1e9f }
|
||||
}
|
||||
val snow = kind == "snow"
|
||||
Canvas(modifier) {
|
||||
val h = size.height
|
||||
DROPS.forEachIndexed { i, d ->
|
||||
val period = if (snow) d.sec * 7f else d.sec
|
||||
val p = (time / period + d.phase) % 1f
|
||||
val y = p * (h + 40.dp.toPx()) - 20.dp.toPx()
|
||||
if (snow) {
|
||||
val x = d.x * size.width + sin((time / 2f + d.phase) * 2f * Math.PI.toFloat()) * 6.dp.toPx()
|
||||
drawCircle(Color.White.copy(alpha = 0.9f), (1.5f + 2f * d.size).dp.toPx(), Offset(x, y))
|
||||
} else {
|
||||
val len = 14.dp.toPx() * d.size
|
||||
val x = d.x * size.width + y * 0.12f
|
||||
drawLine(Color(0xCCEAF2FF), Offset(x, y), Offset(x - len * 0.12f, y - len), 1.5.dp.toPx(), StrokeCap.Round)
|
||||
// 셋 중 하나는 바닥에서 톡 튄다
|
||||
if (i % 3 == 0 && p > 0.86f) {
|
||||
val k = (p - 0.86f) / 0.14f
|
||||
drawCircle(Color(0x99EAF2FF), (2f + 6f * k).dp.toPx(), Offset(x, h * (0.8f + 0.12f * d.x)), style = Stroke(1.dp.toPx()), alpha = 1f - k)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Stat(icon: String, text: String, dark: Boolean) {
|
||||
Row(
|
||||
Modifier.mallang(if (dark) Tok.statDark else Tok.stat, if (dark) Color.White.copy(alpha = 0.12f) else Tok.shade.copy(alpha = 0.9f), 14.dp)
|
||||
.padding(start = 5.dp, end = 9.dp, top = 3.dp, bottom = 6.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(3.dp),
|
||||
) {
|
||||
Ic(icon, 16.dp)
|
||||
T(text, 12.sp, color = if (dark) Color.White else Tok.ink)
|
||||
}
|
||||
}
|
||||
|
||||
// ───────────── 워치 스킨에서 누른 각 ─────────────
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -18,7 +18,6 @@ object Tok {
|
||||
val navyTop = Color(0xFF2B3577)
|
||||
val card = Color.White.copy(alpha = 0.78f)
|
||||
val stat = Color.White.copy(alpha = 0.72f)
|
||||
val statDark = Color.White.copy(alpha = 0.18f)
|
||||
|
||||
val jua = FontFamily(Font(R.font.jua))
|
||||
val bagel = FontFamily(Font(R.font.bagel_fat_one))
|
||||
@@ -34,16 +33,6 @@ fun skyBrush(mode: String): Brush = when (mode) {
|
||||
else -> v(0f to 0xFF9FD3FF, 0.55f to 0xFFCFE9FF, 1f to 0xFFF1F8FF)
|
||||
}
|
||||
|
||||
/** 비·눈 오는 날 하늘. 밤에는 어두운 회청색 */
|
||||
fun precipBrush(kind: String, mode: String): Brush = when {
|
||||
mode == "night" -> v(0f to 0xFF1C2238, 0.6f to 0xFF2E3650, 1f to 0xFF434B66)
|
||||
kind == "snow" -> v(0f to 0xFFB8C4D6, 0.55f to 0xFFDFE6F0, 1f to 0xFFF4F7FB)
|
||||
else -> v(0f to 0xFF7F93AD, 0.55f to 0xFFA9B7C9, 1f to 0xFFD5DDE8)
|
||||
}
|
||||
|
||||
/** 하늘 위 글자가 흰색이어야 하는 시간대 */
|
||||
fun isDark(mode: String) = mode == "evening" || mode == "night"
|
||||
|
||||
// 카드·장 배경 (.b-bg-*)
|
||||
val bgButter = v(0f to 0xFFFFE7A0, 1f to 0xFFFFF6D8)
|
||||
val bgMint = v(0f to 0xFFBFECD6, 1f to 0xFFEFFAF4)
|
||||
|
||||
Reference in new issue
Block a user