diff --git a/experimental/examples/imageviewer/gradle.properties b/experimental/examples/imageviewer/gradle.properties index 02949c20fd..5f0e0ae985 100644 --- a/experimental/examples/imageviewer/gradle.properties +++ b/experimental/examples/imageviewer/gradle.properties @@ -13,5 +13,5 @@ kotlin.native.useEmbeddableCompilerJar=true kotlin.native.binary.memoryModel=experimental kotlin.version=1.8.0 agp.version=7.1.3 -compose.version=1.4.0-alpha01-dev954 +compose.version=1.4.0-alpha01-dev968 ktor.version=2.2.1 diff --git a/experimental/examples/imageviewer/iosApp/iosApp/ContentView.swift b/experimental/examples/imageviewer/iosApp/iosApp/ContentView.swift index cb37889ef6..89d0d1ad0c 100644 --- a/experimental/examples/imageviewer/iosApp/iosApp/ContentView.swift +++ b/experimental/examples/imageviewer/iosApp/iosApp/ContentView.swift @@ -15,7 +15,9 @@ let gradient = LinearGradient( struct ComposeView: UIViewControllerRepresentable { func makeUIViewController(context: Context) -> UIViewController { - Main_iosKt.MainViewController() + let controller = Main_iosKt.MainViewController() + controller.overrideUserInterfaceStyle = .light + return controller } func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} diff --git a/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/LocationVisualizer.android.kt b/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/LocationVisualizer.android.kt new file mode 100644 index 0000000000..fd73ffc822 --- /dev/null +++ b/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/LocationVisualizer.android.kt @@ -0,0 +1,19 @@ +package example.imageviewer.view + +import androidx.compose.foundation.Image +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.ContentScale +import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.painterResource + +@OptIn(ExperimentalResourceApi::class) +@Composable +internal actual fun LocationVisualizer(modifier: Modifier) { + Image( + painter = painterResource("dummy_map.png"), + contentDescription = "Map", + contentScale = ContentScale.Crop, + modifier = modifier + ) +} diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/LocationVisualizer.common.kt b/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/LocationVisualizer.common.kt new file mode 100644 index 0000000000..b780d6fe00 --- /dev/null +++ b/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/LocationVisualizer.common.kt @@ -0,0 +1,7 @@ +package example.imageviewer.view + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier + +@Composable +internal expect fun LocationVisualizer(modifier: Modifier) \ No newline at end of file diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/MemoryScreen.kt b/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/MemoryScreen.kt index 1efb43dada..09a8d04926 100644 --- a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/MemoryScreen.kt +++ b/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/MemoryScreen.kt @@ -3,15 +3,12 @@ package example.imageviewer.view import androidx.compose.animation.animateContentSize import androidx.compose.animation.core.Spring import androidx.compose.animation.core.spring -import androidx.compose.foundation.Image -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable +import androidx.compose.foundation.* import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.foundation.verticalScroll import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment @@ -70,7 +67,14 @@ internal fun MemoryScreen( Box(modifier = Modifier.background(MaterialTheme.colorScheme.background)) { Column { Headliner("Place") - LocationVisualizer() + val locationShape = RoundedCornerShape(10.dp) + LocationVisualizer( + Modifier.padding(horizontal = 12.dp) + .clip(locationShape) + .border(1.dp, Color.Gray, locationShape) + .fillMaxWidth() + .height(200.dp) + ) Headliner("Note") Collapsible( """ @@ -201,17 +205,6 @@ internal fun Headliner(s: String) { ) } -@OptIn(ExperimentalResourceApi::class) -@Composable -internal fun LocationVisualizer() { - Image( - painterResource("dummy_map.png"), - "Map", - contentScale = ContentScale.Crop, - modifier = Modifier.fillMaxWidth().height(200.dp) - ) -} - @Composable internal fun RelatedMemoriesVisualizer( ps: List, diff --git a/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/LocationVisualizer.desktop.kt b/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/LocationVisualizer.desktop.kt new file mode 100644 index 0000000000..fd73ffc822 --- /dev/null +++ b/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/LocationVisualizer.desktop.kt @@ -0,0 +1,19 @@ +package example.imageviewer.view + +import androidx.compose.foundation.Image +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.ContentScale +import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.painterResource + +@OptIn(ExperimentalResourceApi::class) +@Composable +internal actual fun LocationVisualizer(modifier: Modifier) { + Image( + painter = painterResource("dummy_map.png"), + contentDescription = "Map", + contentScale = ContentScale.Crop, + modifier = modifier + ) +} diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/LocationVisualizer.ios.kt b/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/LocationVisualizer.ios.kt new file mode 100644 index 0000000000..93add685f2 --- /dev/null +++ b/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/LocationVisualizer.ios.kt @@ -0,0 +1,30 @@ +package example.imageviewer.view + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.interop.UIKitInteropView +import platform.CoreLocation.CLLocationCoordinate2DMake +import platform.MapKit.MKCoordinateRegionMakeWithDistance +import platform.MapKit.MKMapView +import platform.MapKit.MKPointAnnotation + +@Composable +internal actual fun LocationVisualizer(modifier: Modifier) { + //todo get real geo coordinates + UIKitInteropView( + modifier = modifier, + factory = { + val mkMapView = MKMapView() + val cityAmsterdam = CLLocationCoordinate2DMake(52.3676, 4.9041) + mkMapView.setRegion( + MKCoordinateRegionMakeWithDistance( + centerCoordinate = cityAmsterdam, + 5000.0, 5000.0 + ), + animated = false + ) + mkMapView.addAnnotation(MKPointAnnotation(cityAmsterdam, title = null, subtitle = null)) + mkMapView + }, + ) +}