refactor: migrate package structure from fr.ajaury.gwenedeg to bzh.ajaury.chombev

This commit is contained in:
2026-07-07 18:58:17 +02:00
parent 272cefa5fd
commit 6361fa6e74
119 changed files with 370 additions and 376 deletions
@@ -0,0 +1,6 @@
package bzh.ajaury.chombev
import androidx.compose.ui.window.ComposeUIViewController
@Suppress("ktlint:standard:function-naming")
fun MainViewController() = ComposeUIViewController { App() }
@@ -0,0 +1,43 @@
package bzh.ajaury.chombev.web.ui
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.interop.UIKitView
import kotlinx.cinterop.ExperimentalForeignApi
import platform.CoreGraphics.CGRectZero
import platform.Foundation.NSURL
import platform.Foundation.NSURLRequest
import platform.UIKit.UIUserInterfaceStyle
import platform.UIKit.UIUserInterfaceStyle.UIUserInterfaceStyleDark
import platform.UIKit.UIUserInterfaceStyle.UIUserInterfaceStyleLight
import platform.WebKit.WKWebView
import platform.WebKit.WKWebViewConfiguration
@OptIn(ExperimentalForeignApi::class)
@Composable
actual fun PlatformWebView(
url: String,
darkTheme: Boolean,
modifier: Modifier,
) {
UIKitView(
modifier = modifier,
factory = {
WKWebView(
frame = CGRectZero.readValue(),
configuration = WKWebViewConfiguration(),
).apply {
setOverrideUserInterfaceStyle(darkTheme.toInterfaceStyle())
NSURL.URLWithString(url)?.let { nsUrl ->
loadRequest(NSURLRequest(uRL = nsUrl))
}
}
},
// Re-apply on recomposition so a light/dark switch takes effect without reloading the page.
update = { webView ->
webView.setOverrideUserInterfaceStyle(darkTheme.toInterfaceStyle())
},
)
}
private fun Boolean.toInterfaceStyle(): UIUserInterfaceStyle = if (this) UIUserInterfaceStyleDark else UIUserInterfaceStyleLight