From bbdf14d94956eb6e50b20920b042a632362877ef Mon Sep 17 00:00:00 2001 From: tapframe <85391825+tapframe@users.noreply.github.com> Date: Sat, 28 Mar 2026 20:39:18 +0530 Subject: [PATCH] feat: Remove Sync Overview page and related functionality from settings --- .../app/features/settings/SettingsModels.kt | 2 - .../app/features/settings/SettingsRootPage.kt | 62 ++++----- .../app/features/settings/SettingsScreen.kt | 8 -- .../app/features/settings/SyncOverviewPage.kt | 123 ------------------ 4 files changed, 26 insertions(+), 169 deletions(-) delete mode 100644 composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SyncOverviewPage.kt diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SettingsModels.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SettingsModels.kt index c473dcf0..cd134c76 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SettingsModels.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SettingsModels.kt @@ -24,7 +24,6 @@ internal enum class SettingsPage( Addons("Addons"), Homescreen("Homescreen"), Account("Account"), - SyncOverview("Sync Overview"), } internal fun SettingsPage.previousPage(): SettingsPage? = @@ -37,5 +36,4 @@ internal fun SettingsPage.previousPage(): SettingsPage? = SettingsPage.Addons -> SettingsPage.ContentDiscovery SettingsPage.Homescreen -> SettingsPage.ContentDiscovery SettingsPage.Account -> SettingsPage.Root - SettingsPage.SyncOverview -> SettingsPage.Root } diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SettingsRootPage.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SettingsRootPage.kt index 547c674d..bce2c56f 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SettingsRootPage.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SettingsRootPage.kt @@ -7,7 +7,6 @@ import androidx.compose.material.icons.rounded.Extension import androidx.compose.material.icons.rounded.Palette import androidx.compose.material.icons.rounded.People import androidx.compose.material.icons.rounded.PlayArrow -import androidx.compose.material.icons.rounded.Sync internal fun LazyListScope.settingsRootContent( isTablet: Boolean, @@ -15,9 +14,34 @@ internal fun LazyListScope.settingsRootContent( onAppearanceClick: () -> Unit, onContentDiscoveryClick: () -> Unit, onAccountClick: () -> Unit, - onSyncOverviewClick: () -> Unit, onSwitchProfileClick: (() -> Unit)? = null, ) { + item { + SettingsSection( + title = "ACCOUNT", + isTablet = isTablet, + ) { + SettingsGroup(isTablet = isTablet) { + if (onSwitchProfileClick != null) { + SettingsNavigationRow( + title = "Switch Profile", + description = "Change to a different profile.", + icon = Icons.Rounded.People, + isTablet = isTablet, + onClick = onSwitchProfileClick, + ) + SettingsGroupDivider(isTablet = isTablet) + } + SettingsNavigationRow( + title = "Account", + description = "Manage your account, sign out, or delete.", + icon = Icons.Rounded.AccountCircle, + isTablet = isTablet, + onClick = onAccountClick, + ) + } + } + } item { SettingsSection( title = "GENERAL", @@ -50,38 +74,4 @@ internal fun LazyListScope.settingsRootContent( } } } - item { - SettingsSection( - title = "ACCOUNT & SYNC", - isTablet = isTablet, - ) { - SettingsGroup(isTablet = isTablet) { - if (onSwitchProfileClick != null) { - SettingsNavigationRow( - title = "Switch Profile", - description = "Change to a different profile.", - icon = Icons.Rounded.People, - isTablet = isTablet, - onClick = onSwitchProfileClick, - ) - SettingsGroupDivider(isTablet = isTablet) - } - SettingsNavigationRow( - title = "Account", - description = "Manage your account, sign out, or delete.", - icon = Icons.Rounded.AccountCircle, - isTablet = isTablet, - onClick = onAccountClick, - ) - SettingsGroupDivider(isTablet = isTablet) - SettingsNavigationRow( - title = "Sync Overview", - description = "View synced data counts per profile.", - icon = Icons.Rounded.Sync, - isTablet = isTablet, - onClick = onSyncOverviewClick, - ) - } - } - } } diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SettingsScreen.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SettingsScreen.kt index ecd44cb1..93f13eb9 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SettingsScreen.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SettingsScreen.kt @@ -134,7 +134,6 @@ private fun MobileSettingsScreen( onAppearanceClick = { onPageChange(SettingsPage.Appearance) }, onContentDiscoveryClick = { onPageChange(SettingsPage.ContentDiscovery) }, onAccountClick = { onPageChange(SettingsPage.Account) }, - onSyncOverviewClick = { onPageChange(SettingsPage.SyncOverview) }, onSwitchProfileClick = onSwitchProfile, ) SettingsPage.Playback -> playbackSettingsContent( @@ -164,9 +163,6 @@ private fun MobileSettingsScreen( SettingsPage.Account -> accountSettingsContent( isTablet = false, ) - SettingsPage.SyncOverview -> syncOverviewContent( - isTablet = false, - ) } } } @@ -247,7 +243,6 @@ private fun TabletSettingsScreen( onAppearanceClick = { onPageChange(SettingsPage.Appearance) }, onContentDiscoveryClick = { onPageChange(SettingsPage.ContentDiscovery) }, onAccountClick = { onPageChange(SettingsPage.Account) }, - onSyncOverviewClick = { onPageChange(SettingsPage.SyncOverview) }, onSwitchProfileClick = onSwitchProfile, ) SettingsPage.Playback -> playbackSettingsContent( @@ -277,9 +272,6 @@ private fun TabletSettingsScreen( SettingsPage.Account -> accountSettingsContent( isTablet = true, ) - SettingsPage.SyncOverview -> syncOverviewContent( - isTablet = true, - ) } } } diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SyncOverviewPage.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SyncOverviewPage.kt deleted file mode 100644 index 3d4de50e..00000000 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/SyncOverviewPage.kt +++ /dev/null @@ -1,123 +0,0 @@ -package com.nuvio.app.features.settings - -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.lazy.LazyListScope -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -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.text.font.FontWeight -import androidx.compose.ui.unit.dp -import co.touchlab.kermit.Logger -import com.nuvio.app.core.network.SupabaseProvider -import com.nuvio.app.core.ui.NuvioSurfaceCard -import io.github.jan.supabase.postgrest.postgrest -import io.github.jan.supabase.postgrest.rpc -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -private data class SyncOverviewItem( - @SerialName("profile_name") val profileName: String = "", - @SerialName("profile_index") val profileIndex: Int = 0, - @SerialName("addon_count") val addonCount: Int = 0, - @SerialName("library_count") val libraryCount: Int = 0, - @SerialName("watch_progress_count") val watchProgressCount: Int = 0, - @SerialName("watched_count") val watchedCount: Int = 0, -) - -internal fun LazyListScope.syncOverviewContent( - isTablet: Boolean, -) { - item { - SyncOverviewCards(isTablet = isTablet) - } -} - -@Composable -private fun SyncOverviewCards(isTablet: Boolean) { - val log = remember { Logger.withTag("SyncOverview") } - var overviewItems by remember { mutableStateOf>(emptyList()) } - var isLoading by remember { mutableStateOf(true) } - - LaunchedEffect(Unit) { - runCatching { - val result = SupabaseProvider.client.postgrest.rpc("get_sync_overview") - overviewItems = result.decodeList() - }.onFailure { e -> - log.e(e) { "Failed to fetch sync overview" } - } - isLoading = false - } - - Column(verticalArrangement = Arrangement.spacedBy(12.dp)) { - if (isLoading) { - NuvioSurfaceCard { - Text( - text = "Loading sync data...", - style = MaterialTheme.typography.bodyLarge, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - } - } else if (overviewItems.isEmpty()) { - NuvioSurfaceCard { - Text( - text = "No sync data available. Sign in with an account to enable cloud sync.", - style = MaterialTheme.typography.bodyLarge, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - } - } else { - overviewItems.sortedBy { it.profileIndex }.forEach { item -> - NuvioSurfaceCard { - Text( - text = item.profileName.ifBlank { "Profile ${item.profileIndex}" }, - style = MaterialTheme.typography.titleLarge, - color = MaterialTheme.colorScheme.onSurface, - fontWeight = FontWeight.SemiBold, - ) - Spacer(modifier = Modifier.height(14.dp)) - SyncStatRow("Library Items", item.libraryCount) - Spacer(modifier = Modifier.height(8.dp)) - SyncStatRow("Watch Progress", item.watchProgressCount) - Spacer(modifier = Modifier.height(8.dp)) - SyncStatRow("Watched Items", item.watchedCount) - Spacer(modifier = Modifier.height(8.dp)) - SyncStatRow("Addons", item.addonCount) - } - } - } - } -} - -@Composable -private fun SyncStatRow(label: String, count: Int) { - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - ) { - Text( - text = label, - style = MaterialTheme.typography.bodyLarge, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - Text( - text = count.toString(), - style = MaterialTheme.typography.titleMedium, - color = MaterialTheme.colorScheme.primary, - fontWeight = FontWeight.Bold, - ) - } -}