Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ kotlin {
// implementation(project(":lib:chip-text-field"))

// webview
api(libs.compose.webview.multiplatform)
implementation(libs.wvbridge.core)

// https://coil-kt.github.io/coil/changelog/
implementation(dependencies.platform(libs.coil.bom))
Expand Down Expand Up @@ -208,6 +208,20 @@ kotlin {
val desktopMain by getting
desktopMain.dependencies {
implementation(compose.desktop.currentOs)
implementation(
when {
System.getProperty("os.name").startsWith("Windows") -> libs.wvbridge.platform.windows

System.getProperty("os.name").startsWith("Linux") -> libs.wvbridge.platform.linux

System.getProperty("os.name").startsWith("Mac") && System.getProperty("os.arch") in setOf("aarch64", "arm64") -> libs.wvbridge.platform.macos

else -> error(
"Unsupported desktop runtime for wvbridge: " +
"${System.getProperty("os.name")} ${System.getProperty("os.arch")}",
)
},
)
implementation(libs.kotlinx.coroutines.swing)
implementation(libs.ktor.client.okhttp)
implementation(libs.ktor.client.java)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
package top.kagg886.pmf.ui.route.login.v2

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import io.github.kdroidfilter.webview.web.WebView
import io.github.kdroidfilter.webview.web.WebViewNavigator
import io.github.kdroidfilter.webview.web.WebViewState
import top.kagg886.wvbridge.config.WebViewPlatformConfig

@Composable
internal actual fun WebviewPlatformInstall() {
}

@Composable
internal actual fun PlatformWebView(
state: WebViewState,
modifier: Modifier,
navigator: WebViewNavigator,
) = WebView(state, modifier, navigator)
actual fun defaultPlatformConfig(): WebViewPlatformConfig = WebViewPlatformConfig()
34 changes: 34 additions & 0 deletions composeApp/src/commonMain/kotlin/top/kagg886/pmf/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ import top.kagg886.pmf.util.initFileLogger
import top.kagg886.pmf.util.logger
import top.kagg886.pmf.util.stringResource
import top.kagg886.pmf.util.toColorScheme
import top.kagg886.wvbridge.util.LoggerReceiver

val LocalNavBackStack = compositionLocalOf<NavBackStack<NavKey>> {
error("not provided")
Expand Down Expand Up @@ -613,6 +614,39 @@ fun setupEnv() {
- Platform: $currentPlatform
""".trimIndent(),
)

LoggerReceiver.register { level, tag, message ->
// enum class Severity {
// Verbose,
// Debug,
// Info,
// Warn,
// Error,
// Assert,
// }

// public enum class Level {
// /** Detailed diagnostic output. */
// VERBOSE,
//
// /** Debug information useful during development. */
// DEBUG,
//
// /** General informational messages. */
// INFO,
//
// /** Potentially problematic state that does not stop execution. */
// WARN,
//
// /** Error state reported by the runtime. */
// ERROR,
//
// /** Assertion or unrecoverable failure state. */
// ASSERT
// }

co.touchlab.kermit.Logger.log(Severity.valueOf(level.name.lowercase().replaceFirstChar { it.uppercase() }), tag, null, message)
}
}

expect fun openBrowser(link: String)
Expand Down
Loading
Loading