diff --git a/examples/imageviewer/android/build.gradle.kts b/examples/imageviewer/android/build.gradle.kts index f0a7bb5417..79c2704f42 100755 --- a/examples/imageviewer/android/build.gradle.kts +++ b/examples/imageviewer/android/build.gradle.kts @@ -22,4 +22,11 @@ android { dependencies { implementation(project(":common")) -} \ No newline at end of file + implementation("androidx.activity:activity-compose:1.3.0-alpha02") { + exclude(group = "androidx.compose.animation") + exclude(group = "androidx.compose.foundation") + exclude(group = "androidx.compose.material") + exclude(group = "androidx.compose.runtime") + exclude(group = "androidx.compose.ui") + } +} diff --git a/examples/imageviewer/android/src/main/java/imageviewer/MainActivity.kt b/examples/imageviewer/android/src/main/java/imageviewer/MainActivity.kt index 6f0dc3bdff..6b0f591109 100755 --- a/examples/imageviewer/android/src/main/java/imageviewer/MainActivity.kt +++ b/examples/imageviewer/android/src/main/java/imageviewer/MainActivity.kt @@ -2,7 +2,7 @@ package example.imageviewer import android.os.Bundle import androidx.appcompat.app.AppCompatActivity -import androidx.compose.ui.platform.setContent +import androidx.activity.compose.setContent import example.imageviewer.view.BuildAppUI import example.imageviewer.model.ContentState import example.imageviewer.model.ImageRepository diff --git a/examples/imageviewer/build.gradle.kts b/examples/imageviewer/build.gradle.kts index 70be1d66fa..1d9f83c87a 100755 --- a/examples/imageviewer/build.gradle.kts +++ b/examples/imageviewer/build.gradle.kts @@ -11,7 +11,7 @@ buildscript { dependencies { // __LATEST_COMPOSE_RELEASE_VERSION__ - classpath("org.jetbrains.compose:compose-gradle-plugin:0.3.0-build149") + classpath("org.jetbrains.compose:compose-gradle-plugin:0.3.0-build150") classpath("com.android.tools.build:gradle:4.0.1") // __KOTLIN_COMPOSE_VERSION__ classpath(kotlin("gradle-plugin", version = "1.4.30")) diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/style/Decoration.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/style/Decoration.kt index 841fac5596..8918ee2bc7 100755 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/style/Decoration.kt +++ b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/style/Decoration.kt @@ -1,38 +1,38 @@ package example.imageviewer.style import androidx.compose.runtime.Composable -import androidx.compose.ui.res.imageResource +import androidx.compose.ui.res.painterResource import example.imageviewer.common.R @Composable -fun icEmpty() = imageResource(R.raw.empty) +fun icEmpty() = painterResource(R.raw.empty) @Composable -fun icBack() = imageResource(R.raw.back) +fun icBack() = painterResource(R.raw.back) @Composable -fun icRefresh() = imageResource(R.raw.refresh) +fun icRefresh() = painterResource(R.raw.refresh) @Composable -fun icDots() = imageResource(R.raw.dots) +fun icDots() = painterResource(R.raw.dots) @Composable -fun icFilterGrayscaleOn() = imageResource(R.raw.grayscale_on) +fun icFilterGrayscaleOn() = painterResource(R.raw.grayscale_on) @Composable -fun icFilterGrayscaleOff() = imageResource(R.raw.grayscale_off) +fun icFilterGrayscaleOff() = painterResource(R.raw.grayscale_off) @Composable -fun icFilterPixelOn() = imageResource(R.raw.pixel_on) +fun icFilterPixelOn() = painterResource(R.raw.pixel_on) @Composable -fun icFilterPixelOff() = imageResource(R.raw.pixel_off) +fun icFilterPixelOff() = painterResource(R.raw.pixel_off) @Composable -fun icFilterBlurOn() = imageResource(R.raw.blur_on) +fun icFilterBlurOn() = painterResource(R.raw.blur_on) @Composable -fun icFilterBlurOff() = imageResource(R.raw.blur_off) +fun icFilterBlurOff() = painterResource(R.raw.blur_off) @Composable -fun icFilterUnknown() = imageResource(R.raw.filter_unknown) +fun icFilterUnknown() = painterResource(R.raw.filter_unknown) diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/FullImageScreen.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/FullImageScreen.kt index 1c6ac8dc2f..8da6e5dc3e 100755 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/FullImageScreen.kt +++ b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/FullImageScreen.kt @@ -3,8 +3,9 @@ package example.imageviewer.view import android.graphics.Bitmap import android.graphics.Rect import androidx.compose.foundation.Image -import androidx.compose.foundation.ScrollableRow import androidx.compose.foundation.background +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -25,6 +26,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.asImageBitmap +import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.unit.dp import example.imageviewer.core.FilterType @@ -85,7 +87,7 @@ fun setToolBar( text: String, content: ContentState ) { - + val scrollState = rememberScrollState() Surface(color = MiniatureColor, modifier = Modifier.preferredHeight(44.dp)) { Row(modifier = Modifier.padding(end = 30.dp)) { Surface( @@ -122,11 +124,9 @@ fun setToolBar( .align(Alignment.CenterVertically), shape = CircleShape ) { - ScrollableRow { - Row { - for (type in FilterType.values()) { - FilterButton(content, type) - } + Row(Modifier.horizontalScroll(scrollState)) { + for (type in FilterType.values()) { + FilterButton(content, type) } } } @@ -158,7 +158,7 @@ fun FilterButton( } @Composable -fun getFilterImage(type: FilterType, content: ContentState): ImageBitmap { +fun getFilterImage(type: FilterType, content: ContentState): Painter { return when (type) { FilterType.GrayScale -> if (content.isFilterEnabled(type)) icFilterGrayscaleOn() else icFilterGrayscaleOff() diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/MainScreen.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/MainScreen.kt index 49d740da3e..2989717f40 100755 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/MainScreen.kt +++ b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/MainScreen.kt @@ -1,8 +1,9 @@ package example.imageviewer.view import android.content.res.Configuration +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.Image -import androidx.compose.foundation.ScrollableColumn import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -28,6 +29,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.graphics.asImageBitmap +import androidx.compose.ui.graphics.painter.BitmapPainter import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.unit.dp import example.imageviewer.common.R @@ -145,7 +147,7 @@ fun setPreviewImageUI(content: ContentState) { if (content.isMainImageEmpty()) { icEmpty() } else { - content.getSelectedImage().asImageBitmap() + BitmapPainter(content.getSelectedImage().asImageBitmap()) }, contentDescription = null, modifier = Modifier @@ -223,18 +225,16 @@ fun setMiniatureUI( @Composable fun setScrollableArea(content: ContentState) { - - ScrollableColumn { - var index = 1 - Column { - for (picture in content.getMiniatures()) { - setMiniatureUI( - picture = picture, - content = content - ) - Spacer(modifier = Modifier.height(5.dp)) - index++ - } + var index = 1 + val scrollState = rememberScrollState() + Column(Modifier.verticalScroll(scrollState)) { + for (picture in content.getMiniatures()) { + setMiniatureUI( + picture = picture, + content = content + ) + Spacer(modifier = Modifier.height(5.dp)) + index++ } } } diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Clickable.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Clickable.kt index 11d760894d..8eae0782da 100755 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Clickable.kt +++ b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Clickable.kt @@ -1,7 +1,6 @@ package example.imageviewer.view import androidx.compose.runtime.Composable -import androidx.compose.runtime.emptyContent import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.ui.Modifier @@ -10,7 +9,7 @@ import androidx.compose.ui.Modifier fun Clickable( modifier: Modifier = Modifier, onClick: (() -> Unit)? = null, - children: @Composable () -> Unit = emptyContent() + children: @Composable () -> Unit = { } ) { Box( modifier = modifier.clickable { diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/utils/Application.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/utils/Application.kt index bfc0523890..a3c1236748 100644 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/utils/Application.kt +++ b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/utils/Application.kt @@ -11,7 +11,6 @@ import androidx.compose.runtime.ExperimentalComposeApi import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MonotonicFrameClock import androidx.compose.runtime.Recomposer -import androidx.compose.runtime.emptyContent import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -46,7 +45,7 @@ class ApplicationScope( private val scope = CoroutineScope(context) private val recomposer = Recomposer(context) - private val composition = Composition(Unit, EmptyApplier(), recomposer) + private val composition = Composition(EmptyApplier(), recomposer) private val windows = mutableSetOf() private var windowsVersion by mutableStateOf(Any()) @@ -89,7 +88,7 @@ class ApplicationScope( resizable: Boolean = true, events: WindowEvents = WindowEvents(), onDismissRequest: (() -> Unit)? = null, - content: @Composable () -> Unit = emptyContent() + content: @Composable () -> Unit = {} ) { var isOpened by remember { mutableStateOf(true) } if (isOpened) {