Browse Source

Merge remote-tracking branch 'origin/master' into support/1.5.0

# Conflicts:
#	examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/GalleryScreen.kt
pull/3564/head
Igor Demin 1 year ago
parent
commit
8427c25f1e
  1. 3
      CHANGELOG.md
  2. 13
      examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/CameraView.android.kt
  3. 25
      examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/GalleryScreen.android.kt
  4. 22
      examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/GalleryScreen.kt
  5. 48
      examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/GalleryScreen.desktop.kt
  6. 25
      examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/GalleryScreen.ios.kt
  7. 2
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatibility.kt
  8. 3
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt
  9. 2
      gradle-plugins/gradle.properties

3
CHANGELOG.md

@ -250,7 +250,8 @@ This version of Compose Multiplatform is based on the next Jetpack Compose libra
- [Implement `NativeStringDelegate`](https://github.com/JetBrains/compose-multiplatform/issues/2876)
### API Changes
- Resource management was reimplemented. Follow [the guide in the PR](https://github.com/JetBrains/compose-multiplatform/pull/3340) to support new feautures
- Resource management was reimplemented. Follow [the guide in the PR](https://github.com/JetBrains/compose-multiplatform/pull/3340) to support new features
- [`CADisableMinimumFrameDurationOnPhone` added to the template's `Info.plist` to support 120Hz](https://github.com/JetBrains/compose-multiplatform-ios-android-template/pull/17#issue-1714201779)
## Desktop

13
examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/CameraView.android.kt

@ -79,6 +79,7 @@ private fun CameraWithGrantedPermission(
val context = LocalContext.current
val lifecycleOwner = LocalLifecycleOwner.current
val viewScope = rememberCoroutineScope()
var cameraProvider: ProcessCameraProvider? by remember { mutableStateOf(null) }
val preview = Preview.Builder().build()
val previewView = remember { PreviewView(context) }
@ -96,16 +97,22 @@ private fun CameraWithGrantedPermission(
.build()
}
DisposableEffect(Unit) {
onDispose {
cameraProvider?.unbindAll()
}
}
LaunchedEffect(isFrontCamera) {
val cameraProvider = suspendCoroutine<ProcessCameraProvider> { continuation ->
cameraProvider = suspendCoroutine<ProcessCameraProvider> { continuation ->
ProcessCameraProvider.getInstance(context).also { cameraProvider ->
cameraProvider.addListener({
continuation.resume(cameraProvider.get())
}, executor)
}
}
cameraProvider.unbindAll()
cameraProvider.bindToLifecycle(
cameraProvider?.unbindAll()
cameraProvider?.bindToLifecycle(
lifecycleOwner,
cameraSelector,
preview,

25
examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/GalleryScreen.android.kt

@ -0,0 +1,25 @@
package example.imageviewer.view
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyGridScope
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@Composable
actual fun GalleryLazyVerticalGrid(
columns: GridCells,
modifier: Modifier,
verticalArrangement: Arrangement.Vertical,
horizontalArrangement: Arrangement.Horizontal,
content: LazyGridScope.() -> Unit
) {
LazyVerticalGrid(
columns = columns,
modifier = modifier,
verticalArrangement = verticalArrangement,
horizontalArrangement = horizontalArrangement,
content = content
)
}

22
examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/GalleryScreen.kt

@ -12,7 +12,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.LazyGridScope
import androidx.compose.foundation.lazy.grid.itemsIndexed
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.PagerState
@ -33,10 +33,13 @@ import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import example.imageviewer.*
import example.imageviewer.ExternalImageViewerEvent
import example.imageviewer.LocalImageProvider
import example.imageviewer.LocalInternalEvents
import example.imageviewer.LocalNotification
import example.imageviewer.icon.IconMenu
import example.imageviewer.icon.IconVisibility
import example.imageviewer.model.*
import example.imageviewer.model.PictureData
import example.imageviewer.style.ImageviewerColors
import kotlinx.coroutines.launch
import kotlin.math.absoluteValue
@ -178,6 +181,15 @@ fun GalleryScreen(
}
}
@Composable
expect fun GalleryLazyVerticalGrid(
columns: GridCells,
modifier: Modifier,
verticalArrangement: Arrangement.Vertical,
horizontalArrangement: Arrangement.Horizontal,
content: LazyGridScope.() -> Unit
)
@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun SquaresGalleryView(
@ -185,9 +197,9 @@ private fun SquaresGalleryView(
pagerState: PagerState,
onSelect: (index: Int) -> Unit,
) {
LazyVerticalGrid(
modifier = Modifier.padding(top = 4.dp).testTag("squaresGalleryView"),
GalleryLazyVerticalGrid(
columns = GridCells.Adaptive(minSize = 130.dp),
modifier = Modifier.padding(top = 4.dp).testTag("squaresGalleryView"),
verticalArrangement = Arrangement.spacedBy(1.dp),
horizontalArrangement = Arrangement.spacedBy(1.dp)
) {

48
examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/GalleryScreen.desktop.kt

@ -0,0 +1,48 @@
package example.imageviewer.view
import androidx.compose.foundation.VerticalScrollbar
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyGridScope
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.rememberLazyGridState
import androidx.compose.foundation.rememberScrollbarAdapter
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
// On the desktop, include a scrollbar
@Composable
actual fun GalleryLazyVerticalGrid(
columns: GridCells,
modifier: Modifier,
verticalArrangement: Arrangement.Vertical,
horizontalArrangement: Arrangement.Horizontal,
content: LazyGridScope.() -> Unit
) {
Box(
modifier = modifier
) {
val scrollState = rememberLazyGridState()
val adapter = rememberScrollbarAdapter(scrollState)
LazyVerticalGrid(
columns = columns,
modifier = Modifier.fillMaxSize(),
state = scrollState,
verticalArrangement = verticalArrangement,
horizontalArrangement = horizontalArrangement,
content = content
)
Box(
modifier = Modifier.matchParentSize()
){
VerticalScrollbar(
adapter = adapter,
modifier = Modifier.align(Alignment.CenterEnd),
)
}
}
}

25
examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/GalleryScreen.ios.kt

@ -0,0 +1,25 @@
package example.imageviewer.view
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyGridScope
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@Composable
actual fun GalleryLazyVerticalGrid(
columns: GridCells,
modifier: Modifier,
verticalArrangement: Arrangement.Vertical,
horizontalArrangement: Arrangement.Horizontal,
content: LazyGridScope.() -> Unit
) {
LazyVerticalGrid(
columns = columns,
modifier = modifier,
verticalArrangement = verticalArrangement,
horizontalArrangement = horizontalArrangement,
content = content
)
}

2
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatibility.kt

@ -14,7 +14,7 @@ internal object ComposeCompilerCompatibility {
"1.8.22" to "1.4.8",
"1.9.0-Beta" to "1.4.7.1-beta",
"1.9.0-RC" to "1.4.8-beta",
"1.9.0" to "1.5.1-rc01"
"1.9.0" to "1.5.1"
)
fun compilerVersionFor(kotlinVersion: String): String {

3
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt

@ -106,6 +106,7 @@ abstract class ComposePlugin : Plugin<Project> {
val runtime get() = composeDependency("org.jetbrains.compose.runtime:runtime")
val runtimeSaveable get() = composeDependency("org.jetbrains.compose.runtime:runtime-saveable")
val ui get() = composeDependency("org.jetbrains.compose.ui:ui")
@Deprecated("Use desktop.uiTestJUnit4", replaceWith = ReplaceWith("desktop.uiTestJUnit4"))
@ExperimentalComposeLibrary
val uiTestJUnit4 get() = composeDependency("org.jetbrains.compose.ui:ui-test-junit4")
val uiTooling get() = composeDependency("org.jetbrains.compose.ui:ui-tooling")
@ -127,6 +128,8 @@ abstract class ComposePlugin : Plugin<Project> {
val macos_x64 = composeDependency("org.jetbrains.compose.desktop:desktop-jvm-macos-x64")
val macos_arm64 = composeDependency("org.jetbrains.compose.desktop:desktop-jvm-macos-arm64")
val uiTestJUnit4 get() = composeDependency("org.jetbrains.compose.ui:ui-test-junit4")
val currentOs by lazy {
composeDependency("org.jetbrains.compose.desktop:desktop-jvm-${currentTarget.id}")
}

2
gradle-plugins/gradle.properties

@ -4,7 +4,7 @@ kotlin.code.style=official
# Default version of Compose Libraries used by Gradle plugin
compose.version=1.5.0
# The latest version of Compose Compiler used by Gradle plugin. Used only in tests/CI.
compose.tests.compiler.version=1.5.0
compose.tests.compiler.version=1.5.1
# The latest version of Kotlin compatible with compose.tests.compiler.version. Used only in tests/CI.
compose.tests.compiler.compatible.kotlin.version=1.9.0
# The latest version of Kotlin compatible with compose.tests.compiler.version for JS target. Used only on CI.

Loading…
Cancel
Save