Skip to content

Commit

Permalink
add webview to Extension detail screen
Browse files Browse the repository at this point in the history
  • Loading branch information
cuong-tran committed Jan 8, 2025
1 parent 1399f15 commit 37ac075
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.Launch
import androidx.compose.material.icons.outlined.Public
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
Expand Down Expand Up @@ -68,6 +69,9 @@ fun ExtensionDetailsScreen(
navigateUp: () -> Unit,
state: ExtensionDetailsScreenModel.State,
onClickSourcePreferences: (sourceId: Long) -> Unit,
// KMK -->
onOpenWebView: (() -> Unit)?,
// KMK <--
onClickEnableAll: () -> Unit,
onClickDisableAll: () -> Unit,
onClickClearCookies: () -> Unit,
Expand All @@ -94,6 +98,15 @@ fun ExtensionDetailsScreen(
AppBarActions(
actions = persistentListOf<AppBar.AppBarAction>().builder()
.apply {
if (onOpenWebView != null) {
add(
AppBar.Action(
title = stringResource(MR.strings.action_open_in_web_view),
icon = Icons.Outlined.Public,
onClick = onOpenWebView,
),
)
}
if (url != null) {
add(
AppBar.Action(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.currentOrThrow
import eu.kanade.presentation.browse.ExtensionDetailsScreen
import eu.kanade.presentation.util.Screen
import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.ui.webview.WebViewScreen
import kotlinx.coroutines.flow.collectLatest
import tachiyomi.presentation.core.screens.LoadingScreen

Expand All @@ -29,11 +31,29 @@ data class ExtensionDetailsScreen(
}

val navigator = LocalNavigator.currentOrThrow
// KMK -->
val source = state.extension?.sources?.getOrNull(0)
// KMK <--

ExtensionDetailsScreen(
navigateUp = navigator::pop,
state = state,
onClickSourcePreferences = { navigator.push(SourcePreferencesScreen(it)) },
// KMK -->
onOpenWebView = if (source != null && source is HttpSource) {
{
navigator.push(
WebViewScreen(
url = source.baseUrl,
initialTitle = source.name,
sourceId = source.id,
),
)
}
} else {
null
},
// KMK <--
onClickEnableAll = { screenModel.toggleSources(true) },
onClickDisableAll = { screenModel.toggleSources(false) },
onClickClearCookies = screenModel::clearCookies,
Expand Down

0 comments on commit 37ac075

Please sign in to comment.