mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-04 01:09:05 +00:00
feat: Remove Sync Overview page and related functionality from settings
This commit is contained in:
parent
2510798092
commit
bbdf14d949
4 changed files with 26 additions and 169 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<List<SyncOverviewItem>>(emptyList()) }
|
||||
var isLoading by remember { mutableStateOf(true) }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
runCatching {
|
||||
val result = SupabaseProvider.client.postgrest.rpc("get_sync_overview")
|
||||
overviewItems = result.decodeList<SyncOverviewItem>()
|
||||
}.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,
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue