Modern Apps git

← Modern-Apps.git

games-hub: dev-gated Yuu avatar creator with Mii-style editor

Commit
5395dccc1db6114c973cbfe4ebd0d7a79dee4682
Author
vayun-mathur <[email protected]>
When
2026-10-19 18:22 UTC (1 month ago)
Parents
3bbb68f

Diff

games/hub/src/main/java/com/vayunmathur/games/hub/MainActivity.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/MainActivity.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/MainActivity.ktindex 6d74d04628..3ef9b2b9ff 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/MainActivity.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/MainActivity.kt@@ -8,12 +8,14 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vayunmathur.games.hub.ui.components.AvatarIcon import com.vayunmathur.library.ui.IconDashboard+import com.vayunmathur.library.ui.IconEmoji import com.vayunmathur.library.ui.IconEmojiEvents import com.vayunmathur.library.ui.IconSportsEsports import com.vayunmathur.library.ui.PagerTab import com.vayunmathur.library.ui.TabStyle import com.vayunmathur.library.ui.TabbedPagerScaffold import com.vayunmathur.games.hub.data.GamesHubRepository+import com.vayunmathur.games.hub.BuildConfig import com.vayunmathur.games.hub.ui.screens.AchievementsScreen import com.vayunmathur.games.hub.ui.screens.ActivityFeedScreen import com.vayunmathur.games.hub.ui.screens.DashboardPage@@ -22,6 +24,8 @@ import com.vayunmathur.games.hub.ui.screens.GamesListPage import com.vayunmathur.games.hub.ui.screens.PlayOnTvScreen import com.vayunmathur.games.hub.ui.screens.ProfilePage import com.vayunmathur.games.hub.ui.screens.SettingsScreen+import com.vayunmathur.games.hub.ui.screens.YuuEditorPage+import com.vayunmathur.games.hub.ui.screens.YuuPage import com.vayunmathur.games.hub.viewmodel.GameHubViewModel import com.vayunmathur.games.hub.viewmodel.GameHubViewModelFactory import com.vayunmathur.library.ui.MaActivity@@ -56,6 +60,8 @@ sealed interface MainRoute : NavKey {     @Serializable data object Settings : MainRoute     /** The phone-as-controller screen (hub hosts the SDK ControllerPad). */     @Serializable data object PlayOnTv : MainRoute+    @Serializable data object YuuEditorNew : MainRoute+    @Serializable data class YuuEditorEdit(val yuuId: Long) : MainRoute }  @Composable@@ -94,6 +100,20 @@ fun HubNavigation(         entry<MainRoute.PlayOnTv> {             PlayOnTvScreen(backStack = backStack)         }+        entry<MainRoute.YuuEditorNew> {+            YuuEditorPage(+                viewModel = viewModel,+                editingId = null,+                onDismiss = { backStack.pop() },+            )+        }+        entry<MainRoute.YuuEditorEdit> { route ->+            YuuEditorPage(+                viewModel = viewModel,+                editingId = route.yuuId,+                onDismiss = { backStack.pop() },+            )+        }     } } @@ -102,7 +122,7 @@ private fun HubTabs(     viewModel: GameHubViewModel,     backStack: NavBackStack<MainRoute>, ) {-    val pagerState = rememberPagerState(pageCount = { 4 })+    val pagerState = rememberPagerState(pageCount = { if (BuildConfig.DEV_BUILD) 5 else 4 })     val scope = rememberCoroutineScope()     val profile by viewModel.profileFlow.collectAsStateWithLifecycle()     // Home and Games are adjacent pages showing the same games (recentlyPlayed is a subset of the@@ -134,6 +154,17 @@ private fun HubTabs(         PagerTab("Profile", { AvatarIcon(symbol = profile?.avatarSymbol) }) {             ProfilePage(viewModel = viewModel)         },-    )+        // Dev-only: the Yuu avatar plaza is still experimental. R8 strips the+        // block from release builds via the repo-wide BuildConfig.DEV_BUILD flag.+        if (BuildConfig.DEV_BUILD) {+            PagerTab("Yuu", { IconEmoji() }) {+                YuuPage(+                    viewModel = viewModel,+                    onCreateYuu = { backStack.add(MainRoute.YuuEditorNew) },+                    onEditYuu = { id -> backStack.add(MainRoute.YuuEditorEdit(id)) },+                )+            }+        } else null,+    ).filterNotNull()     TabbedPagerScaffold(tabs = tabs, pagerState = pagerState, tabStyle = TabStyle.BottomNav) }
games/hub/src/main/java/com/vayunmathur/games/hub/data/GamesHubDatabase.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/data/GamesHubDatabase.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/data/GamesHubDatabase.ktindex 16779f8730..4259d5d6b0 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/data/GamesHubDatabase.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/data/GamesHubDatabase.kt@@ -10,6 +10,7 @@ import com.vayunmathur.games.hub.data.dao.GameDao import com.vayunmathur.games.hub.data.dao.ProfileDao import com.vayunmathur.games.hub.data.dao.SessionDao import com.vayunmathur.games.hub.data.dao.StreakDao+import com.vayunmathur.games.hub.data.dao.YuuDao import com.vayunmathur.games.hub.data.entities.AchievementDefEntity import com.vayunmathur.games.hub.data.entities.AchievementProgressEntity import com.vayunmathur.games.hub.data.entities.ActivityEventEntity@@ -17,6 +18,7 @@ import com.vayunmathur.games.hub.data.entities.DailyStreakEntity import com.vayunmathur.games.hub.data.entities.HubGameEntity import com.vayunmathur.games.hub.data.entities.PlaySessionEntity import com.vayunmathur.games.hub.data.entities.PlayerProfileEntity+import com.vayunmathur.games.hub.data.entities.YuuEntity import com.vayunmathur.library.util.DatabaseMigrations  const val DB_NAME = "games-hub-db"@@ -29,9 +31,10 @@ const val DB_NAME = "games-hub-db"         PlaySessionEntity::class,         PlayerProfileEntity::class,         ActivityEventEntity::class,-        DailyStreakEntity::class+        DailyStreakEntity::class,+        YuuEntity::class     ],-    version = 2,+    version = 3,     exportSchema = false ) abstract class GamesHubDatabase : RoomDatabase() {@@ -41,6 +44,7 @@ abstract class GamesHubDatabase : RoomDatabase() {     abstract fun profileDao(): ProfileDao     abstract fun activityDao(): ActivityDao     abstract fun streakDao(): StreakDao+    abstract fun yuuDao(): YuuDao      companion object : DatabaseMigrations {         override val migrations: List<Migration> = listOf(@@ -57,6 +61,18 @@ abstract class GamesHubDatabase : RoomDatabase() {                         "PRIMARY KEY(`gameId`))",                 )             },+            // Yuu avatar plaza. DDL byte-matches Room's generated schema for YuuEntity+            // (autoGenerate id, TEXT name/configJson, INTEGER updatedAt/isProfile).+            Migration(2, 3) { db ->+                db.execSQL(+                    "CREATE TABLE IF NOT EXISTS `yuus` (" ++                        "`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " ++                        "`name` TEXT NOT NULL, " ++                        "`configJson` TEXT NOT NULL, " ++                        "`updatedAt` INTEGER NOT NULL, " ++                        "`isProfile` INTEGER NOT NULL)",+                )+            },         )     } }
games/hub/src/main/java/com/vayunmathur/games/hub/data/GamesHubRepository.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/data/GamesHubRepository.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/data/GamesHubRepository.ktindex 13ee70f153..68055b42a0 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/data/GamesHubRepository.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/data/GamesHubRepository.kt@@ -7,7 +7,7 @@ import com.vayunmathur.library.room.RoomRepository  * Single owner of [GamesHubDatabase].  *  * Per-domain reads and writes live on the store classes ([GameStore], [AchievementStore],- * [SessionStore], [StreakStore], [ProfileStore], [ActivityStore]); this class keeps the+ * [SessionStore], [StreakStore], [ProfileStore], [ActivityStore], [YuuStore]); this class keeps the  * singleton and the database handle.  */ class GamesHubRepository private constructor(context: Context) :@@ -19,6 +19,7 @@ class GamesHubRepository private constructor(context: Context) :     internal fun profileDaoAccess() = db.profileDao()     internal fun activityDaoAccess() = db.activityDao()     internal fun streakDaoAccess() = db.streakDao()+    internal fun yuuDaoAccess() = db.yuuDao()      val games: GameStore = GameStore(this)     val achievements: AchievementStore = AchievementStore(this)@@ -26,6 +27,7 @@ class GamesHubRepository private constructor(context: Context) :     val streaks: StreakStore = StreakStore(this)     val profile: ProfileStore = ProfileStore(this)     val activity: ActivityStore = ActivityStore(this)+    val yuus: YuuStore = YuuStore(this)      val database: GamesHubDatabase get() = db 
games/hub/src/main/java/com/vayunmathur/games/hub/data/HubStores.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/data/HubStores.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/data/HubStores.ktindex 328a7eccee..08e2a5007f 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/data/HubStores.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/data/HubStores.kt@@ -4,7 +4,12 @@ import com.vayunmathur.games.hub.data.entities.ActivityEventEntity import com.vayunmathur.games.hub.data.entities.DailyStreakEntity import com.vayunmathur.games.hub.data.entities.PlaySessionEntity import com.vayunmathur.games.hub.data.entities.PlayerProfileEntity+import com.vayunmathur.games.hub.data.entities.YuuEntity+import com.vayunmathur.games.hub.data.entities.YuuFaceConfig+import com.vayunmathur.games.hub.data.entities.decodeYuuConfig+import com.vayunmathur.games.hub.data.entities.encode import kotlinx.coroutines.flow.Flow+import kotlinx.coroutines.flow.map  /** Play sessions. Backed by SessionDao. */ class SessionStore internal constructor(private val repository: GamesHubRepository) {@@ -54,3 +59,73 @@ class ActivityStore internal constructor(private val repository: GamesHubReposit         activityDao.flowByGame(gameId, limit)     suspend fun clearActivities() = activityDao.clearAll() }++/** A Yuu with its face config decoded, ready for the Canvas renderer. */+data class YuuUiModel(+    val id: Long,+    val name: String,+    val config: YuuFaceConfig,+    val isProfile: Boolean,+    val updatedAt: Long,+)++private fun YuuEntity.toUiModel() = YuuUiModel(+    id = id,+    name = name,+    config = configJson.decodeYuuConfig(),+    isProfile = isProfile,+    updatedAt = updatedAt,+)++/** Yuu avatar plaza. Backed by YuuDao; config JSON encodes/decodes at this boundary. */+class YuuStore internal constructor(private val repository: GamesHubRepository) {+    private val yuuDao get() = repository.yuuDaoAccess()++    fun yuusFlow(): Flow<List<YuuUiModel>> =+        yuuDao.flowAll().map { list -> list.map { it.toUiModel() } }++    fun profileYuuFlow(): Flow<YuuUiModel?> =+        yuuDao.flowProfile().map { it?.toUiModel() }++    suspend fun getYuu(id: Long): YuuUiModel? = yuuDao.getById(id)?.toUiModel()++    suspend fun createYuu(name: String, config: YuuFaceConfig): Long =+        yuuDao.upsert(+            YuuEntity(+                name = name,+                configJson = config.encode(),+                updatedAt = System.currentTimeMillis(),+            )+        )++    suspend fun updateYuu(id: Long, name: String, config: YuuFaceConfig) {+        val current = yuuDao.getById(id) ?: return+        yuuDao.upsert(+            current.copy(+                name = name,+                configJson = config.encode(),+                updatedAt = System.currentTimeMillis(),+            )+        )+    }++    suspend fun duplicateYuu(id: Long): Long? {+        val current = yuuDao.getById(id) ?: return null+        return yuuDao.upsert(+            current.copy(+                id = 0L,+                name = "${current.name} copy",+                updatedAt = System.currentTimeMillis(),+                isProfile = false,+            )+        )+    }++    suspend fun deleteYuu(id: Long) = yuuDao.deleteById(id)++    suspend fun setProfileYuu(id: Long) = yuuDao.setProfile(id)++    suspend fun clearProfileYuu() = yuuDao.clearProfileFlag()++    suspend fun clearYuus() = yuuDao.clearAll()+}
games/hub/src/main/java/com/vayunmathur/games/hub/data/dao/YuuDao.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/data/dao/YuuDao.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/data/dao/YuuDao.ktnew file mode 100644index 0000000000..64e9b0c487--- /dev/null+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/data/dao/YuuDao.kt@@ -0,0 +1,43 @@+package com.vayunmathur.games.hub.data.dao++import androidx.room3.Dao+import androidx.room3.Query+import androidx.room3.Transaction+import androidx.room3.Upsert+import com.vayunmathur.games.hub.data.entities.YuuEntity+import kotlinx.coroutines.flow.Flow++@Dao+interface YuuDao {++    @Upsert+    suspend fun upsert(yuu: YuuEntity): Long++    @Query("SELECT * FROM yuus WHERE id = :id LIMIT 1")+    suspend fun getById(id: Long): YuuEntity?++    @Query("SELECT * FROM yuus ORDER BY updatedAt DESC")+    fun flowAll(): Flow<List<YuuEntity>>++    @Query("SELECT * FROM yuus WHERE isProfile = 1 LIMIT 1")+    fun flowProfile(): Flow<YuuEntity?>++    @Query("DELETE FROM yuus WHERE id = :id")+    suspend fun deleteById(id: Long)++    @Query("UPDATE yuus SET isProfile = 0")+    suspend fun clearProfileFlag()++    @Query("UPDATE yuus SET isProfile = 1 WHERE id = :id")+    suspend fun markProfile(id: Long)++    /** At most one row holds `isProfile`; clear-then-set runs atomically. */+    @Transaction+    suspend fun setProfile(id: Long) {+        clearProfileFlag()+        markProfile(id)+    }++    @Query("DELETE FROM yuus")+    suspend fun clearAll()+}
games/hub/src/main/java/com/vayunmathur/games/hub/data/entities/YuuEntity.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/data/entities/YuuEntity.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/data/entities/YuuEntity.ktnew file mode 100644index 0000000000..bf12de1867--- /dev/null+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/data/entities/YuuEntity.kt@@ -0,0 +1,20 @@+package com.vayunmathur.games.hub.data.entities++import androidx.room3.Entity+import androidx.room3.PrimaryKey++/**+ * One named Yuu avatar in the plaza collection.+ *+ * The face itself is a [YuuFaceConfig] serialized to [configJson] (see YuuJson); the+ * table stays flat so there is no per-part table. [isProfile] marks the Yuu currently+ * linked as the hub profile avatar — at most one row holds true.+ */+@Entity(tableName = "yuus")+data class YuuEntity(+    @PrimaryKey(autoGenerate = true) val id: Long = 0L,+    val name: String = "",+    val configJson: String = "",+    val updatedAt: Long = System.currentTimeMillis(),+    val isProfile: Boolean = false,+)
games/hub/src/main/java/com/vayunmathur/games/hub/data/entities/YuuFaceConfig.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/data/entities/YuuFaceConfig.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/data/entities/YuuFaceConfig.ktnew file mode 100644index 0000000000..6abca95b10--- /dev/null+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/data/entities/YuuFaceConfig.kt@@ -0,0 +1,103 @@+package com.vayunmathur.games.hub.data.entities++import kotlinx.serialization.Serializable++/**+ * Portable face description for a Yuu avatar, stored as JSON in [YuuEntity.configJson].+ *+ * Indices are positional (0..count-1 per part) so the renderer owns the variant lookup;+ * colors are ARGB longs into the fixed palettes below; tweaks are normalized 0..1 floats.+ * Only this config is persisted, keeping it portable to the future 3D games.+ */+@Serializable+data class YuuFaceConfig(+    val faceShape: Int = 0,+    val skinTone: Long = YUU_SKIN_TONES[3],+    val earSize: Float = 0.5f,+    val bodyHeight: Float = 0.5f,+    val bodyWeight: Float = 0.5f,+    val hairStyle: Int = 0,+    val hairColor: Long = YUU_HAIR_COLORS[0],+    val eyeStyle: Int = 0,+    val eyeColor: Long = YUU_EYE_COLORS[0],+    val eyeSize: Float = 0.5f,+    val eyeSpacing: Float = 0.5f,+    val eyeHeight: Float = 0.5f,+    val eyeRotation: Float = 0.5f,+    val browStyle: Int = 0,+    val browColor: Long = YUU_HAIR_COLORS[0],+    val browHeight: Float = 0.5f,+    val browRotation: Float = 0.5f,+    val noseStyle: Int = 0,+    val noseHeight: Float = 0.5f,+    val mouthStyle: Int = 0,+    val mouthColor: Long = YUU_MOUTH_COLORS[0],+    val mouthSize: Float = 0.5f,+    val mouthHeight: Float = 0.5f,+    val glassesStyle: Int = 0,+    val beardStyle: Int = 0,+    val moleStyle: Int = 0,+    val wrinkleStyle: Int = 0,+    val blushStyle: Int = 0,+) {+    companion object {+        /** Variant counts the Canvas renderer supports for v1 (Mii-like breadth). */+        const val FACE_SHAPES = 8+        const val HAIR_STYLES = 12+        const val EYE_STYLES = 12+        const val BROW_STYLES = 8+        const val NOSE_STYLES = 8+        const val MOUTH_STYLES = 12+        const val GLASSES_STYLES = 6+        const val BEARD_STYLES = 5+        const val MOLE_STYLES = 4+        const val WRINKLE_STYLES = 4+        const val BLUSH_STYLES = 3++        /** 0 means "none" for the optional extras; face parts start at real variants. */+        const val NONE = 0++        val DEFAULT = YuuFaceConfig()+    }+}++/** Fixed Mii-like skin tones (ARGB). No in-app color picker in v1. */+val YUU_SKIN_TONES = listOf(+    0xFFFFE3D3L,+    0xFFFFD7B8L,+    0xFFF5C99BL,+    0xFFE8B48AL,+    0xFFD69E73L,+    0xFFB07B4FL,+    0xFF7D5233L,+    0xFF4E2F1DL,+)++/** Fixed hair / brow colors (ARGB). */+val YUU_HAIR_COLORS = listOf(+    0xFF2B2B2BL,+    0xFF5A3A22L,+    0xFF8A5A2BL,+    0xFFD9A441L,+    0xFFB34A2BL,+    0xFF7A7A7AL,+    0xFFE8E8E8L,+    0xFF4A6FA5L,+)++/** Fixed eye colors (ARGB). */+val YUU_EYE_COLORS = listOf(+    0xFF2B2B2BL,+    0xFF5A3A22L,+    0xFF4A6FA5L,+    0xFF3E8E5AL,+    0xFF7A7A7AL,+)++/** Fixed mouth / blush colors (ARGB). */+val YUU_MOUTH_COLORS = listOf(+    0xFFB34A4AL,+    0xFFD97B7BL,+    0xFF8E3B3BL,+    0xFF5A2B2BL,+)
games/hub/src/main/java/com/vayunmathur/games/hub/data/entities/YuuJson.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/data/entities/YuuJson.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/data/entities/YuuJson.ktnew file mode 100644index 0000000000..6fd3133048--- /dev/null+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/data/entities/YuuJson.kt@@ -0,0 +1,25 @@+package com.vayunmathur.games.hub.data.entities++import kotlinx.serialization.SerializationException+import kotlinx.serialization.encodeToString+import kotlinx.serialization.json.Json++/**+ * JSON encode/decode for [YuuFaceConfig] at the store boundary (notes-app `NoteBlock`+ * precedent). `ignoreUnknownKeys` lets older configs parse after part additions, and+ * any unparseable blob falls back to [YuuFaceConfig.DEFAULT] so a stale row can never+ * break the plaza grid.+ */+private val yuuJson = Json { ignoreUnknownKeys = true }++fun YuuFaceConfig.encode(): String = yuuJson.encodeToString(this)++fun String.decodeYuuConfig(): YuuFaceConfig =+    if (isBlank()) YuuFaceConfig.DEFAULT+    else try {+        yuuJson.decodeFromString<YuuFaceConfig>(this)+    } catch (_: SerializationException) {+        YuuFaceConfig.DEFAULT+    } catch (_: IllegalArgumentException) {+        YuuFaceConfig.DEFAULT+    }
games/hub/src/main/java/com/vayunmathur/games/hub/ui/components/YuuBadge.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/components/YuuBadge.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/components/YuuBadge.ktnew file mode 100644index 0000000000..0ace363861--- /dev/null+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/components/YuuBadge.kt@@ -0,0 +1,35 @@+package com.vayunmathur.games.hub.ui.components++import androidx.compose.foundation.background+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.shape.CircleShape+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.unit.dp+import com.vayunmathur.games.hub.data.entities.YuuFaceConfig+import com.vayunmathur.library.ui.MaterialTheme++/**+ * Circular Yuu miniature for profile headers and the plaza grid. Same sizing and+ * surface as [AvatarBadge] so the two are interchangeable in header rows.+ */+@Composable+fun YuuBadge(config: YuuFaceConfig, modifier: Modifier = Modifier, large: Boolean = false) {+    val size = if (large) 56.dp else 36.dp+    Box(+        modifier = modifier+            .size(size)+            .clip(CircleShape)+            .background(MaterialTheme.colorScheme.primaryContainer),+        contentAlignment = Alignment.Center+    ) {+        YuuFace(+            config = config,+            modifier = Modifier.size(size - 8.dp).padding(2.dp),+        )+    }+}
games/hub/src/main/java/com/vayunmathur/games/hub/ui/components/YuuFace.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/components/YuuFace.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/components/YuuFace.ktnew file mode 100644index 0000000000..fc06791414--- /dev/null+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/components/YuuFace.kt@@ -0,0 +1,495 @@+package com.vayunmathur.games.hub.ui.components++import androidx.compose.foundation.Canvas+import androidx.compose.runtime.Composable+import androidx.compose.runtime.remember+import androidx.compose.ui.Modifier+import androidx.compose.ui.geometry.CornerRadius+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.geometry.Size+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.Path+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.graphics.drawscope.Stroke+import com.vayunmathur.games.hub.data.entities.YuuFaceConfig++/**+ * Deterministic vector renderer for a [YuuFaceConfig]: every part is drawn from the+ * config with size-relative math, so the same config renders identically at any size.+ * Pure — no ViewModel, no resources — so previews and the plaza grid can use it freely.+ *+ * Paint order: body -> ears -> face shape -> hair back -> eyes -> brows -> nose ->+ * mouth -> blush/wrinkles/mole -> glasses -> facial hair -> hair front.+ *+ * When [withBody] is true (editor preview), a simple Mii-like torso is drawn under+ * the head whose height/width follow bodyHeight/bodyWeight. Plaza badges and profile+ * headers keep the head-only form.+ */+@Composable+fun YuuFace(+    config: YuuFaceConfig,+    modifier: Modifier = Modifier,+    withBody: Boolean = false,+) {+    val spec = remember(config, withBody) { YuuDrawSpec(config, withBody) }+    Canvas(modifier = modifier) {+        spec.draw(this)+    }+}++private fun Long.toColor(): Color = Color(this)++/** Precomputed, denormalized draw parameters for one config. */+private class YuuDrawSpec(config: YuuFaceConfig, val withBody: Boolean = false) {+    val faceShape = config.faceShape.mod(YuuFaceConfig.FACE_SHAPES)+    val skin = config.skinTone.toColor()+    val skinShade = config.skinTone.toColor().copy(alpha = 1f).darken(0.12f)+    val earR = 0.06f + config.earSize * 0.07f+    val bodyH = 0.28f + config.bodyHeight * 0.30f+    val bodyW = 0.30f + config.bodyWeight * 0.35f+    val hairStyle = config.hairStyle.mod(YuuFaceConfig.HAIR_STYLES)+    val hair = config.hairColor.toColor()+    val eyeStyle = config.eyeStyle.mod(YuuFaceConfig.EYE_STYLES)+    val eyeColor = config.eyeColor.toColor()+    val eyeR = 0.045f + config.eyeSize * 0.05f+    val eyeDx = 0.10f + config.eyeSpacing * 0.12f+    val eyeDy = -0.02f + config.eyeHeight * 0.10f - 0.05f+    val eyeTilt = (config.eyeRotation - 0.5f) * 0.6f+    val browStyle = config.browStyle.mod(YuuFaceConfig.BROW_STYLES)+    val browColor = config.browColor.toColor()+    val browDy = -0.16f - config.browHeight * 0.08f+    val browTilt = (config.browRotation - 0.5f) * 0.9f+    val noseStyle = config.noseStyle.mod(YuuFaceConfig.NOSE_STYLES)+    val noseDy = (config.noseHeight - 0.5f) * 0.12f+    val mouthStyle = config.mouthStyle.mod(YuuFaceConfig.MOUTH_STYLES)+    val mouthColor = config.mouthColor.toColor()+    val mouthW = 0.10f + config.mouthSize * 0.14f+    val mouthDy = (config.mouthHeight - 0.5f) * 0.12f+    val glasses = config.glassesStyle.mod(YuuFaceConfig.GLASSES_STYLES + 1)+    val beard = config.beardStyle.mod(YuuFaceConfig.BEARD_STYLES + 1)+    val mole = config.moleStyle.mod(YuuFaceConfig.MOLE_STYLES + 1)+    val wrinkles = config.wrinkleStyle.mod(YuuFaceConfig.WRINKLE_STYLES + 1)+    val blush = config.blushStyle.mod(YuuFaceConfig.BLUSH_STYLES + 1)++    fun draw(scope: DrawScope) = with(scope) {+        // With a body the head sits higher so the torso fits below.+        val s = if (withBody) size.minDimension * 0.72f else size.minDimension+        val c = if (withBody) center + Offset(0f, -size.minDimension * 0.14f) else center+        if (withBody) drawBody(c, size.minDimension)+        drawEars(c, s)+        drawFaceShape(c, s)+        drawHairBack(c, s)+        drawEyes(c, s)+        drawBrows(c, s)+        drawNose(c, s)+        drawMouth(c, s)+        drawSkinDetails(c, s)+        drawGlasses(c, s)+        drawBeard(c, s)+        drawHairFront(c, s)+    }++    private fun DrawScope.drawBody(headC: Offset, full: Float) {+        val neckW = bodyW * full * 0.28f+        val neckTop = headC.y + faceHalfHeight() * full * 0.72f - full * 0.02f+        // Neck.+        drawOval(+            skin,+            topLeft = Offset(headC.x - neckW / 2, neckTop - full * 0.06f),+            size = Size(neckW, full * 0.12f),+        )+        // Torso: rounded shoulders widening with weight, lengthening with height.+        val torsoTop = neckTop + full * 0.04f+        val torsoH = bodyH * full+        val torsoW = bodyW * full+        val p = Path().apply {+            moveTo(headC.x - torsoW * 0.45f, torsoTop + torsoH * 0.18f)+            quadraticTo(headC.x - torsoW * 0.55f, torsoTop, headC.x - torsoW * 0.30f, torsoTop)+            lineTo(headC.x + torsoW * 0.30f, torsoTop)+            quadraticTo(headC.x + torsoW * 0.55f, torsoTop, headC.x + torsoW * 0.45f, torsoTop + torsoH * 0.18f)+            lineTo(headC.x + torsoW * 0.50f, torsoTop + torsoH)+            lineTo(headC.x - torsoW * 0.50f, torsoTop + torsoH)+            close()+        }+        drawPath(p, skinShade)+    }++    private fun DrawScope.drawEars(c: Offset, s: Float) {+        val faceW = faceHalfWidth() * s+        val ey = c.y - s * 0.02f+        drawCircle(skin, radius = earR * s, center = Offset(c.x - faceW, ey))+        drawCircle(skin, radius = earR * s, center = Offset(c.x + faceW, ey))+    }++    private fun faceHalfWidth(): Float = when (faceShape) {+        1 -> 0.30f+        2 -> 0.27f+        3 -> 0.32f+        4 -> 0.26f+        5 -> 0.34f+        6 -> 0.29f+        7 -> 0.31f+        else -> 0.30f+    }++    private fun faceHalfHeight(): Float = when (faceShape) {+        1 -> 0.36f+        2 -> 0.40f+        3 -> 0.34f+        4 -> 0.42f+        5 -> 0.35f+        6 -> 0.38f+        7 -> 0.33f+        else -> 0.37f+    }++    private fun DrawScope.drawFaceShape(c: Offset, s: Float) {+        val w = faceHalfWidth() * s+        val h = faceHalfHeight() * s+        val cy = c.y - s * 0.02f+        when (faceShape) {+            // 1: square jaw — rounded rect.+            1 -> drawRoundRectPath(c, w, h, 0.18f * s)+            // 2: heart — wider top via two overlapping ovals.+            2 -> {+                drawOvalPath(c + Offset(0f, -h * 0.18f), w, h * 0.85f)+                drawOvalPath(c + Offset(0f, h * 0.28f), w * 0.72f, h * 0.62f)+            }+            // 4: long oval.+            4 -> drawOvalPath(c.copy(y = cy), w * 0.92f, h)+            // 6: round cheeks — main oval plus cheek circles.+            6 -> {+                drawOvalPath(c.copy(y = cy), w, h)+                drawCircle(skin, w * 0.42f, c + Offset(-w * 0.62f, h * 0.35f))+                drawCircle(skin, w * 0.42f, c + Offset(w * 0.62f, h * 0.35f))+            }+            // 7: wide — flattened oval.+            7 -> drawOvalPath(c.copy(y = cy), w, h * 0.88f)+            // 0, 3, 5: ovals with varying width (covered by faceHalfWidth).+            else -> drawOvalPath(c.copy(y = cy), w, h)+        }+    }++    private fun DrawScope.drawOvalPath(c: Offset, hw: Float, hh: Float) {+        drawOval(skin, topLeft = Offset(c.x - hw, c.y - hh), size = Size(hw * 2, hh * 2))+    }++    private fun DrawScope.drawRoundRectPath(c: Offset, hw: Float, hh: Float, r: Float) {+        drawRoundRect(+            skin,+            topLeft = Offset(c.x - hw, c.y - hh),+            size = Size(hw * 2, hh * 2),+            cornerRadius = CornerRadius(r, r),+        )+    }++    private fun DrawScope.drawHairBack(c: Offset, s: Float) {+        if (hairStyle == 0) return+        val w = faceHalfWidth() * s+        val topY = c.y - faceHalfHeight() * s - s * 0.02f+        when (hairStyle % 4) {+            // Long back hair: side panels behind the face.+            1 -> {+                drawOval(hair, Offset(c.x - w * 0.95f, topY + s * 0.30f), Size(w * 0.45f, s * 0.55f))+                drawOval(hair, Offset(c.x + w * 0.50f, topY + s * 0.30f), Size(w * 0.45f, s * 0.55f))+            }+            // Tied / bun sides.+            2 -> {+                drawCircle(hair, s * 0.09f, Offset(c.x - w - s * 0.05f, topY + s * 0.10f))+                drawCircle(hair, s * 0.09f, Offset(c.x + w + s * 0.05f, topY + s * 0.10f))+            }+            // Afro halo behind everything.+            3 -> drawCircle(hair, w * 1.25f, Offset(c.x, topY + s * 0.08f))+        }+    }++    private fun eyeCenters(c: Offset, s: Float): Pair<Offset, Offset> {+        val y = c.y + eyeDy * s+        return Offset(c.x - eyeDx * s, y) to Offset(c.x + eyeDx * s, y)+    }++    private fun DrawScope.drawEyes(c: Offset, s: Float) {+        val (l, r) = eyeCenters(c, s)+        val whiteRx = eyeR * s * 1.25f+        val whiteRy = eyeR * s * (if (eyeStyle % 3 == 2) 1.35f else 1.0f)+        for (ec in listOf(l, r)) {+            when (eyeStyle % 4) {+                // 0: classic white + iris.+                0, 1 -> {+                    drawOval(Color.White, Offset(ec.x - whiteRx, ec.y - whiteRy), Size(whiteRx * 2, whiteRy * 2))+                    drawCircle(eyeColor, eyeR * s * 0.62f, ec)+                    drawCircle(Color.Black, eyeR * s * 0.30f, ec)+                    drawCircle(Color.White, eyeR * s * 0.12f, ec + Offset(-eyeR * s * 0.15f, -eyeR * s * 0.15f))+                }+                // 2: tall oval eyes.+                2 -> {+                    drawOval(Color.White, Offset(ec.x - whiteRx, ec.y - whiteRy), Size(whiteRx * 2, whiteRy * 2))+                    drawOval(eyeColor, Offset(ec.x - whiteRx * 0.5f, ec.y - whiteRy * 0.5f), Size(whiteRx, whiteRy))+                    drawCircle(Color.Black, eyeR * s * 0.28f, ec)+                }+                // 3: simple dot eyes (Mii-like minimal).+                else -> drawCircle(eyeColor, eyeR * s * 0.55f, ec)+            }+            // Upper lash line, tilted by eyeRotation.+            val tilt = eyeTilt * s * 0.1f+            drawLine(+                Color.Black,+                Offset(ec.x - whiteRx, ec.y - whiteRy * 0.55f + tilt),+                Offset(ec.x + whiteRx, ec.y - whiteRy * 0.55f - tilt),+                strokeWidth = s * 0.012f,+            )+        }+    }++    private fun DrawScope.drawBrows(c: Offset, s: Float) {+        val (l, r) = eyeCenters(c, s)+        val y = c.y + browDy * s+        for (ec in listOf(l, r)) {+            val w2 = eyeR * s * 1.2f+            val yOff = (ec.x - c.x) * eyeTilt * 0.3f+            // Brow rotation: tilt each brow around its own center.+            val rot = browTilt * s * 0.35f+            when (browStyle % 4) {+                0 -> drawLine(browColor, Offset(ec.x - w2, y + yOff + rot), Offset(ec.x + w2, y + yOff - rot), s * 0.03f)+                1 -> {+                    val p = Path().apply {+                        moveTo(ec.x - w2, y + s * 0.02f + yOff + rot)+                        quadraticTo(ec.x, y - s * 0.045f + yOff, ec.x + w2, y + yOff - rot)+                    }+                    drawPath(p, browColor, style = Stroke(s * 0.028f))+                }+                2 -> drawLine(browColor, Offset(ec.x - w2, y + s * 0.02f + yOff + rot), Offset(ec.x + w2, y - s * 0.02f + yOff - rot), s * 0.035f)+                else -> {+                    drawLine(browColor, Offset(ec.x - w2, y + yOff + rot), Offset(ec.x + w2 * 0.4f, y - s * 0.03f + yOff), s * 0.03f)+                    drawLine(browColor, Offset(ec.x + w2 * 0.4f, y - s * 0.03f + yOff), Offset(ec.x + w2, y + yOff - rot), s * 0.03f)+                }+            }+        }+    }++    private fun DrawScope.drawNose(c: Offset, s: Float) {+        val ny = c.y + s * 0.06f + noseDy * s+        val ink = skinShade+        when (noseStyle % 4) {+            0 -> drawLine(ink, Offset(c.x + s * 0.01f, ny - s * 0.03f), Offset(c.x + s * 0.01f, ny + s * 0.03f), s * 0.014f)+            1 -> {+                val p = Path().apply {+                    moveTo(c.x - s * 0.02f, ny - s * 0.03f)+                    quadraticTo(c.x + s * 0.03f, ny, c.x - s * 0.005f, ny + s * 0.03f)+                }+                drawPath(p, ink, style = Stroke(s * 0.014f))+            }+            2 -> drawCircle(ink, s * 0.018f, Offset(c.x, ny + s * 0.01f))+            else -> drawLine(ink, Offset(c.x - s * 0.03f, ny + s * 0.02f), Offset(c.x + s * 0.03f, ny + s * 0.02f), s * 0.016f)+        }+    }++    private fun DrawScope.drawMouth(c: Offset, s: Float) {+        val my = c.y + s * 0.16f + mouthDy * s+        val w2 = mouthW * s+        when (mouthStyle % 6) {+            0 -> drawLine(mouthColor, Offset(c.x - w2 * 0.8f, my), Offset(c.x + w2 * 0.8f, my), s * 0.018f)+            1 -> {+                val p = Path().apply {+                    moveTo(c.x - w2, my - s * 0.01f)+                    quadraticTo(c.x, my + s * 0.09f, c.x + w2, my - s * 0.01f)+                }+                drawPath(p, mouthColor, style = Stroke(s * 0.018f))+            }+            2 -> drawOval(mouthColor, Offset(c.x - w2 * 0.55f, my - s * 0.035f), Size(w2 * 1.1f, s * 0.09f))+            3 -> {+                drawOval(Color.White, Offset(c.x - w2 * 0.7f, my - s * 0.02f), Size(w2 * 1.4f, s * 0.10f))+                drawLine(Color.Black, Offset(c.x - w2 * 0.7f, my + s * 0.015f), Offset(c.x + w2 * 0.7f, my + s * 0.015f), s * 0.010f)+            }+            4 -> {+                val p = Path().apply {+                    moveTo(c.x - w2, my + s * 0.02f)+                    quadraticTo(c.x, my - s * 0.05f, c.x + w2, my + s * 0.02f)+                }+                drawPath(p, mouthColor, style = Stroke(s * 0.016f))+            }+            else -> {+                val p = Path().apply {+                    moveTo(c.x - w2, my)+                    lineTo(c.x - w2 * 0.3f, my + s * 0.02f)+                    lineTo(c.x + w2 * 0.3f, my + s * 0.02f)+                    lineTo(c.x + w2, my)+                    lineTo(c.x + w2 * 0.5f, my + s * 0.055f)+                    lineTo(c.x - w2 * 0.5f, my + s * 0.055f)+                    close()+                }+                drawPath(p, Color.White)+                drawPath(p, mouthColor, style = Stroke(s * 0.012f))+            }+        }+    }++    private fun DrawScope.drawSkinDetails(c: Offset, s: Float) {+        // Blush.+        if (blush != 0) {+            val bc = mouthColor.copy(alpha = 0.45f)+            val (l, r) = eyeCenters(c, s)+            val by = c.y + s * 0.12f+            val bw = s * (0.05f + blush * 0.012f)+            drawCircle(bc, bw, Offset(l.x - s * 0.05f, by))+            drawCircle(bc, bw, Offset(r.x + s * 0.05f, by))+            if (blush == 3) {+                drawCircle(bc, bw * 0.7f, Offset(l.x - s * 0.05f, by - bw))+                drawCircle(bc, bw * 0.7f, Offset(r.x + s * 0.05f, by - bw))+            }+        }+        // Wrinkles: forehead lines + crow's feet.+        if (wrinkles != 0) {+            val ink = skinShade.copy(alpha = 0.8f)+            val fy = c.y - faceHalfHeight() * s * 0.55f+            repeat(wrinkles) { i ->+                val yy = fy + i * s * 0.035f+                val wob = s * 0.10f * (1f - i * 0.15f)+                drawLine(ink, Offset(c.x - wob, yy), Offset(c.x + wob, yy), s * 0.008f)+            }+            val (l, r) = eyeCenters(c, s)+            drawLine(ink, Offset(l.x - eyeR * s * 1.7f, l.y), Offset(l.x - eyeR * s * 1.2f, l.y - s * 0.02f), s * 0.008f)+            drawLine(ink, Offset(r.x + eyeR * s * 1.7f, r.y), Offset(r.x + eyeR * s * 1.2f, r.y - s * 0.02f), s * 0.008f)+        }+        // Mole / beauty mark.+        if (mole != 0) {+            val mp = when (mole % 4) {+                1 -> Offset(c.x - s * 0.12f, c.y + s * 0.10f)+                2 -> Offset(c.x + s * 0.12f, c.y + s * 0.10f)+                3 -> Offset(c.x + s * 0.05f, c.y + s * 0.22f)+                else -> Offset(c.x - s * 0.05f, c.y + s * 0.02f)+            }+            drawCircle(Color(0xFF4A2B2B), s * 0.014f, mp)+        }+    }++    private fun DrawScope.drawGlasses(c: Offset, s: Float) {+        if (glasses == 0) return+        val (l, r) = eyeCenters(c, s)+        val frame = Color(0xFF2B2B2B)+        val rw = eyeR * s * 1.7f+        val rh = eyeR * s * 1.4f+        when (glasses % 3) {+            // 1: round frames + bridge.+            1 -> {+                for (ec in listOf(l, r)) drawCircle(frame, rw, ec, style = Stroke(s * 0.018f))+                drawLine(frame, Offset(l.x + rw, l.y - rh * 0.3f), Offset(r.x - rw, r.y - rh * 0.3f), s * 0.016f)+            }+            // 2: square frames.+            2 -> {+                for (ec in listOf(l, r)) {+                    drawRoundRectPath(ec, rw, rh, s * 0.02f, frame, s * 0.018f)+                }+                drawLine(frame, Offset(l.x + rw, l.y), Offset(r.x - rw, r.y), s * 0.016f)+            }+            // 0 (mod 3): shades.+            else -> {+                for (ec in listOf(l, r)) drawOval(frame, Offset(ec.x - rw, ec.y - rh), Size(rw * 2, rh * 2))+                drawRoundRect(frame, Offset(c.x - rw * 0.4f, l.y - rh * 0.4f), Size(rw * 0.8f, rh * 0.5f))+            }+        }+    }++    private fun DrawScope.drawRoundRectPath(c: Offset, hw: Float, hh: Float, r: Float, color: Color, width: Float) {+        drawRoundRect(+            color,+            topLeft = Offset(c.x - hw, c.y - hh),+            size = Size(hw * 2, hh * 2),+            cornerRadius = CornerRadius(r, r),+            style = Stroke(width),+        )+    }++    private fun DrawScope.drawBeard(c: Offset, s: Float) {+        if (beard == 0) return+        val w = faceHalfWidth() * s+        val my = c.y + s * 0.16f+        when (beard % 3) {+            // 1: moustache above the mouth.+            1 -> {+                drawOval(hair, Offset(c.x - mouthW * s * 1.1f, my - s * 0.045f), Size(mouthW * s * 1.1f, s * 0.035f))+                drawOval(hair, Offset(c.x - s * 0.01f, my - s * 0.045f), Size(mouthW * s * 1.1f, s * 0.035f))+            }+            // 2: goatee below the mouth.+            2 -> drawOval(hair, Offset(c.x - w * 0.28f, my + s * 0.03f), Size(w * 0.56f, s * 0.16f))+            // 0 (mod 3): full beard framing the jaw.+            else -> {+                val p = Path().apply {+                    moveTo(c.x - w * 0.95f, my - s * 0.06f)+                    quadraticTo(c.x - w * 0.7f, my + s * 0.30f, c.x, my + s * 0.32f)+                    quadraticTo(c.x + w * 0.7f, my + s * 0.30f, c.x + w * 0.95f, my - s * 0.06f)+                    quadraticTo(c.x + w * 0.5f, my + s * 0.10f, c.x, my + s * 0.10f)+                    quadraticTo(c.x - w * 0.5f, my + s * 0.10f, c.x - w * 0.95f, my - s * 0.06f)+                    close()+                }+                drawPath(p, hair)+            }+        }+    }++    private fun DrawScope.drawHairFront(c: Offset, s: Float) {+        if (hairStyle == 0) return+        val w = faceHalfWidth() * s+        val topY = c.y - faceHalfHeight() * s - s * 0.02f+        when (hairStyle % 6) {+            // 1: side part sweep.+            1 -> {+                val p = Path().apply {+                    moveTo(c.x - w * 1.05f, topY + s * 0.12f)+                    quadraticTo(c.x - w * 0.4f, topY - s * 0.10f, c.x + w * 1.05f, topY + s * 0.06f)+                    quadraticTo(c.x + w * 0.6f, topY - s * 0.02f, c.x + w * 0.2f, topY + s * 0.10f)+                    quadraticTo(c.x - w * 0.5f, topY + s * 0.02f, c.x - w * 1.05f, topY + s * 0.12f)+                    close()+                }+                drawPath(p, hair)+            }+            // 2: straight fringe.+            2 -> drawOval(hair, Offset(c.x - w * 1.02f, topY - s * 0.06f), Size(w * 2.04f, s * 0.20f))+            // 3: afro cap.+            3 -> {+                drawCircle(hair, w * 1.25f, Offset(c.x, topY + s * 0.08f))+                drawCircle(skin, w * 0.98f, Offset(c.x, topY + s * 0.22f))+            }+            // 4: spiky top.+            4 -> {+                val p = Path().apply {+                    val n = 7+                    moveTo(c.x - w * 1.05f, topY + s * 0.10f)+                    repeat(n) { i ->+                        val x0 = c.x - w * 1.05f + i * (w * 2.1f / n)+                        val x1 = x0 + w * 2.1f / n / 2+                        val x2 = x0 + w * 2.1f / n+                        lineTo(x1, topY - s * (0.08f + (i % 2) * 0.05f))+                        lineTo(x2, topY + s * 0.10f)+                    }+                    quadraticTo(c.x, topY + s * 0.16f, c.x - w * 1.05f, topY + s * 0.10f)+                    close()+                }+                drawPath(p, hair)+            }+            // 5: bald with side wisps.+            5 -> {+                drawOval(hair, Offset(c.x - w * 1.02f, topY + s * 0.02f), Size(w * 0.28f, s * 0.16f))+                drawOval(hair, Offset(c.x + w * 0.74f, topY + s * 0.02f), Size(w * 0.28f, s * 0.16f))+            }+            // 0 (mod 6): neat cap.+            else -> {+                val p = Path().apply {+                    moveTo(c.x - w * 1.02f, topY + s * 0.14f)+                    quadraticTo(c.x, topY - s * 0.14f, c.x + w * 1.02f, topY + s * 0.14f)+                    quadraticTo(c.x + w * 0.9f, topY + s * 0.02f, c.x + w * 0.55f, topY + s * 0.10f)+                    quadraticTo(c.x, topY - s * 0.02f, c.x - w * 0.55f, topY + s * 0.10f)+                    quadraticTo(c.x - w * 0.9f, topY + s * 0.02f, c.x - w * 1.02f, topY + s * 0.14f)+                    close()+                }+                drawPath(p, hair)+            }+        }+    }++    private fun Color.darken(fraction: Float): Color {+        // Simple RGB scaling via cosine-free linear darkening; alpha preserved.+        fun Float.d() = (this * (1f - fraction)).coerceIn(0f, 1f)+        return copy(red = red.d(), green = green.d(), blue = blue.d())+    }+}
games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/DashboardPage.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/DashboardPage.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/DashboardPage.ktindex 1001b91558..7369f2d52a 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/DashboardPage.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/DashboardPage.kt@@ -31,6 +31,7 @@ fun DashboardPage(     val level by viewModel.levelFlow.collectAsStateWithLifecycle()     val title by viewModel.titleFlow.collectAsStateWithLifecycle()     val profile by viewModel.profileFlow.collectAsStateWithLifecycle()+    val profileYuu by viewModel.profileYuuFlow.collectAsStateWithLifecycle()     val recentActivity by viewModel.recentActivityFlow.collectAsStateWithLifecycle()     val allAchievements by viewModel.allAchievementsFlow.collectAsStateWithLifecycle()     val dailyStreaks by viewModel.dailyStreaksFlow.collectAsStateWithLifecycle()@@ -61,6 +62,7 @@ fun DashboardPage(         state = DashboardUiState(             playerName = profile?.displayName,             avatarSymbol = profile?.avatarSymbol,+            profileYuu = profileYuu,             level = level,             title = title,             totalXp = xp,
games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/DashboardScreen.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/DashboardScreen.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/DashboardScreen.ktindex 5382cb562d..58ce1565d9 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/DashboardScreen.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/DashboardScreen.kt@@ -19,6 +19,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.vayunmathur.games.hub.R+import com.vayunmathur.games.hub.BuildConfig import com.vayunmathur.games.hub.data.entities.HubGameEntity import com.vayunmathur.games.hub.ui.components.ActivityItemCard import com.vayunmathur.games.hub.ui.components.AvatarBadge@@ -26,6 +27,7 @@ import com.vayunmathur.games.hub.ui.components.GameCard import com.vayunmathur.games.hub.ui.components.StatCard import com.vayunmathur.games.hub.ui.components.StreakCard import com.vayunmathur.games.hub.ui.components.XpProgressBar+import com.vayunmathur.games.hub.ui.components.YuuBadge import com.vayunmathur.games.hub.util.DashboardActions import com.vayunmathur.games.hub.util.DashboardUiState import com.vayunmathur.games.hub.util.formatPlaytime@@ -71,7 +73,11 @@ fun DashboardScreen(             item {                 Card(onClick = actions::openProfile, modifier = Modifier.fillMaxWidth()) {                     Row(modifier = Modifier.padding(16.dp), horizontalArrangement = Arrangement.spacedBy(12.dp)) {-                        AvatarBadge(symbol = state.avatarSymbol, large = true)+                        if (BuildConfig.DEV_BUILD && state.profileYuu != null) {+                            YuuBadge(config = state.profileYuu.config, large = true)+                        } else {+                            AvatarBadge(symbol = state.avatarSymbol, large = true)+                        }                         Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(4.dp)) {                             Text(text = state.playerName ?: stringResource(R.string.player), style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)                             Text(text = state.title, style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.primary)
games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ProfilePage.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ProfilePage.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ProfilePage.ktindex 390b488d86..90b455e1d5 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ProfilePage.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ProfilePage.kt@@ -11,6 +11,7 @@ import com.vayunmathur.games.hub.viewmodel.GameHubViewModel @Composable fun ProfilePage(viewModel: GameHubViewModel, modifier: Modifier = Modifier) {     val profile by viewModel.profileFlow.collectAsStateWithLifecycle()+    val profileYuu by viewModel.profileYuuFlow.collectAsStateWithLifecycle()     val xp by viewModel.totalXpFlow.collectAsStateWithLifecycle()     val level by viewModel.levelFlow.collectAsStateWithLifecycle()     val title by viewModel.titleFlow.collectAsStateWithLifecycle()@@ -20,6 +21,7 @@ fun ProfilePage(viewModel: GameHubViewModel, modifier: Modifier = Modifier) {         state = ProfileUiState(             playerName = profile?.displayName,             avatarSymbol = profile?.avatarSymbol,+            profileYuu = profileYuu,             level = level,             title = title,             totalXp = xp,
games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ProfileScreen.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ProfileScreen.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ProfileScreen.ktindex ed4aaf4554..c9b406120e 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ProfileScreen.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ProfileScreen.kt@@ -23,10 +23,12 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.vayunmathur.games.hub.R+import com.vayunmathur.games.hub.BuildConfig import com.vayunmathur.games.hub.ui.components.AvatarBadge import com.vayunmathur.games.hub.ui.components.AvatarIcon import com.vayunmathur.games.hub.ui.components.StatCard import com.vayunmathur.games.hub.ui.components.XpProgressBar+import com.vayunmathur.games.hub.ui.components.YuuBadge import com.vayunmathur.games.hub.util.ProfileActions import com.vayunmathur.games.hub.util.ProfileUiState import com.vayunmathur.games.hub.util.XpLevelCalculator@@ -81,7 +83,11 @@ fun ProfileScreen(             item {                 Card(modifier = Modifier.fillMaxWidth()) {                     Column(modifier = Modifier.padding(24.dp).fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(12.dp), horizontalAlignment = Alignment.CenterHorizontally) {-                        AvatarBadge(symbol = state.avatarSymbol, large = true)+                        if (BuildConfig.DEV_BUILD && state.profileYuu != null) {+                            YuuBadge(config = state.profileYuu.config, large = true)+                        } else {+                            AvatarBadge(symbol = state.avatarSymbol, large = true)+                        }                         Text(text = state.playerName ?: stringResource(R.string.player), style = MaterialTheme.typography.headlineSmall, fontWeight = FontWeight.Bold)                         Text(text = state.title, style = MaterialTheme.typography.titleMedium, color = MaterialTheme.colorScheme.primary)                         Text(stringResource(R.string.level_1, state.level), style = MaterialTheme.typography.labelLarge)
games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuEditorPage.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuEditorPage.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuEditorPage.ktnew file mode 100644index 0000000000..0e9fdbee1a--- /dev/null+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuEditorPage.kt@@ -0,0 +1,44 @@+package com.vayunmathur.games.hub.ui.screens++import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.remember+import androidx.compose.ui.Modifier+import androidx.lifecycle.compose.collectAsStateWithLifecycle+import com.vayunmathur.games.hub.data.entities.YuuFaceConfig+import com.vayunmathur.games.hub.ui.yuu.YuuEditorActions+import com.vayunmathur.games.hub.ui.yuu.YuuEditorUiState+import com.vayunmathur.games.hub.viewmodel.GameHubViewModel++/** Binds [GameHubViewModel] to the stateless [YuuEditorScreen]. */+@Composable+fun YuuEditorPage(+    viewModel: GameHubViewModel,+    editingId: Long?,+    onDismiss: () -> Unit,+    modifier: Modifier = Modifier,+) {+    val yuus by viewModel.yuuListFlow.collectAsStateWithLifecycle()+    val editing = remember(editingId, yuus) { yuus.find { it.id == editingId } }++    YuuEditorScreen(+        state = YuuEditorUiState(+            editingId = editingId,+            initialName = editing?.name ?: "",+            initialConfig = editing?.config ?: YuuFaceConfig.DEFAULT,+        ),+        actions = object : YuuEditorActions {+            override fun onSave(name: String, config: YuuFaceConfig) {+                val trimmed = name.trim()+                if (editingId == null) {+                    viewModel.createYuu(trimmed, config)+                } else {+                    viewModel.updateYuu(editingId, trimmed, config)+                }+                onDismiss()+            }+            override fun onDismiss() = onDismiss()+        },+        modifier = modifier,+    )+}
games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuEditorScreen.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuEditorScreen.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuEditorScreen.ktnew file mode 100644index 0000000000..929ef64c93--- /dev/null+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuEditorScreen.kt@@ -0,0 +1,560 @@+package com.vayunmathur.games.hub.ui.screens++import androidx.compose.foundation.BorderStroke+import androidx.compose.foundation.background+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.Row+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.aspectRatio+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.lazy.LazyRow+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.shape.CircleShape+import androidx.compose.foundation.verticalScroll+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.mutableIntStateOf+import androidx.compose.runtime.mutableLongStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.unit.dp+import com.vayunmathur.games.hub.R+import com.vayunmathur.games.hub.data.entities.YUU_EYE_COLORS+import com.vayunmathur.games.hub.data.entities.YUU_HAIR_COLORS+import com.vayunmathur.games.hub.data.entities.YUU_MOUTH_COLORS+import com.vayunmathur.games.hub.data.entities.YUU_SKIN_TONES+import com.vayunmathur.games.hub.data.entities.YuuFaceConfig+import com.vayunmathur.games.hub.ui.components.YuuFace+import com.vayunmathur.games.hub.ui.yuu.YuuCategory+import com.vayunmathur.games.hub.ui.yuu.YuuEditorActions+import com.vayunmathur.games.hub.ui.yuu.YuuEditorUiState+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.Card+import com.vayunmathur.library.ui.FilterChip+import com.vayunmathur.library.ui.IconArrowDownward+import com.vayunmathur.library.ui.IconArrowUpward+import com.vayunmathur.library.ui.IconButton+import com.vayunmathur.library.ui.IconRotateLeft+import com.vayunmathur.library.ui.IconRotateRight+import com.vayunmathur.library.ui.IconUnfoldLess+import com.vayunmathur.library.ui.IconUnfoldMore+import com.vayunmathur.library.ui.IconZoomIn+import com.vayunmathur.library.ui.IconZoomOut+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.OutlinedTextField+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.library.ui.R as UiR++/**+ * Wii-style Yuu creator with a fixed, non-scrolling layout: preview zone (with icon+ * steppers overlaid for the active category's numeric tweaks), a compact name+save+ * row, the category rail, then the option-picker zone which is the ONLY scrollable+ * area. Fully local draft state until [YuuEditorActions.onSave].+ */+@Composable+fun YuuEditorScreen(+    state: YuuEditorUiState,+    actions: YuuEditorActions,+    modifier: Modifier = Modifier,+) {+    val draft = remember(state.editingId, state.initialConfig) {+        YuuDraft.from(state.initialConfig)+    }+    var name by remember(state.editingId, state.initialName) {+        mutableStateOf(state.initialName)+    }+    var category by remember { mutableStateOf(YuuCategory.Face) }+    var nameError by remember { mutableStateOf(false) }++    AppScaffold(+        title = {+            Text(+                stringResource(+                    if (state.editingId == null) R.string.yuu_new else R.string.yuu_edit_title+                ),+                fontWeight = FontWeight.Bold,+            )+        },+        onNavigateBack = actions::onDismiss,+        scrollBehavior = appBarScrollBehavior(),+    ) { padding ->+        Column(+            modifier = modifier.fillMaxSize().padding(padding).padding(16.dp),+            verticalArrangement = Arrangement.spacedBy(10.dp),+        ) {+            // Zone 1: preview with overlay steppers for the active category.+            Card(modifier = Modifier.fillMaxWidth()) {+                Box(+                    modifier = Modifier.fillMaxWidth(),+                    contentAlignment = Alignment.Center,+                ) {+                    YuuFace(+                        config = draft.toConfig(),+                        withBody = true,+                        modifier = Modifier.fillMaxWidth(0.72f).aspectRatio(0.9f).padding(8.dp),+                    )+                    PreviewSteppers(+                        category = category,+                        draft = draft,+                        modifier = Modifier.fillMaxWidth().aspectRatio(0.9f),+                    )+                }+            }+            // Zone 2: name + save on one compact row.+            Row(+                modifier = Modifier.fillMaxWidth(),+                horizontalArrangement = Arrangement.spacedBy(8.dp),+                verticalAlignment = Alignment.CenterVertically,+            ) {+                OutlinedTextField(+                    value = name,+                    onValueChange = { name = it; nameError = false },+                    label = { Text(stringResource(UiR.string.name)) },+                    singleLine = true,+                    isError = nameError,+                    supportingText = if (nameError) {+                        { Text(stringResource(R.string.yuu_name_required)) }+                    } else null,+                    modifier = Modifier.weight(1f),+                )+                Button(+                    onClick = {+                        if (name.isBlank()) {+                            nameError = true+                        } else {+                            actions.onSave(name, draft.toConfig())+                        }+                    },+                ) { Text(stringResource(UiR.string.save)) }+            }+            // Zone 3: category rail (never scrolls the screen).+            LazyRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {+                items(YuuCategory.entries) { cat ->+                    FilterChip(+                        selected = category == cat,+                        onClick = { category = cat },+                        label = { Text(stringResource(cat.labelRes())) },+                    )+                }+            }+            // Zone 4: the ONLY scrollable area — the option picker.+            Column(+                modifier = Modifier.fillMaxWidth().weight(1f).verticalScroll(rememberScrollState()),+                verticalArrangement = Arrangement.spacedBy(8.dp),+            ) {+                when (category) {+                    YuuCategory.Face -> FacePanel(draft)+                    YuuCategory.Body -> BodyPanel(draft)+                    YuuCategory.Hair -> HairPanel(draft)+                    YuuCategory.Eyes -> EyesPanel(draft)+                    YuuCategory.Brows -> BrowsPanel(draft)+                    YuuCategory.Nose -> NosePanel(draft)+                    YuuCategory.Mouth -> MouthPanel(draft)+                    YuuCategory.Extras -> ExtrasPanel(draft)+                }+            }+        }+    }+}++private fun YuuCategory.labelRes(): Int = when (this) {+    YuuCategory.Face -> R.string.yuu_cat_face+    YuuCategory.Body -> R.string.yuu_cat_body+    YuuCategory.Hair -> R.string.yuu_cat_hair+    YuuCategory.Eyes -> R.string.yuu_cat_eyes+    YuuCategory.Brows -> R.string.yuu_cat_brows+    YuuCategory.Nose -> R.string.yuu_cat_nose+    YuuCategory.Mouth -> R.string.yuu_cat_mouth+    YuuCategory.Extras -> R.string.yuu_cat_extras+}++/** Mutable draft mirroring [YuuFaceConfig]; Compose observes each field. */+private class YuuDraft private constructor(+    faceShape: Int,+    skinTone: Long,+    earSize: Float,+    bodyHeight: Float,+    bodyWeight: Float,+    hairStyle: Int,+    hairColor: Long,+    eyeStyle: Int,+    eyeColor: Long,+    eyeSize: Float,+    eyeSpacing: Float,+    eyeHeight: Float,+    eyeRotation: Float,+    browStyle: Int,+    browColor: Long,+    browHeight: Float,+    browRotation: Float,+    noseStyle: Int,+    noseHeight: Float,+    mouthStyle: Int,+    mouthColor: Long,+    mouthSize: Float,+    mouthHeight: Float,+    glassesStyle: Int,+    beardStyle: Int,+    moleStyle: Int,+    wrinkleStyle: Int,+    blushStyle: Int,+) {+    var faceShape by mutableIntStateOf(faceShape)+    var skinTone by mutableLongStateOf(skinTone)+    var earSize by mutableFloatStateOf(earSize)+    var bodyHeight by mutableFloatStateOf(bodyHeight)+    var bodyWeight by mutableFloatStateOf(bodyWeight)+    var hairStyle by mutableIntStateOf(hairStyle)+    var hairColor by mutableLongStateOf(hairColor)+    var eyeStyle by mutableIntStateOf(eyeStyle)+    var eyeColor by mutableLongStateOf(eyeColor)+    var eyeSize by mutableFloatStateOf(eyeSize)+    var eyeSpacing by mutableFloatStateOf(eyeSpacing)+    var eyeHeight by mutableFloatStateOf(eyeHeight)+    var eyeRotation by mutableFloatStateOf(eyeRotation)+    var browStyle by mutableIntStateOf(browStyle)+    var browColor by mutableLongStateOf(browColor)+    var browHeight by mutableFloatStateOf(browHeight)+    var browRotation by mutableFloatStateOf(browRotation)+    var noseStyle by mutableIntStateOf(noseStyle)+    var noseHeight by mutableFloatStateOf(noseHeight)+    var mouthStyle by mutableIntStateOf(mouthStyle)+    var mouthColor by mutableLongStateOf(mouthColor)+    var mouthSize by mutableFloatStateOf(mouthSize)+    var mouthHeight by mutableFloatStateOf(mouthHeight)+    var glassesStyle by mutableIntStateOf(glassesStyle)+    var beardStyle by mutableIntStateOf(beardStyle)+    var moleStyle by mutableIntStateOf(moleStyle)+    var wrinkleStyle by mutableIntStateOf(wrinkleStyle)+    var blushStyle by mutableIntStateOf(blushStyle)++    fun toConfig() = YuuFaceConfig(+        faceShape = faceShape, skinTone = skinTone, earSize = earSize,+        bodyHeight = bodyHeight, bodyWeight = bodyWeight,+        hairStyle = hairStyle, hairColor = hairColor,+        eyeStyle = eyeStyle, eyeColor = eyeColor, eyeSize = eyeSize,+        eyeSpacing = eyeSpacing, eyeHeight = eyeHeight, eyeRotation = eyeRotation,+        browStyle = browStyle, browColor = browColor, browHeight = browHeight,+        browRotation = browRotation,+        noseStyle = noseStyle, noseHeight = noseHeight,+        mouthStyle = mouthStyle, mouthColor = mouthColor,+        mouthSize = mouthSize, mouthHeight = mouthHeight,+        glassesStyle = glassesStyle, beardStyle = beardStyle,+        moleStyle = moleStyle, wrinkleStyle = wrinkleStyle, blushStyle = blushStyle,+    )++    companion object {+        fun from(c: YuuFaceConfig) = YuuDraft(+            c.faceShape, c.skinTone, c.earSize, c.bodyHeight, c.bodyWeight,+            c.hairStyle, c.hairColor,+            c.eyeStyle, c.eyeColor, c.eyeSize, c.eyeSpacing, c.eyeHeight, c.eyeRotation,+            c.browStyle, c.browColor, c.browHeight, c.browRotation,+            c.noseStyle, c.noseHeight, c.mouthStyle,+            c.mouthColor, c.mouthSize, c.mouthHeight, c.glassesStyle, c.beardStyle, c.moleStyle,+            c.wrinkleStyle, c.blushStyle,+        )+    }+}++/** Step size for every icon stepper tap. */+private const val STEP = 0.1f++private fun Float.stepped(delta: Float): Float = (this + delta).coerceIn(0f, 1f)++/**+ * Icon steppers overlaid on the preview, one pair per numeric tweak of the active+ * category. Rotation uses rotate L/R icons, size uses zoom out/in, spacing uses+ * unfold less/more, vertical moves use up/down arrows.+ */+@Composable+private fun PreviewSteppers(+    category: YuuCategory,+    draft: YuuDraft,+    modifier: Modifier = Modifier,+) {+    val rows: List<StepperSpec> = when (category) {+        YuuCategory.Face -> listOf(+            StepperSpec(R.string.yuu_ear_size, { IconZoomOut() }, { draft.earSize = draft.earSize.stepped(-STEP) }, { IconZoomIn() }, { draft.earSize = draft.earSize.stepped(STEP) }),+        )+        YuuCategory.Body -> listOf(+            StepperSpec(R.string.yuu_body_height, { IconArrowDownward() }, { draft.bodyHeight = draft.bodyHeight.stepped(-STEP) }, { IconArrowUpward() }, { draft.bodyHeight = draft.bodyHeight.stepped(STEP) }),+            StepperSpec(R.string.yuu_body_weight, { IconUnfoldLess() }, { draft.bodyWeight = draft.bodyWeight.stepped(-STEP) }, { IconUnfoldMore() }, { draft.bodyWeight = draft.bodyWeight.stepped(STEP) }),+        )+        YuuCategory.Hair -> emptyList()+        YuuCategory.Eyes -> listOf(+            StepperSpec(R.string.yuu_eye_size, { IconZoomOut() }, { draft.eyeSize = draft.eyeSize.stepped(-STEP) }, { IconZoomIn() }, { draft.eyeSize = draft.eyeSize.stepped(STEP) }),+            StepperSpec(R.string.yuu_eye_spacing, { IconUnfoldLess() }, { draft.eyeSpacing = draft.eyeSpacing.stepped(-STEP) }, { IconUnfoldMore() }, { draft.eyeSpacing = draft.eyeSpacing.stepped(STEP) }),+            StepperSpec(R.string.yuu_eye_height, { IconArrowDownward() }, { draft.eyeHeight = draft.eyeHeight.stepped(-STEP) }, { IconArrowUpward() }, { draft.eyeHeight = draft.eyeHeight.stepped(STEP) }),+            StepperSpec(R.string.yuu_eye_rotation, { IconRotateLeft() }, { draft.eyeRotation = draft.eyeRotation.stepped(-STEP) }, { IconRotateRight() }, { draft.eyeRotation = draft.eyeRotation.stepped(STEP) }),+        )+        YuuCategory.Brows -> listOf(+            StepperSpec(R.string.yuu_brow_height, { IconArrowDownward() }, { draft.browHeight = draft.browHeight.stepped(-STEP) }, { IconArrowUpward() }, { draft.browHeight = draft.browHeight.stepped(STEP) }),+            StepperSpec(R.string.yuu_brow_rotation, { IconRotateLeft() }, { draft.browRotation = draft.browRotation.stepped(-STEP) }, { IconRotateRight() }, { draft.browRotation = draft.browRotation.stepped(STEP) }),+        )+        YuuCategory.Nose -> listOf(+            StepperSpec(R.string.yuu_nose_height, { IconArrowDownward() }, { draft.noseHeight = draft.noseHeight.stepped(-STEP) }, { IconArrowUpward() }, { draft.noseHeight = draft.noseHeight.stepped(STEP) }),+        )+        YuuCategory.Mouth -> listOf(+            StepperSpec(R.string.yuu_mouth_size, { IconZoomOut() }, { draft.mouthSize = draft.mouthSize.stepped(-STEP) }, { IconZoomIn() }, { draft.mouthSize = draft.mouthSize.stepped(STEP) }),+            StepperSpec(R.string.yuu_mouth_height, { IconArrowDownward() }, { draft.mouthHeight = draft.mouthHeight.stepped(-STEP) }, { IconArrowUpward() }, { draft.mouthHeight = draft.mouthHeight.stepped(STEP) }),+        )+        YuuCategory.Extras -> emptyList()+    }+    if (rows.isEmpty()) return+    Column(+        modifier = modifier.padding(4.dp),+        verticalArrangement = Arrangement.Bottom,+    ) {+        rows.forEach { spec ->+            Row(+                modifier = Modifier.fillMaxWidth(),+                horizontalArrangement = Arrangement.SpaceBetween,+                verticalAlignment = Alignment.CenterVertically,+            ) {+                IconButton(onClick = spec.onDecrease) { spec.decreaseIcon() }+                Text(+                    stringResource(spec.labelRes),+                    style = MaterialTheme.typography.labelSmall,+                    textAlign = TextAlign.Center,+                    modifier = Modifier.weight(1f),+                )+                IconButton(onClick = spec.onIncrease) { spec.increaseIcon() }+            }+        }+    }+}++private class StepperSpec(+    val labelRes: Int,+    val decreaseIcon: @Composable () -> Unit,+    val onDecrease: () -> Unit,+    val increaseIcon: @Composable () -> Unit,+    val onIncrease: () -> Unit,+)++@Composable+private fun SectionLabel(text: String) {+    Text(text, style = MaterialTheme.typography.labelMedium, fontWeight = FontWeight.Bold)+}++@Composable+private fun VariantGrid(+    count: Int,+    selected: Int,+    render: @Composable (Int, Boolean) -> Unit,+) {+    // Non-lazy fixed grid inside the scrollable option zone: lays out rows directly.+    val columns = 4+    val rows = (count + columns - 1) / columns+    Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+        repeat(rows) { row ->+            Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {+                for (col in 0 until columns) {+                    val i = row * columns + col+                    if (i < count) {+                        Box(Modifier.weight(1f)) { render(i, i == selected) }+                    } else {+                        Spacer(Modifier.weight(1f))+                    }+                }+            }+        }+    }+}++@Composable+private fun VariantCell(+    selected: Boolean,+    onClick: () -> Unit,+    content: @Composable () -> Unit,+) {+    Card(+        onClick = onClick,+        border = if (selected) {+            BorderStroke(2.dp, MaterialTheme.colorScheme.primary)+        } else null,+        modifier = Modifier.aspectRatio(1f),+    ) {+        Box(modifier = Modifier.fillMaxSize().padding(6.dp), contentAlignment = Alignment.Center) {+            content()+        }+    }+}++@Composable+private fun ColorSwatches(+    colors: List<Long>,+    selected: Long,+    onSelect: (Long) -> Unit,+) {+    LazyRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {+        items(colors) { argb ->+            val active = argb == selected+            Box(+                modifier = Modifier+                    .size(40.dp)+                    .clip(CircleShape)+                    .background(Color(argb))+                    .clickable { onSelect(argb) }+                    .then(+                        if (active) {+                            Modifier.background(+                                MaterialTheme.colorScheme.primary.copy(alpha = 0.15f),+                                CircleShape,+                            )+                        } else Modifier+                    ),+            )+        }+    }+}++@Composable+private fun FacePanel(d: YuuDraft) {+    Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+        SectionLabel(stringResource(R.string.yuu_face_shape))+        VariantGrid(count = YuuFaceConfig.FACE_SHAPES, selected = d.faceShape) { i, sel ->+            VariantCell(sel, onClick = { d.faceShape = i }) {+                YuuFace(YuuFaceConfig(faceShape = i, skinTone = d.skinTone), Modifier.fillMaxSize())+            }+        }+        SectionLabel(stringResource(R.string.yuu_skin_tone))+        ColorSwatches(YUU_SKIN_TONES, d.skinTone) { d.skinTone = it }+    }+}++@Composable+private fun BodyPanel(d: YuuDraft) {+    Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+        SectionLabel(stringResource(R.string.yuu_body_preview_hint))+        Card(modifier = Modifier.fillMaxWidth()) {+            Text(+                stringResource(R.string.yuu_body_hint),+                style = MaterialTheme.typography.bodySmall,+                modifier = Modifier.padding(12.dp),+            )+        }+    }+}++@Composable+private fun HairPanel(d: YuuDraft) {+    Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+        SectionLabel(stringResource(R.string.yuu_hair_style))+        VariantGrid(count = YuuFaceConfig.HAIR_STYLES, selected = d.hairStyle) { i, sel ->+            VariantCell(sel, onClick = { d.hairStyle = i }) {+                YuuFace(YuuFaceConfig(hairStyle = i, hairColor = d.hairColor, skinTone = d.skinTone), Modifier.fillMaxSize())+            }+        }+        SectionLabel(stringResource(R.string.yuu_hair_color))+        ColorSwatches(YUU_HAIR_COLORS, d.hairColor) { d.hairColor = it }+    }+}++@Composable+private fun EyesPanel(d: YuuDraft) {+    Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+        SectionLabel(stringResource(R.string.yuu_eye_style))+        VariantGrid(count = YuuFaceConfig.EYE_STYLES, selected = d.eyeStyle) { i, sel ->+            VariantCell(sel, onClick = { d.eyeStyle = i }) {+                YuuFace(YuuFaceConfig(eyeStyle = i, eyeColor = d.eyeColor, skinTone = d.skinTone), Modifier.fillMaxSize())+            }+        }+        SectionLabel(stringResource(R.string.yuu_eye_color))+        ColorSwatches(YUU_EYE_COLORS, d.eyeColor) { d.eyeColor = it }+    }+}++@Composable+private fun BrowsPanel(d: YuuDraft) {+    Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+        SectionLabel(stringResource(R.string.yuu_brow_style))+        VariantGrid(count = YuuFaceConfig.BROW_STYLES, selected = d.browStyle) { i, sel ->+            VariantCell(sel, onClick = { d.browStyle = i }) {+                YuuFace(YuuFaceConfig(browStyle = i, browColor = d.browColor, skinTone = d.skinTone), Modifier.fillMaxSize())+            }+        }+        SectionLabel(stringResource(R.string.yuu_brow_color))+        ColorSwatches(YUU_HAIR_COLORS, d.browColor) { d.browColor = it }+    }+}++@Composable+private fun NosePanel(d: YuuDraft) {+    Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+        SectionLabel(stringResource(R.string.yuu_nose_style))+        VariantGrid(count = YuuFaceConfig.NOSE_STYLES, selected = d.noseStyle) { i, sel ->+            VariantCell(sel, onClick = { d.noseStyle = i }) {+                YuuFace(YuuFaceConfig(noseStyle = i, skinTone = d.skinTone), Modifier.fillMaxSize())+            }+        }+    }+}++@Composable+private fun MouthPanel(d: YuuDraft) {+    Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+        SectionLabel(stringResource(R.string.yuu_mouth_style))+        VariantGrid(count = YuuFaceConfig.MOUTH_STYLES, selected = d.mouthStyle) { i, sel ->+            VariantCell(sel, onClick = { d.mouthStyle = i }) {+                YuuFace(YuuFaceConfig(mouthStyle = i, mouthColor = d.mouthColor, skinTone = d.skinTone), Modifier.fillMaxSize())+            }+        }+        SectionLabel(stringResource(R.string.yuu_mouth_color))+        ColorSwatches(YUU_MOUTH_COLORS, d.mouthColor) { d.mouthColor = it }+    }+}++@Composable+private fun ExtrasPanel(d: YuuDraft) {+    Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+        SectionLabel(stringResource(R.string.yuu_glasses))+        VariantGrid(count = YuuFaceConfig.GLASSES_STYLES + 1, selected = d.glassesStyle) { i, sel ->+            VariantCell(sel, onClick = { d.glassesStyle = i }) {+                if (i == 0) Text(stringResource(UiR.string.none)) else YuuFace(YuuFaceConfig(glassesStyle = i, skinTone = d.skinTone), Modifier.fillMaxSize())+            }+        }+        SectionLabel(stringResource(R.string.yuu_beard))+        VariantGrid(count = YuuFaceConfig.BEARD_STYLES + 1, selected = d.beardStyle) { i, sel ->+            VariantCell(sel, onClick = { d.beardStyle = i }) {+                if (i == 0) Text(stringResource(UiR.string.none)) else YuuFace(YuuFaceConfig(beardStyle = i, skinTone = d.skinTone, hairColor = d.hairColor), Modifier.fillMaxSize())+            }+        }+        SectionLabel(stringResource(R.string.yuu_mole))+        VariantGrid(count = YuuFaceConfig.MOLE_STYLES + 1, selected = d.moleStyle) { i, sel ->+            VariantCell(sel, onClick = { d.moleStyle = i }) {+                if (i == 0) Text(stringResource(UiR.string.none)) else YuuFace(YuuFaceConfig(moleStyle = i, skinTone = d.skinTone), Modifier.fillMaxSize())+            }+        }+        SectionLabel(stringResource(R.string.yuu_wrinkles))+        VariantGrid(count = YuuFaceConfig.WRINKLE_STYLES + 1, selected = d.wrinkleStyle) { i, sel ->+            VariantCell(sel, onClick = { d.wrinkleStyle = i }) {+                if (i == 0) Text(stringResource(UiR.string.none)) else YuuFace(YuuFaceConfig(wrinkleStyle = i, skinTone = d.skinTone), Modifier.fillMaxSize())+            }+        }+        SectionLabel(stringResource(R.string.yuu_blush))+        VariantGrid(count = YuuFaceConfig.BLUSH_STYLES + 1, selected = d.blushStyle) { i, sel ->+            VariantCell(sel, onClick = { d.blushStyle = i }) {+                if (i == 0) Text(stringResource(UiR.string.none)) else YuuFace(YuuFaceConfig(blushStyle = i, skinTone = d.skinTone), Modifier.fillMaxSize())+            }+        }+    }+}
games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuPage.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuPage.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuPage.ktnew file mode 100644index 0000000000..342b5afb8f--- /dev/null+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuPage.kt@@ -0,0 +1,38 @@+package com.vayunmathur.games.hub.ui.screens++import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.ui.Modifier+import androidx.lifecycle.compose.collectAsStateWithLifecycle+import com.vayunmathur.games.hub.data.YuuUiModel+import com.vayunmathur.games.hub.ui.yuu.YuuListActions+import com.vayunmathur.games.hub.ui.yuu.YuuListUiState+import com.vayunmathur.games.hub.viewmodel.GameHubViewModel++/** Binds [GameHubViewModel] to the stateless [YuuScreen]. */+@Composable+fun YuuPage(+    viewModel: GameHubViewModel,+    onCreateYuu: () -> Unit,+    onEditYuu: (Long) -> Unit,+    modifier: Modifier = Modifier,+) {+    val yuus by viewModel.yuuListFlow.collectAsStateWithLifecycle()+    val profileYuu by viewModel.profileYuuFlow.collectAsStateWithLifecycle()++    YuuScreen(+        state = YuuListUiState(+            yuus = yuus,+            profileYuuId = profileYuu?.id,+        ),+        actions = object : YuuListActions {+            override fun onCreate() = onCreateYuu()+            override fun onEdit(yuu: YuuUiModel) = onEditYuu(yuu.id)+            override fun onDuplicate(yuu: YuuUiModel) = viewModel.duplicateYuu(yuu.id)+            override fun onDelete(yuu: YuuUiModel) = viewModel.deleteYuu(yuu.id)+            override fun onSetAsProfile(yuu: YuuUiModel) = viewModel.setProfileYuu(yuu.id)+            override fun onClearProfile() = viewModel.clearProfileYuu()+        },+        modifier = modifier,+    )+}
games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuScreen.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuScreen.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuScreen.ktnew file mode 100644index 0000000000..857323f281--- /dev/null+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuScreen.kt@@ -0,0 +1,166 @@+package com.vayunmathur.games.hub.ui.screens++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.aspectRatio+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.grid.GridCells+import androidx.compose.foundation.lazy.grid.LazyVerticalGrid+import androidx.compose.foundation.lazy.grid.items+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResource+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.unit.dp+import com.vayunmathur.games.hub.R+import com.vayunmathur.games.hub.data.YuuUiModel+import com.vayunmathur.games.hub.ui.components.YuuFace+import com.vayunmathur.games.hub.ui.yuu.YuuListActions+import com.vayunmathur.games.hub.ui.yuu.YuuListUiState+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.Card+import com.vayunmathur.library.ui.DropdownMenu+import com.vayunmathur.library.ui.DropdownMenuItem+import com.vayunmathur.library.ui.FloatingActionButton+import com.vayunmathur.library.ui.IconAdd+import com.vayunmathur.library.ui.IconMoreVert+import com.vayunmathur.library.ui.IconButton+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.library.ui.R as UiR++/**+ * The Yuu plaza: grid of named avatars with create / edit / duplicate / delete /+ * set-as-profile. Stateless — the editor itself lives in [YuuEditorScreen].+ */+@Composable+fun YuuScreen(+    state: YuuListUiState,+    actions: YuuListActions,+    modifier: Modifier = Modifier,+) {+    AppScaffold(+        title = { Text(stringResource(R.string.tab_yuu), fontWeight = FontWeight.Bold) },+        scrollBehavior = appBarScrollBehavior(),+        floatingActionButton = {+            FloatingActionButton(onClick = actions::onCreate) { IconAdd() }+        },+    ) { padding ->+        if (state.yuus.isEmpty()) {+            Box(+                modifier = modifier.fillMaxSize().padding(padding).padding(32.dp),+                contentAlignment = Alignment.Center,+            ) {+                Column(+                    horizontalAlignment = Alignment.CenterHorizontally,+                    verticalArrangement = Arrangement.spacedBy(8.dp),+                ) {+                    Text(+                        text = stringResource(R.string.yuu_empty_title),+                        style = MaterialTheme.typography.titleMedium,+                        fontWeight = FontWeight.Bold,+                        textAlign = TextAlign.Center,+                    )+                    Text(+                        text = stringResource(R.string.yuu_empty_body),+                        style = MaterialTheme.typography.bodyMedium,+                        color = MaterialTheme.colorScheme.onSurfaceVariant,+                        textAlign = TextAlign.Center,+                    )+                }+            }+        } else {+            LazyVerticalGrid(+                columns = GridCells.Adaptive(120.dp),+                modifier = modifier.fillMaxSize().padding(padding),+                contentPadding = PaddingValues(16.dp),+                horizontalArrangement = Arrangement.spacedBy(12.dp),+                verticalArrangement = Arrangement.spacedBy(12.dp),+            ) {+                items(state.yuus, key = { it.id }) { yuu ->+                    YuuCard(+                        yuu = yuu,+                        isProfile = yuu.id == state.profileYuuId,+                        actions = actions,+                    )+                }+            }+        }+    }+}++@Composable+private fun YuuCard(+    yuu: YuuUiModel,+    isProfile: Boolean,+    actions: YuuListActions,+    modifier: Modifier = Modifier,+) {+    var menuOpen by remember { mutableStateOf(false) }+    Card(onClick = { actions.onEdit(yuu) }, modifier = modifier.fillMaxWidth()) {+        Column(+            modifier = Modifier.padding(12.dp).fillMaxWidth(),+            horizontalAlignment = Alignment.CenterHorizontally,+            verticalArrangement = Arrangement.spacedBy(8.dp),+        ) {+            Box(contentAlignment = Alignment.TopEnd) {+                YuuFace(+                    config = yuu.config,+                    modifier = Modifier.fillMaxWidth().aspectRatio(1f),+                )+                IconButton(onClick = { menuOpen = true }) { IconMoreVert() }+                DropdownMenu(expanded = menuOpen, onDismissRequest = { menuOpen = false }) {+                    DropdownMenuItem(+                        text = { Text(stringResource(R.string.yuu_edit)) },+                        onClick = { menuOpen = false; actions.onEdit(yuu) },+                    )+                    DropdownMenuItem(+                        text = { Text(stringResource(R.string.duplicate)) },+                        onClick = { menuOpen = false; actions.onDuplicate(yuu) },+                    )+                    if (isProfile) {+                        DropdownMenuItem(+                            text = { Text(stringResource(R.string.remove_profile_avatar)) },+                            onClick = { menuOpen = false; actions.onClearProfile() },+                        )+                    } else {+                        DropdownMenuItem(+                            text = { Text(stringResource(R.string.set_as_profile_avatar)) },+                            onClick = { menuOpen = false; actions.onSetAsProfile(yuu) },+                        )+                    }+                    DropdownMenuItem(+                        text = { Text(stringResource(UiR.string.delete)) },+                        onClick = { menuOpen = false; actions.onDelete(yuu) },+                    )+                }+            }+            Text(+                text = yuu.name,+                style = MaterialTheme.typography.labelLarge,+                fontWeight = FontWeight.Medium,+                maxLines = 1,+                overflow = TextOverflow.Ellipsis,+            )+            if (isProfile) {+                Text(+                    text = stringResource(R.string.profile_avatar),+                    style = MaterialTheme.typography.labelSmall,+                    color = MaterialTheme.colorScheme.primary,+                )+            }+        }+    }+}
games/hub/src/main/java/com/vayunmathur/games/hub/ui/yuu/YuuEditorContract.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/yuu/YuuEditorContract.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/yuu/YuuEditorContract.ktnew file mode 100644index 0000000000..d223950eac--- /dev/null+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/yuu/YuuEditorContract.kt@@ -0,0 +1,34 @@+package com.vayunmathur.games.hub.ui.yuu++import com.vayunmathur.games.hub.data.entities.YuuFaceConfig++/** Wii-style creator categories, in rail order. */+enum class YuuCategory {+    Face,+    Body,+    Hair,+    Eyes,+    Brows,+    Nose,+    Mouth,+    Extras,+}++/**+ * UI contract for the Yuu creator. The screen holds draft [config] + [name] locally+ * while editing; [onSave] persists via the ViewModel and [onDismiss] closes.+ */+data class YuuEditorUiState(+    val editingId: Long? = null,+    val initialName: String = "",+    val initialConfig: YuuFaceConfig = YuuFaceConfig.DEFAULT,+)++interface YuuEditorActions {+    fun onSave(name: String, config: YuuFaceConfig) {}+    fun onDismiss() {}++    companion object {+        val Noop: YuuEditorActions = object : YuuEditorActions {}+    }+}
games/hub/src/main/java/com/vayunmathur/games/hub/ui/yuu/YuuUiContract.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/yuu/YuuUiContract.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/yuu/YuuUiContract.ktnew file mode 100644index 0000000000..6f44f62b47--- /dev/null+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/yuu/YuuUiContract.kt@@ -0,0 +1,25 @@+package com.vayunmathur.games.hub.ui.yuu++import com.vayunmathur.games.hub.data.YuuUiModel++/**+ * UI contract for the Yuu plaza tab. Lives under `ui` (not `util`) since `util/` is+ * pending migration — same state+actions shape as `util/HubUiContract.kt` otherwise.+ */+data class YuuListUiState(+    val yuus: List<YuuUiModel> = emptyList(),+    val profileYuuId: Long? = null,+)++interface YuuListActions {+    fun onCreate() {}+    fun onEdit(yuu: YuuUiModel) {}+    fun onDuplicate(yuu: YuuUiModel) {}+    fun onDelete(yuu: YuuUiModel) {}+    fun onSetAsProfile(yuu: YuuUiModel) {}+    fun onClearProfile() {}++    companion object {+        val Noop: YuuListActions = object : YuuListActions {}+    }+}
games/hub/src/main/java/com/vayunmathur/games/hub/util/HubUiContract.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/util/HubUiContract.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/util/HubUiContract.ktindex 942ceacb7d..662fc399a5 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/util/HubUiContract.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/util/HubUiContract.kt@@ -1,5 +1,6 @@ package com.vayunmathur.games.hub.util +import com.vayunmathur.games.hub.data.YuuUiModel import com.vayunmathur.games.hub.data.entities.ActivityEventEntity import com.vayunmathur.games.hub.data.entities.HubGameEntity import com.vayunmathur.games.hub.viewmodel.CrossGameStats@@ -23,6 +24,7 @@ import com.vayunmathur.games.hub.viewmodel.CrossGameStats data class DashboardUiState(     val playerName: String? = null,     val avatarSymbol: String? = null,+    val profileYuu: YuuUiModel? = null,     val level: Int = 1,     val title: String = "Beginner",     val totalXp: Int = 0,@@ -52,6 +54,7 @@ data class GamesListUiState( data class ProfileUiState(     val playerName: String? = null,     val avatarSymbol: String? = null,+    val profileYuu: YuuUiModel? = null,     val level: Int = 1,     val title: String = "Beginner",     val totalXp: Int = 0,
games/hub/src/main/java/com/vayunmathur/games/hub/viewmodel/GameHubViewModel.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/viewmodel/GameHubViewModel.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/viewmodel/GameHubViewModel.ktindex 98d5048b1d..a5b5399d54 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/viewmodel/GameHubViewModel.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/viewmodel/GameHubViewModel.kt@@ -6,12 +6,14 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.viewModelScope import com.vayunmathur.games.hub.data.GamesHubRepository+import com.vayunmathur.games.hub.data.YuuUiModel import com.vayunmathur.games.hub.data.dao.AchievementWithProgress import com.vayunmathur.games.hub.data.entities.ActivityEventEntity import com.vayunmathur.games.hub.data.entities.DailyStreakEntity import com.vayunmathur.games.hub.data.entities.HubGameEntity import com.vayunmathur.games.hub.data.entities.PlayerProfileEntity import com.vayunmathur.games.hub.data.entities.PlaySessionEntity+import com.vayunmathur.games.hub.data.entities.YuuFaceConfig import com.vayunmathur.games.hub.util.ProfileActions import com.vayunmathur.games.hub.util.StreakCalculator import com.vayunmathur.games.hub.util.XpLevelCalculator@@ -85,6 +87,14 @@ class GameHubViewModel(         repository.profile.profileFlow()             .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), null) +    val yuuListFlow: StateFlow<List<YuuUiModel>> =+        repository.yuus.yuusFlow()+            .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), emptyList())++    val profileYuuFlow: StateFlow<YuuUiModel?> =+        repository.yuus.profileYuuFlow()+            .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), null)+     init {         viewModelScope.launch(Dispatchers.IO) {             val existing = repository.profile.getProfile()@@ -108,6 +118,42 @@ class GameHubViewModel(         }     } +    fun createYuu(name: String, config: YuuFaceConfig) {+        viewModelScope.launch(Dispatchers.IO) {+            repository.yuus.createYuu(name, config)+        }+    }++    fun updateYuu(id: Long, name: String, config: YuuFaceConfig) {+        viewModelScope.launch(Dispatchers.IO) {+            repository.yuus.updateYuu(id, name, config)+        }+    }++    fun duplicateYuu(id: Long) {+        viewModelScope.launch(Dispatchers.IO) {+            repository.yuus.duplicateYuu(id)+        }+    }++    fun deleteYuu(id: Long) {+        viewModelScope.launch(Dispatchers.IO) {+            repository.yuus.deleteYuu(id)+        }+    }++    fun setProfileYuu(id: Long) {+        viewModelScope.launch(Dispatchers.IO) {+            repository.yuus.setProfileYuu(id)+        }+    }++    fun clearProfileYuu() {+        viewModelScope.launch(Dispatchers.IO) {+            repository.yuus.clearProfileYuu()+        }+    }+     val sessionsFlow: StateFlow<List<PlaySessionEntity>> =         repository.sessions.allSessionsFlow()             .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), emptyList())
games/hub/src/main/res/values/strings.xml
diff --git a/games/hub/src/main/res/values/strings.xml b/games/hub/src/main/res/values/strings.xmlindex 2fd24a1231..fe5ffd8821 100644--- a/games/hub/src/main/res/values/strings.xml+++ b/games/hub/src/main/res/values/strings.xml@@ -131,4 +131,68 @@     <string name="connect_to_tv">Connect to TV</string>     <!-- Dashboard: explains the generic controller entry. -->     <string name="connect_to_tv_subtitle">Use this phone as a controller for games on your TV</string>++    <!-- YuuScreen: Tab title for the Yuu avatar plaza. Noun -->+    <string name="tab_yuu">Yuu</string>+    <!-- YuuScreen: Empty state title when no Yuus exist yet. Sentence -->+    <string name="yuu_empty_title">No Yuus yet</string>+    <!-- YuuScreen: Empty state body inviting creation. Sentence -->+    <string name="yuu_empty_body">Tap + to create your first Yuu avatar!</string>+    <!-- YuuScreen: Overflow menu edit action. Verb -->+    <string name="yuu_edit">Edit</string>+    <!-- YuuScreen: Overflow menu duplicate action. Verb -->+    <string name="duplicate">Duplicate</string>+    <!-- YuuScreen: Overflow menu action linking a Yuu as the profile avatar. Verb phrase -->+    <string name="set_as_profile_avatar">Set as profile avatar</string>+    <!-- YuuScreen: Overflow menu action unlinking the profile Yuu. Verb phrase -->+    <string name="remove_profile_avatar">Remove profile avatar</string>+    <!-- YuuScreen: Label marking the Yuu linked as profile avatar. Noun phrase -->+    <string name="profile_avatar">Profile avatar</string>+    <!-- YuuEditorScreen: Title for creating a Yuu. Noun phrase -->+    <string name="yuu_new">New Yuu</string>+    <!-- YuuEditorScreen: Title for editing a Yuu. Noun phrase -->+    <string name="yuu_edit_title">Edit Yuu</string>+    <!-- YuuEditorScreen: Error when the name field is blank. Sentence -->+    <string name="yuu_name_required">Give your Yuu a name</string>+    <!-- YuuEditorScreen: Category labels. Nouns -->+    <string name="yuu_cat_face">Face</string>+    <string name="yuu_cat_body">Body</string>+    <string name="yuu_cat_hair">Hair</string>+    <string name="yuu_cat_eyes">Eyes</string>+    <string name="yuu_cat_brows">Brows</string>+    <string name="yuu_cat_nose">Nose</string>+    <string name="yuu_cat_mouth">Mouth</string>+    <string name="yuu_cat_extras">Extras</string>+    <!-- YuuEditorScreen: Section labels. Noun phrases -->+    <string name="yuu_face_shape">Face shape</string>+    <string name="yuu_skin_tone">Skin tone</string>+    <string name="yuu_ear_size">Ear size</string>+    <string name="yuu_hair_style">Hairstyle</string>+    <string name="yuu_hair_color">Hair color</string>+    <string name="yuu_eye_style">Eyes</string>+    <string name="yuu_eye_color">Eye color</string>+    <string name="yuu_eye_size">Size</string>+    <string name="yuu_eye_spacing">Spacing</string>+    <string name="yuu_eye_height">Height</string>+    <string name="yuu_eye_rotation">Rotation</string>+    <string name="yuu_brow_style">Eyebrows</string>+    <string name="yuu_brow_color">Brow color</string>+    <string name="yuu_brow_height">Brow height</string>+    <string name="yuu_brow_rotation">Brow rotation</string>+    <string name="yuu_nose_style">Nose</string>+    <string name="yuu_nose_height">Nose height</string>+    <string name="yuu_mouth_style">Mouth</string>+    <string name="yuu_mouth_color">Mouth color</string>+    <string name="yuu_mouth_size">Mouth size</string>+    <string name="yuu_mouth_height">Mouth height</string>+    <string name="yuu_glasses">Glasses</string>+    <string name="yuu_beard">Facial hair</string>+    <string name="yuu_mole">Beauty mark</string>+    <string name="yuu_wrinkles">Wrinkles</string>+    <string name="yuu_blush">Blush</string>+    <!-- YuuEditorScreen: Body category labels and hint. Noun phrases + sentence -->+    <string name="yuu_body_height">Height</string>+    <string name="yuu_body_weight">Weight</string>+    <string name="yuu_body_preview_hint">Body</string>+    <string name="yuu_body_hint">Use the arrows on the preview to set height, and the unfold icons for weight.</string> </resources>
games/hub/src/screenshotTest/kotlin/com/vayunmathur/games/hub/ui/screens/MetadataPreviews.kt
diff --git a/games/hub/src/screenshotTest/kotlin/com/vayunmathur/games/hub/ui/screens/MetadataPreviews.kt b/games/hub/src/screenshotTest/kotlin/com/vayunmathur/games/hub/ui/screens/MetadataPreviews.ktindex 852ad7b239..655b319313 100644--- a/games/hub/src/screenshotTest/kotlin/com/vayunmathur/games/hub/ui/screens/MetadataPreviews.kt+++ b/games/hub/src/screenshotTest/kotlin/com/vayunmathur/games/hub/ui/screens/MetadataPreviews.kt@@ -8,8 +8,14 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import com.android.tools.screenshot.PreviewTest+import com.vayunmathur.games.hub.data.YuuUiModel import com.vayunmathur.games.hub.data.entities.ActivityEventEntity import com.vayunmathur.games.hub.data.entities.HubGameEntity+import com.vayunmathur.games.hub.data.entities.YuuFaceConfig+import com.vayunmathur.games.hub.ui.yuu.YuuEditorActions+import com.vayunmathur.games.hub.ui.yuu.YuuEditorUiState+import com.vayunmathur.games.hub.ui.yuu.YuuListActions+import com.vayunmathur.games.hub.ui.yuu.YuuListUiState import com.vayunmathur.games.hub.util.DashboardActions import com.vayunmathur.games.hub.util.DashboardUiState import com.vayunmathur.games.hub.util.GamesListActions@@ -179,4 +185,50 @@ class MetadataPreviews {             }         }     }++    @PreviewTest+    @Preview(name = "5-yuu", device = PHONE, showSystemUi = true)+    @Composable+    fun Preview5Yuu() {+        DynamicTheme(darkTheme = true) {+            YuuScreen(+                state = YuuListUiState(+                    yuus = listOf(+                        YuuUiModel(1, "Alex", YuuFaceConfig.DEFAULT, isProfile = true, updatedAt = now),+                        YuuUiModel(2, "Sam", YuuFaceConfig(faceShape = 2, hairStyle = 2, eyeStyle = 3), isProfile = false, updatedAt = now),+                        YuuUiModel(3, "Jo", YuuFaceConfig(faceShape = 5, hairStyle = 4, glassesStyle = 1), isProfile = false, updatedAt = now),+                    ),+                    profileYuuId = 1,+                ),+                actions = YuuListActions.Noop,+            )+        }+    }++    @PreviewTest+    @Preview(name = "6-yuu-empty", device = PHONE, showSystemUi = true)+    @Composable+    fun Preview6YuuEmpty() {+        DynamicTheme(darkTheme = true) {+            YuuScreen(+                state = YuuListUiState(),+                actions = YuuListActions.Noop,+            )+        }+    }++    @PreviewTest+    @Preview(name = "7-yuu-editor", device = PHONE, showSystemUi = true)+    @Composable+    fun Preview7YuuEditor() {+        DynamicTheme(darkTheme = true) {+            YuuEditorScreen(+                state = YuuEditorUiState(+                    initialName = "Alex",+                    initialConfig = YuuFaceConfig(faceShape = 1, hairStyle = 2, eyeStyle = 1),+                ),+                actions = YuuEditorActions.Noop,+            )+        }+    } }
library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.ktindex 49405484e9..7344ad5f57 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt@@ -124,6 +124,7 @@ import androidx.compose.material.icons.filled.Apps import androidx.compose.material.icons.filled.Widgets import androidx.compose.material.icons.filled.Receipt import androidx.compose.material.icons.filled.Archive+import androidx.compose.material.icons.filled.ArrowDownward import androidx.compose.material.icons.filled.ArrowDropDown import androidx.compose.material.icons.filled.Attachment import androidx.compose.material.icons.filled.Backup@@ -182,6 +183,7 @@ import androidx.compose.material.icons.filled.Grass import androidx.compose.material.icons.filled.GridOn import androidx.compose.material.icons.filled.Group import androidx.compose.material.icons.filled.History+import androidx.compose.material.icons.filled.Height import androidx.compose.material.icons.filled.Home import androidx.compose.material.icons.filled.HourglassBottom import androidx.compose.material.icons.filled.Image@@ -236,6 +238,8 @@ import androidx.compose.material.icons.filled.ThumbDown import androidx.compose.material.icons.filled.ThumbUp import androidx.compose.material.icons.filled.Timer import androidx.compose.material.icons.filled.Unarchive+import androidx.compose.material.icons.filled.UnfoldLess+import androidx.compose.material.icons.filled.UnfoldMore import androidx.compose.material.icons.filled.Upload import androidx.compose.material.icons.filled.VerifiedUser import androidx.compose.material.icons.filled.Videocam@@ -276,6 +280,8 @@ import androidx.compose.material.icons.filled.LocalOffer import androidx.compose.material.icons.filled.ShoppingCart import androidx.compose.material.icons.filled.Wallpaper import androidx.compose.material.icons.filled.Work+import androidx.compose.material.icons.filled.ZoomIn+import androidx.compose.material.icons.filled.ZoomOut import androidx.compose.material.icons.outlined.HighlightAlt import androidx.compose.material.icons.outlined.Inbox import androidx.compose.material.icons.outlined.MailOutline@@ -371,6 +377,34 @@ fun IconRotateLeft(modifier: Modifier = Modifier, tint: Color = LocalContentColo fun IconRotateRight(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) =     AppIcon(Icons.AutoMirrored.Filled.RotateRight, "Rotate Right", modifier, tint) +@Composable+fun IconZoomIn(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) =+    AppIcon(Icons.Filled.ZoomIn, "Increase size", modifier, tint)++@Composable+fun IconZoomOut(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) =+    AppIcon(Icons.Filled.ZoomOut, "Decrease size", modifier, tint)++@Composable+fun IconUnfoldMore(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) =+    AppIcon(Icons.Filled.UnfoldMore, "Increase spacing", modifier, tint)++@Composable+fun IconUnfoldLess(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) =+    AppIcon(Icons.Filled.UnfoldLess, "Decrease spacing", modifier, tint)++@Composable+fun IconArrowUpward(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) =+    AppIcon(Icons.Filled.ArrowUpward, "Move up", modifier, tint)++@Composable+fun IconArrowDownward(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) =+    AppIcon(Icons.Filled.ArrowDownward, "Move down", modifier, tint)++@Composable+fun IconHeight(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) =+    AppIcon(Icons.Filled.Height, "Height", modifier, tint)+ @Composable fun IconContentCut(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) =     AppIcon(Icons.Filled.ContentCut, "Trim", modifier, tint)
metadata_data/photos/games-hub/1.png
diff --git a/metadata_data/photos/games-hub/1.png b/metadata_data/photos/games-hub/1.pngindex 8ddb171a46..a919775858 100644Binary files a/metadata_data/photos/games-hub/1.png and b/metadata_data/photos/games-hub/1.png differ
metadata_data/photos/games-hub/4.png
diff --git a/metadata_data/photos/games-hub/4.png b/metadata_data/photos/games-hub/4.pngindex d2801e8899..32051dfd40 100644Binary files a/metadata_data/photos/games-hub/4.png and b/metadata_data/photos/games-hub/4.png differ
metadata_data/photos/games-hub/5.png
diff --git a/metadata_data/photos/games-hub/5.png b/metadata_data/photos/games-hub/5.pngnew file mode 100644index 0000000000..8cecdc93faBinary files /dev/null and b/metadata_data/photos/games-hub/5.png differ
metadata_data/photos/games-hub/6.png
diff --git a/metadata_data/photos/games-hub/6.png b/metadata_data/photos/games-hub/6.pngnew file mode 100644index 0000000000..3717abbc41Binary files /dev/null and b/metadata_data/photos/games-hub/6.png differ
metadata_data/photos/games-hub/7.png
diff --git a/metadata_data/photos/games-hub/7.png b/metadata_data/photos/games-hub/7.pngnew file mode 100644index 0000000000..9e91f949fdBinary files /dev/null and b/metadata_data/photos/games-hub/7.png differ