From d139ee8e9838abd95798e362cc69df19a66afae2 Mon Sep 17 00:00:00 2001 From: Igor Demin Date: Fri, 20 Dec 2024 18:06:37 +0100 Subject: [PATCH] Restore commonMain to AOSP state (small fixes) https://youtrack.jetbrains.com/issue/CMP-3373 is no longer reproducible (code compiles) Restore to the last merged Material3 (1.4.0-alpha04) for code changed in https://youtrack.jetbrains.com/issue/CMP-3373 ## Testing - CI passes ## Release Notes N/A --- .../androidx/compose/material3/TimeFormat.kt | 10 ++------- .../androidx/compose/material3/TimePicker.kt | 12 ++--------- .../internal/SystemBarsDefaultInsets.kt | 8 ++----- .../compose/material3/TimeFormat.skiko.kt | 8 +++---- .../compose/material3/TimePicker.skiko.kt | 21 ++++++++++--------- .../internal/SystemBarsDefaultInsets.skiko.kt | 7 +++---- 6 files changed, 24 insertions(+), 42 deletions(-) diff --git a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/TimeFormat.kt b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/TimeFormat.kt index 79b908e708577..0bcfb7aac4807 100644 --- a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/TimeFormat.kt +++ b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/TimeFormat.kt @@ -19,11 +19,5 @@ package androidx.compose.material3 import androidx.compose.runtime.Composable import androidx.compose.runtime.ReadOnlyComposable -// TODO(https://github.com/JetBrains/compose-multiplatform/issues/3373) revert to expect get() -internal val is24HourFormat: Boolean - @Composable - @ReadOnlyComposable get() = is24HourFormat() - -@Composable -@ReadOnlyComposable -internal expect fun is24HourFormat(): Boolean +internal expect val is24HourFormat: Boolean + @Composable @ReadOnlyComposable get diff --git a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/TimePicker.kt b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/TimePicker.kt index 40b2727bf795c..04f568a97c02c 100644 --- a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/TimePicker.kt +++ b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/TimePicker.kt @@ -1984,16 +1984,8 @@ private enum class LayoutId { InnerCircle, } -// TODO(https://github.com/JetBrains/compose-multiplatform/issues/3373) fix expect composable getter -@OptIn(ExperimentalMaterial3Api::class) -internal val defaultTimePickerLayoutType: TimePickerLayoutType - @Composable - @ReadOnlyComposable get() = defaultTimePickerLayoutType() - -@Composable -@ReadOnlyComposable -@OptIn(ExperimentalMaterial3Api::class) -internal expect fun defaultTimePickerLayoutType() : TimePickerLayoutType +internal expect val defaultTimePickerLayoutType: TimePickerLayoutType + @Composable @ReadOnlyComposable get private const val FullCircle: Float = (PI * 2).toFloat() private const val HalfCircle: Float = FullCircle / 2f diff --git a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/internal/SystemBarsDefaultInsets.kt b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/internal/SystemBarsDefaultInsets.kt index cc6f184aee500..2824fae0c271f 100644 --- a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/internal/SystemBarsDefaultInsets.kt +++ b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/internal/SystemBarsDefaultInsets.kt @@ -19,9 +19,5 @@ package androidx.compose.material3.internal import androidx.compose.foundation.layout.WindowInsets import androidx.compose.runtime.Composable -// TODO(https://github.com/JetBrains/compose-multiplatform/issues/3373) revert to expect get() -internal val WindowInsets.Companion.systemBarsForVisualComponents: WindowInsets - @Composable get() = systemBarsForVisualComponents() - -@Composable -internal expect fun WindowInsets.Companion.systemBarsForVisualComponents(): WindowInsets \ No newline at end of file +internal expect val WindowInsets.Companion.systemBarsForVisualComponents: WindowInsets + @Composable get diff --git a/compose/material3/material3/src/skikoMain/kotlin/androidx/compose/material3/TimeFormat.skiko.kt b/compose/material3/material3/src/skikoMain/kotlin/androidx/compose/material3/TimeFormat.skiko.kt index 465ab6adff47c..d5a977fae2ece 100644 --- a/compose/material3/material3/src/skikoMain/kotlin/androidx/compose/material3/TimeFormat.skiko.kt +++ b/compose/material3/material3/src/skikoMain/kotlin/androidx/compose/material3/TimeFormat.skiko.kt @@ -20,7 +20,7 @@ import androidx.compose.material3.internal.PlatformDateFormat import androidx.compose.runtime.Composable import androidx.compose.runtime.ReadOnlyComposable -@Composable -@ReadOnlyComposable -internal actual fun is24HourFormat(): Boolean = - PlatformDateFormat(defaultLocale()).is24HourFormat() +internal actual val is24HourFormat + @Composable + @ReadOnlyComposable + get(): Boolean = PlatformDateFormat(defaultLocale()).is24HourFormat() diff --git a/compose/material3/material3/src/skikoMain/kotlin/androidx/compose/material3/TimePicker.skiko.kt b/compose/material3/material3/src/skikoMain/kotlin/androidx/compose/material3/TimePicker.skiko.kt index 8d6441f66ce8f..e59eef6e2395f 100644 --- a/compose/material3/material3/src/skikoMain/kotlin/androidx/compose/material3/TimePicker.skiko.kt +++ b/compose/material3/material3/src/skikoMain/kotlin/androidx/compose/material3/TimePicker.skiko.kt @@ -21,16 +21,17 @@ import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.platform.LocalWindowInfo -@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class) -@Composable -@ReadOnlyComposable -internal actual fun defaultTimePickerLayoutType(): TimePickerLayoutType { - return with(LocalWindowInfo.current) { - if (containerSize.height < containerSize.width) { - TimePickerLayoutType.Horizontal - } else { - TimePickerLayoutType.Vertical +internal actual val defaultTimePickerLayoutType + @OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class) + @Composable + @ReadOnlyComposable + get(): TimePickerLayoutType { + return with(LocalWindowInfo.current) { + if (containerSize.height < containerSize.width) { + TimePickerLayoutType.Horizontal + } else { + TimePickerLayoutType.Vertical + } } } -} diff --git a/compose/material3/material3/src/skikoMain/kotlin/androidx/compose/material3/internal/SystemBarsDefaultInsets.skiko.kt b/compose/material3/material3/src/skikoMain/kotlin/androidx/compose/material3/internal/SystemBarsDefaultInsets.skiko.kt index 7e6165c9aeccb..3783b11157d69 100644 --- a/compose/material3/material3/src/skikoMain/kotlin/androidx/compose/material3/internal/SystemBarsDefaultInsets.skiko.kt +++ b/compose/material3/material3/src/skikoMain/kotlin/androidx/compose/material3/internal/SystemBarsDefaultInsets.skiko.kt @@ -20,7 +20,6 @@ import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.systemBars import androidx.compose.runtime.Composable -// TODO upstream to commonMain -@Composable -internal actual fun WindowInsets.Companion.systemBarsForVisualComponents(): WindowInsets = - WindowInsets.systemBars +internal actual val WindowInsets.Companion.systemBarsForVisualComponents + @Composable + get(): WindowInsets = WindowInsets.systemBars