mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-16 23:12:12 +00:00
Update App.kt
This commit is contained in:
parent
89c61662a4
commit
82c185ca60
1 changed files with 467 additions and 436 deletions
|
|
@ -114,6 +114,7 @@ import com.nuvio.app.features.library.LibrarySection
|
||||||
import com.nuvio.app.features.library.LibrarySourceMode
|
import com.nuvio.app.features.library.LibrarySourceMode
|
||||||
import com.nuvio.app.features.library.LibraryScreen
|
import com.nuvio.app.features.library.LibraryScreen
|
||||||
import com.nuvio.app.features.library.toLibraryItem
|
import com.nuvio.app.features.library.toLibraryItem
|
||||||
|
import com.nuvio.app.features.library.toMetaPreview
|
||||||
import com.nuvio.app.features.notifications.EpisodeReleaseNotificationsRepository
|
import com.nuvio.app.features.notifications.EpisodeReleaseNotificationsRepository
|
||||||
import com.nuvio.app.features.player.PlayerLaunch
|
import com.nuvio.app.features.player.PlayerLaunch
|
||||||
import com.nuvio.app.features.player.PlayerLaunchStore
|
import com.nuvio.app.features.player.PlayerLaunchStore
|
||||||
|
|
@ -945,6 +946,10 @@ private fun MainAppContent(
|
||||||
onLibraryPosterClick = { item ->
|
onLibraryPosterClick = { item ->
|
||||||
navController.navigate(DetailRoute(type = item.type, id = item.id))
|
navController.navigate(DetailRoute(type = item.type, id = item.id))
|
||||||
},
|
},
|
||||||
|
onLibraryPosterLongClick = { item ->
|
||||||
|
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||||
|
selectedPosterForActions = item.toMetaPreview() // reuse existing sheet
|
||||||
|
},
|
||||||
onLibrarySectionViewAllClick = onLibrarySectionViewAllClick,
|
onLibrarySectionViewAllClick = onLibrarySectionViewAllClick,
|
||||||
onContinueWatchingClick = onContinueWatchingClick,
|
onContinueWatchingClick = onContinueWatchingClick,
|
||||||
onContinueWatchingLongPress = onContinueWatchingLongPress,
|
onContinueWatchingLongPress = onContinueWatchingLongPress,
|
||||||
|
|
@ -1646,6 +1651,30 @@ private fun MainAppContent(
|
||||||
if (!isTraktConnected) {
|
if (!isTraktConnected) {
|
||||||
LibraryRepository.toggleSaved(libraryItem)
|
LibraryRepository.toggleSaved(libraryItem)
|
||||||
} else {
|
} else {
|
||||||
|
// Tap = directly toggle watchlist (first tab)
|
||||||
|
coroutineScope.launch {
|
||||||
|
runCatching {
|
||||||
|
val snapshot = LibraryRepository.getMembershipSnapshot(libraryItem)
|
||||||
|
val tabs = LibraryRepository.traktListTabs()
|
||||||
|
val watchlistKey = tabs.firstOrNull()?.key
|
||||||
|
if (watchlistKey != null) {
|
||||||
|
val currentlyIn = snapshot[watchlistKey] == true
|
||||||
|
val desired = tabs.associate { tab ->
|
||||||
|
tab.key to if (tab.key == watchlistKey) !currentlyIn else (snapshot[tab.key] == true)
|
||||||
|
}
|
||||||
|
LibraryRepository.applyMembershipChanges(libraryItem, desired)
|
||||||
|
}
|
||||||
|
}.onFailure {
|
||||||
|
LibraryRepository.toggleSaved(libraryItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onOpenListPicker = if (isTraktConnected) {
|
||||||
|
{
|
||||||
|
selectedPosterForActions?.let { preview ->
|
||||||
|
val libraryItem = preview.toLibraryItem(savedAtEpochMs = 0L)
|
||||||
pickerItem = libraryItem
|
pickerItem = libraryItem
|
||||||
pickerTitle = preview.name
|
pickerTitle = preview.name
|
||||||
pickerTabs = LibraryRepository.traktListTabs()
|
pickerTabs = LibraryRepository.traktListTabs()
|
||||||
|
|
@ -1668,7 +1697,7 @@ private fun MainAppContent(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
} else null,
|
||||||
onToggleWatched = {
|
onToggleWatched = {
|
||||||
selectedPosterForActions?.let { preview ->
|
selectedPosterForActions?.let { preview ->
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
|
|
@ -1864,6 +1893,7 @@ private fun AppTabHost(
|
||||||
onCollectionsSettingsClick: () -> Unit = {},
|
onCollectionsSettingsClick: () -> Unit = {},
|
||||||
onFolderClick: ((collectionId: String, folderId: String) -> Unit)? = null,
|
onFolderClick: ((collectionId: String, folderId: String) -> Unit)? = null,
|
||||||
onInitialHomeContentRendered: () -> Unit = {},
|
onInitialHomeContentRendered: () -> Unit = {},
|
||||||
|
onLibraryPosterLongClick: ((LibraryItem) -> Unit)? = null,
|
||||||
) {
|
) {
|
||||||
val tabStateHolder = rememberSaveableStateHolder()
|
val tabStateHolder = rememberSaveableStateHolder()
|
||||||
|
|
||||||
|
|
@ -1895,6 +1925,7 @@ private fun AppTabHost(
|
||||||
LibraryScreen(
|
LibraryScreen(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
onPosterClick = onLibraryPosterClick,
|
onPosterClick = onLibraryPosterClick,
|
||||||
|
onPosterLongClick = onLibraryPosterLongClick,
|
||||||
onSectionViewAllClick = onLibrarySectionViewAllClick,
|
onSectionViewAllClick = onLibrarySectionViewAllClick,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue