diff --git a/MULTIPLATFORM.md b/MULTIPLATFORM.md index ee1bf1aa11236..62ae2bd6973cd 100644 --- a/MULTIPLATFORM.md +++ b/MULTIPLATFORM.md @@ -71,7 +71,7 @@ Compose Multiplatform core libraries can be published to local Maven with the fo The default value for the version is `0.0.0-SNAPSHOT` And library groups: -`-Pjetbrains.publication.libraries=CORE_BUNDLE,COMPOSE,LIFECYCLE,NAVIGATION,SAVEDSTATE` +`-Pjetbrains.publication.libraries=CORE_BUNDLE,COMPOSE,LIFECYCLE,NAVIGATION,SAVEDSTATE,WINDOW` The default value includes all libraries. diff --git a/compose/material3/adaptive/adaptive-layout/api/desktop/adaptive-layout.api b/compose/material3/adaptive/adaptive-layout/api/desktop/adaptive-layout.api new file mode 100644 index 0000000000000..7edfecf0f45f1 --- /dev/null +++ b/compose/material3/adaptive/adaptive-layout/api/desktop/adaptive-layout.api @@ -0,0 +1,180 @@ +public abstract interface class androidx/compose/material3/adaptive/layout/AdaptStrategy { + public static final field Companion Landroidx/compose/material3/adaptive/layout/AdaptStrategy$Companion; + public abstract fun adapt-z8rX67Q ()Ljava/lang/String; +} + +public final class androidx/compose/material3/adaptive/layout/AdaptStrategy$Companion { + public final fun getHide ()Landroidx/compose/material3/adaptive/layout/AdaptStrategy; +} + +public abstract interface class androidx/compose/material3/adaptive/layout/AnimatedPaneScope : androidx/compose/animation/AnimatedVisibilityScope { +} + +public final class androidx/compose/material3/adaptive/layout/HingePolicy { + public static final field Companion Landroidx/compose/material3/adaptive/layout/HingePolicy$Companion; + public static final synthetic fun box-impl (I)Landroidx/compose/material3/adaptive/layout/HingePolicy; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (ILjava/lang/Object;)Z + public static final fun equals-impl0 (II)Z + public fun hashCode ()I + public static fun hashCode-impl (I)I + public fun toString ()Ljava/lang/String; + public static fun toString-impl (I)Ljava/lang/String; + public final synthetic fun unbox-impl ()I +} + +public final class androidx/compose/material3/adaptive/layout/HingePolicy$Companion { + public final fun getAlwaysAvoid-u6eov6g ()I + public final fun getAvoidOccluding-u6eov6g ()I + public final fun getAvoidSeparating-u6eov6g ()I + public final fun getNeverAvoid-u6eov6g ()I +} + +public final class androidx/compose/material3/adaptive/layout/ListDetailPaneScaffoldDefaults { + public static final field $stable I + public static final field INSTANCE Landroidx/compose/material3/adaptive/layout/ListDetailPaneScaffoldDefaults; + public final fun adaptStrategies (Landroidx/compose/material3/adaptive/layout/AdaptStrategy;Landroidx/compose/material3/adaptive/layout/AdaptStrategy;Landroidx/compose/material3/adaptive/layout/AdaptStrategy;)Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldAdaptStrategies; + public static synthetic fun adaptStrategies$default (Landroidx/compose/material3/adaptive/layout/ListDetailPaneScaffoldDefaults;Landroidx/compose/material3/adaptive/layout/AdaptStrategy;Landroidx/compose/material3/adaptive/layout/AdaptStrategy;Landroidx/compose/material3/adaptive/layout/AdaptStrategy;ILjava/lang/Object;)Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldAdaptStrategies; +} + +public final class androidx/compose/material3/adaptive/layout/ListDetailPaneScaffoldKt { + public static final fun ListDetailPaneScaffold (Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective;Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldValue;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V +} + +public final class androidx/compose/material3/adaptive/layout/ListDetailPaneScaffoldRole { + public static final field $stable I + public static final field INSTANCE Landroidx/compose/material3/adaptive/layout/ListDetailPaneScaffoldRole; + public final fun getDetail ()Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole; + public final fun getExtra ()Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole; + public final fun getList ()Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole; +} + +public final class androidx/compose/material3/adaptive/layout/PaneAdaptedValue { + public static final field Companion Landroidx/compose/material3/adaptive/layout/PaneAdaptedValue$Companion; + public static final synthetic fun box-impl (Ljava/lang/String;)Landroidx/compose/material3/adaptive/layout/PaneAdaptedValue; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Ljava/lang/String;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Ljava/lang/String;Ljava/lang/String;)Z + public fun hashCode ()I + public static fun hashCode-impl (Ljava/lang/String;)I + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Ljava/lang/String;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Ljava/lang/String; +} + +public final class androidx/compose/material3/adaptive/layout/PaneAdaptedValue$Companion { + public final fun getExpanded-z8rX67Q ()Ljava/lang/String; + public final fun getHidden-z8rX67Q ()Ljava/lang/String; +} + +public final class androidx/compose/material3/adaptive/layout/PaneKt { + public static final fun AnimatedPane (Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldScope;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V +} + +public final class androidx/compose/material3/adaptive/layout/PaneScaffoldDirective { + public static final field $stable I + public static final field Companion Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective$Companion; + public synthetic fun (IFIFFLjava/util/List;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun copy-7PwrCCA (IFIFFLjava/util/List;)Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective; + public static synthetic fun copy-7PwrCCA$default (Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective;IFIFFLjava/util/List;ILjava/lang/Object;)Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective; + public fun equals (Ljava/lang/Object;)Z + public final fun getDefaultPanePreferredWidth-D9Ej5fM ()F + public final fun getExcludedBounds ()Ljava/util/List; + public final fun getHorizontalPartitionSpacerSize-D9Ej5fM ()F + public final fun getMaxHorizontalPartitions ()I + public final fun getMaxVerticalPartitions ()I + public final fun getVerticalPartitionSpacerSize-D9Ej5fM ()F + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class androidx/compose/material3/adaptive/layout/PaneScaffoldDirective$Companion { + public final fun getDefault ()Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective; +} + +public final class androidx/compose/material3/adaptive/layout/PaneScaffoldDirectiveKt { + public static final fun calculatePaneScaffoldDirective-A-ymEG0 (Landroidx/compose/material3/adaptive/WindowAdaptiveInfo;I)Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective; + public static synthetic fun calculatePaneScaffoldDirective-A-ymEG0$default (Landroidx/compose/material3/adaptive/WindowAdaptiveInfo;IILjava/lang/Object;)Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective; + public static final fun calculatePaneScaffoldDirectiveWithTwoPanesOnMediumWidth-A-ymEG0 (Landroidx/compose/material3/adaptive/WindowAdaptiveInfo;I)Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective; + public static synthetic fun calculatePaneScaffoldDirectiveWithTwoPanesOnMediumWidth-A-ymEG0$default (Landroidx/compose/material3/adaptive/WindowAdaptiveInfo;IILjava/lang/Object;)Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective; +} + +public abstract interface class androidx/compose/material3/adaptive/layout/PaneScaffoldScope { + public abstract fun preferredWidth-3ABfNKs (Landroidx/compose/ui/Modifier;F)Landroidx/compose/ui/Modifier; +} + +public final class androidx/compose/material3/adaptive/layout/SupportingPaneScaffoldDefaults { + public static final field $stable I + public static final field INSTANCE Landroidx/compose/material3/adaptive/layout/SupportingPaneScaffoldDefaults; + public final fun adaptStrategies (Landroidx/compose/material3/adaptive/layout/AdaptStrategy;Landroidx/compose/material3/adaptive/layout/AdaptStrategy;Landroidx/compose/material3/adaptive/layout/AdaptStrategy;)Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldAdaptStrategies; + public static synthetic fun adaptStrategies$default (Landroidx/compose/material3/adaptive/layout/SupportingPaneScaffoldDefaults;Landroidx/compose/material3/adaptive/layout/AdaptStrategy;Landroidx/compose/material3/adaptive/layout/AdaptStrategy;Landroidx/compose/material3/adaptive/layout/AdaptStrategy;ILjava/lang/Object;)Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldAdaptStrategies; +} + +public final class androidx/compose/material3/adaptive/layout/SupportingPaneScaffoldKt { + public static final fun SupportingPaneScaffold (Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective;Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldValue;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V +} + +public final class androidx/compose/material3/adaptive/layout/SupportingPaneScaffoldRole { + public static final field $stable I + public static final field INSTANCE Landroidx/compose/material3/adaptive/layout/SupportingPaneScaffoldRole; + public final fun getExtra ()Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole; + public final fun getMain ()Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole; + public final fun getSupporting ()Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole; +} + +public final class androidx/compose/material3/adaptive/layout/ThreePaneScaffoldAdaptStrategies { + public static final field $stable I + public fun (Landroidx/compose/material3/adaptive/layout/AdaptStrategy;Landroidx/compose/material3/adaptive/layout/AdaptStrategy;Landroidx/compose/material3/adaptive/layout/AdaptStrategy;)V + public fun equals (Ljava/lang/Object;)Z + public final fun get (Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole;)Landroidx/compose/material3/adaptive/layout/AdaptStrategy; + public fun hashCode ()I +} + +public final class androidx/compose/material3/adaptive/layout/ThreePaneScaffoldDestinationItem { + public static final field $stable I + public fun (Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole;Ljava/lang/Object;)V + public synthetic fun (Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole;Ljava/lang/Object;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun equals (Ljava/lang/Object;)Z + public final fun getContent ()Ljava/lang/Object; + public final fun getPane ()Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class androidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole : java/lang/Enum { + public static final field Primary Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole; + public static final field Secondary Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole; + public static final field Tertiary Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole; + public static fun values ()[Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole; +} + +public abstract interface class androidx/compose/material3/adaptive/layout/ThreePaneScaffoldScope : androidx/compose/material3/adaptive/layout/PaneScaffoldScope, androidx/compose/ui/layout/LookaheadScope { + public abstract fun getEnterTransition ()Landroidx/compose/animation/EnterTransition; + public abstract fun getExitTransition ()Landroidx/compose/animation/ExitTransition; + public abstract fun getPositionAnimationSpec ()Landroidx/compose/animation/core/FiniteAnimationSpec; + public abstract fun getRole ()Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole; + public abstract fun getScaffoldStateTransition ()Landroidx/compose/animation/core/Transition; + public abstract fun getScaffoldStateTransitionFraction ()F + public abstract fun getSizeAnimationSpec ()Landroidx/compose/animation/core/FiniteAnimationSpec; +} + +public final class androidx/compose/material3/adaptive/layout/ThreePaneScaffoldValue : androidx/compose/material3/adaptive/layout/PaneScaffoldValue { + public static final field $stable I + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun equals (Ljava/lang/Object;)Z + public fun get-KvVKflc (Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole;)Ljava/lang/String; + public synthetic fun get-KvVKflc (Ljava/lang/Object;)Ljava/lang/String; + public final fun getPrimary-z8rX67Q ()Ljava/lang/String; + public final fun getSecondary-z8rX67Q ()Ljava/lang/String; + public final fun getTertiary-z8rX67Q ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class androidx/compose/material3/adaptive/layout/ThreePaneScaffoldValueKt { + public static final fun calculateThreePaneScaffoldValue (ILandroidx/compose/material3/adaptive/layout/ThreePaneScaffoldAdaptStrategies;Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldDestinationItem;)Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldValue; + public static final fun calculateThreePaneScaffoldValue (ILandroidx/compose/material3/adaptive/layout/ThreePaneScaffoldAdaptStrategies;Ljava/util/List;)Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldValue; +} + diff --git a/compose/material3/adaptive/adaptive-layout/build.gradle b/compose/material3/adaptive/adaptive-layout/build.gradle index d61114c242933..e31d9df3a986c 100644 --- a/compose/material3/adaptive/adaptive-layout/build.gradle +++ b/compose/material3/adaptive/adaptive-layout/build.gradle @@ -21,40 +21,53 @@ * Please use that script when creating a new project, rather than copying an existing project and * modifying its settings. */ + +import androidx.build.AndroidXComposePlugin +import androidx.build.JetbrainsAndroidXPlugin import androidx.build.LibraryType -import androidx.build.PlatformIdentifier import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("AndroidXPlugin") id("com.android.library") id("AndroidXComposePlugin") + id("JetbrainsAndroidXPlugin") } -androidXMultiplatform { +AndroidXComposePlugin.applyAndConfigureKotlinPlugin(project) +JetbrainsAndroidXPlugin.applyAndConfigure(project) + +androidXComposeMultiplatform { android() desktop() + darwin() + wasm() + js() +} - defaultPlatform(PlatformIdentifier.ANDROID) - +kotlin { sourceSets { commonMain { dependencies { implementation(libs.kotlinStdlibCommon) api(project(":compose:material3:adaptive:adaptive")) - api("androidx.compose.animation:animation-core:1.7.0-beta04") - api("androidx.compose.ui:ui:1.7.0-beta04") - implementation("androidx.compose.animation:animation:1.7.0-beta04") - implementation("androidx.compose.foundation:foundation:1.6.5") - implementation("androidx.compose.foundation:foundation-layout:1.6.5") - implementation("androidx.compose.ui:ui-geometry:1.6.5") - implementation("androidx.compose.ui:ui-util:1.6.5") - implementation("androidx.window:window-core:1.3.0-rc01") + api(project(":compose:animation:animation-core")) + api(project(":compose:ui:ui")) + implementation(project(":compose:animation:animation")) + implementation(project(":compose:foundation:foundation")) + implementation(project(":compose:foundation:foundation-layout")) + implementation(project(":compose:ui:ui-geometry")) + implementation(project(":compose:ui:ui-util")) + implementation(project(":window:window-core")) + implementation(project(":collection:collection")) } } commonTest { dependencies { + implementation(libs.kotlinTest) + api(project(":annotation:annotation")) + implementation(project(":kruth:kruth")) } } @@ -68,8 +81,6 @@ androidXMultiplatform { androidMain { dependsOn(jvmMain) dependencies { - api("androidx.annotation:annotation:1.1.0") - api("androidx.annotation:annotation-experimental:1.4.0") } } @@ -94,7 +105,7 @@ androidXMultiplatform { dependencies { implementation(project(":compose:material3:material3")) implementation(project(":compose:test-utils")) - implementation(project(":window:window-testing")) +// implementation(project(":window:window-testing")) implementation(libs.junit) implementation(libs.testRunner) implementation(libs.truth) @@ -109,6 +120,22 @@ androidXMultiplatform { implementation(libs.truth) } } + + skikoMain.dependsOn(commonMain) + desktopMain.dependsOn(skikoMain) + nonJvmMain.dependsOn(skikoMain) + webMain.dependsOn(nonJvmMain) + jsMain.dependsOn(webMain) + wasmJsMain.dependsOn(webMain) + nativeMain.dependsOn(nonJvmMain) + + skikoTest.dependsOn(commonTest) + desktopTest.dependsOn(skikoTest) + nonJvmTest.dependsOn(skikoTest) + webTest.dependsOn(nonJvmTest) + jsTest.dependsOn(webTest) + wasmJsTest.dependsOn(webTest) + nativeTest.dependsOn(nonJvmTest) } } @@ -118,11 +145,11 @@ android { androidx { name = "Material Adaptive" - type = LibraryType.PUBLISHED_LIBRARY_ONLY_USED_BY_KOTLIN_CONSUMERS + type = LibraryType.PUBLISHED_LIBRARY inceptionYear = "2023" description = "Compose Material Design Adaptive Library" legacyDisableKotlinStrictApiMode = true - samples(project(":compose:material3:adaptive:adaptive-samples")) +// samples(project(":compose:material3:adaptive:adaptive-samples")) } tasks.withType(KotlinCompile).configureEach { diff --git a/compose/material3/adaptive/adaptive-layout/src/commonMain/kotlin/androidx/compose/material3/adaptive/layout/PaneAdaptedValue.kt b/compose/material3/adaptive/adaptive-layout/src/commonMain/kotlin/androidx/compose/material3/adaptive/layout/PaneAdaptedValue.kt index 00deed0daf2ae..e09a1473b547d 100644 --- a/compose/material3/adaptive/adaptive-layout/src/commonMain/kotlin/androidx/compose/material3/adaptive/layout/PaneAdaptedValue.kt +++ b/compose/material3/adaptive/adaptive-layout/src/commonMain/kotlin/androidx/compose/material3/adaptive/layout/PaneAdaptedValue.kt @@ -17,6 +17,7 @@ package androidx.compose.material3.adaptive.layout import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi +import kotlin.jvm.JvmInline /** * The adapted state of a pane. It gives clues to pane scaffolds about if a certain pane should be diff --git a/compose/material3/adaptive/adaptive-layout/src/commonMain/kotlin/androidx/compose/material3/adaptive/layout/PaneMotion.kt b/compose/material3/adaptive/adaptive-layout/src/commonMain/kotlin/androidx/compose/material3/adaptive/layout/PaneMotion.kt index e151d69d54f37..f965e74f6d261 100644 --- a/compose/material3/adaptive/adaptive-layout/src/commonMain/kotlin/androidx/compose/material3/adaptive/layout/PaneMotion.kt +++ b/compose/material3/adaptive/adaptive-layout/src/commonMain/kotlin/androidx/compose/material3/adaptive/layout/PaneMotion.kt @@ -30,6 +30,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.layout.LookaheadScope import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.IntSize +import kotlin.jvm.JvmInline import kotlin.math.max import kotlin.math.min diff --git a/compose/material3/adaptive/adaptive-layout/src/commonMain/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneMotion.kt b/compose/material3/adaptive/adaptive-layout/src/commonMain/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneMotion.kt index 28ecdc360aa30..f5ec399a5e659 100644 --- a/compose/material3/adaptive/adaptive-layout/src/commonMain/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneMotion.kt +++ b/compose/material3/adaptive/adaptive-layout/src/commonMain/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneMotion.kt @@ -33,6 +33,7 @@ import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi import androidx.compose.runtime.Immutable import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.IntSize +import kotlin.jvm.JvmStatic /** Holds the transitions that can be applied to the different panes. */ @ExperimentalMaterial3AdaptiveApi diff --git a/compose/material3/adaptive/adaptive-layout/src/androidUnitTest/kotlin/androidx/compose/material3/adaptive/layout/PaneMotionTest.kt b/compose/material3/adaptive/adaptive-layout/src/commonTest/kotlin/androidx/compose/material3/adaptive/layout/PaneMotionTest.kt similarity index 98% rename from compose/material3/adaptive/adaptive-layout/src/androidUnitTest/kotlin/androidx/compose/material3/adaptive/layout/PaneMotionTest.kt rename to compose/material3/adaptive/adaptive-layout/src/commonTest/kotlin/androidx/compose/material3/adaptive/layout/PaneMotionTest.kt index 1c455bf906300..d40099a4710c2 100644 --- a/compose/material3/adaptive/adaptive-layout/src/androidUnitTest/kotlin/androidx/compose/material3/adaptive/layout/PaneMotionTest.kt +++ b/compose/material3/adaptive/adaptive-layout/src/commonTest/kotlin/androidx/compose/material3/adaptive/layout/PaneMotionTest.kt @@ -47,13 +47,10 @@ import androidx.compose.ui.layout.LayoutCoordinates import androidx.compose.ui.layout.Placeable import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.IntSize -import com.google.common.truth.Truth.assertWithMessage -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.JUnit4 +import androidx.kruth.assertWithMessage +import kotlin.test.Test @OptIn(ExperimentalMaterial3AdaptiveApi::class) -@RunWith(JUnit4::class) class PaneMotionTest { @Test fun test_allThreePaneMotions() { diff --git a/compose/material3/adaptive/adaptive-layout/src/androidUnitTest/kotlin/androidx/compose/material3/adaptive/layout/PaneScaffoldDirectiveTest.kt b/compose/material3/adaptive/adaptive-layout/src/commonTest/kotlin/androidx/compose/material3/adaptive/layout/PaneScaffoldDirectiveTest.kt similarity index 98% rename from compose/material3/adaptive/adaptive-layout/src/androidUnitTest/kotlin/androidx/compose/material3/adaptive/layout/PaneScaffoldDirectiveTest.kt rename to compose/material3/adaptive/adaptive-layout/src/commonTest/kotlin/androidx/compose/material3/adaptive/layout/PaneScaffoldDirectiveTest.kt index ea192858d4cab..624c9c8ec36c6 100644 --- a/compose/material3/adaptive/adaptive-layout/src/androidUnitTest/kotlin/androidx/compose/material3/adaptive/layout/PaneScaffoldDirectiveTest.kt +++ b/compose/material3/adaptive/adaptive-layout/src/commonTest/kotlin/androidx/compose/material3/adaptive/layout/PaneScaffoldDirectiveTest.kt @@ -22,14 +22,11 @@ import androidx.compose.material3.adaptive.Posture import androidx.compose.material3.adaptive.WindowAdaptiveInfo import androidx.compose.ui.geometry.Rect import androidx.compose.ui.unit.dp +import androidx.kruth.assertThat import androidx.window.core.layout.WindowSizeClass -import com.google.common.truth.Truth.assertThat -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.JUnit4 +import kotlin.test.Test @OptIn(ExperimentalMaterial3AdaptiveApi::class) -@RunWith(JUnit4::class) class PaneScaffoldDirectiveTest { @Test fun test_calculateStandardPaneScaffoldDirective_compactWidth() { diff --git a/compose/material3/adaptive/adaptive-layout/src/androidUnitTest/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneMotionTest.kt b/compose/material3/adaptive/adaptive-layout/src/commonTest/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneMotionTest.kt similarity index 98% rename from compose/material3/adaptive/adaptive-layout/src/androidUnitTest/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneMotionTest.kt rename to compose/material3/adaptive/adaptive-layout/src/commonTest/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneMotionTest.kt index 39bfd7d5a8559..a8ca0d8bf616e 100644 --- a/compose/material3/adaptive/adaptive-layout/src/androidUnitTest/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneMotionTest.kt +++ b/compose/material3/adaptive/adaptive-layout/src/commonTest/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneMotionTest.kt @@ -21,13 +21,11 @@ import androidx.compose.animation.core.VectorConverter import androidx.compose.animation.core.VectorizedAnimationSpec import androidx.compose.animation.core.spring import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi -import com.google.common.truth.Truth.assertThat -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.JUnit4 +import androidx.kruth.assertThat +import kotlin.test.Test +import kotlin.test.assertEquals @OptIn(ExperimentalMaterial3AdaptiveApi::class) -@RunWith(JUnit4::class) class ThreePaneMotionTest { @Test fun noPane_noMotion() { @@ -353,7 +351,7 @@ class ThreePaneMotionTest { ): Float = getValueFromNanos(playTimeNanos, InitialValue, TargetValue, InitialVelocity).value private fun assertValuesAreEqual(value1: Float, value2: Float) { - assertThat(value1 - value2).isWithin(Tolerance) + assertEquals(value1, value2, Tolerance) } companion object { diff --git a/compose/material3/adaptive/adaptive-layout/src/androidUnitTest/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneScaffoldValueTest.kt b/compose/material3/adaptive/adaptive-layout/src/commonTest/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneScaffoldValueTest.kt similarity index 98% rename from compose/material3/adaptive/adaptive-layout/src/androidUnitTest/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneScaffoldValueTest.kt rename to compose/material3/adaptive/adaptive-layout/src/commonTest/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneScaffoldValueTest.kt index b24879e175394..7b3989c8be1d8 100644 --- a/compose/material3/adaptive/adaptive-layout/src/androidUnitTest/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneScaffoldValueTest.kt +++ b/compose/material3/adaptive/adaptive-layout/src/commonTest/kotlin/androidx/compose/material3/adaptive/layout/ThreePaneScaffoldValueTest.kt @@ -17,13 +17,10 @@ package androidx.compose.material3.adaptive.layout import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi -import com.google.common.truth.Truth.assertThat -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.JUnit4 +import androidx.kruth.assertThat +import kotlin.test.Test @OptIn(ExperimentalMaterial3AdaptiveApi::class) -@RunWith(JUnit4::class) class ThreePaneScaffoldValueTest { @Test fun calculateWithoutHistory_onePaneLayout_noDestination() { diff --git a/compose/material3/adaptive/adaptive-layout/src/desktopMain/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionDragHandle.desktop.kt b/compose/material3/adaptive/adaptive-layout/src/skikoMain/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionDragHandle.skiko.kt similarity index 100% rename from compose/material3/adaptive/adaptive-layout/src/desktopMain/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionDragHandle.desktop.kt rename to compose/material3/adaptive/adaptive-layout/src/skikoMain/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionDragHandle.skiko.kt diff --git a/compose/material3/adaptive/adaptive-navigation/api/desktop/adaptive-navigation.api b/compose/material3/adaptive/adaptive-navigation/api/desktop/adaptive-navigation.api new file mode 100644 index 0000000000000..253d7f67d91f3 --- /dev/null +++ b/compose/material3/adaptive/adaptive-navigation/api/desktop/adaptive-navigation.api @@ -0,0 +1,41 @@ +public final class androidx/compose/material3/adaptive/navigation/BackNavigationBehavior { + public static final field Companion Landroidx/compose/material3/adaptive/navigation/BackNavigationBehavior$Companion; + public static final synthetic fun box-impl (Ljava/lang/String;)Landroidx/compose/material3/adaptive/navigation/BackNavigationBehavior; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Ljava/lang/String;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Ljava/lang/String;Ljava/lang/String;)Z + public fun hashCode ()I + public static fun hashCode-impl (Ljava/lang/String;)I + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Ljava/lang/String;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Ljava/lang/String; +} + +public final class androidx/compose/material3/adaptive/navigation/BackNavigationBehavior$Companion { + public final fun getPopLatest-pSECbL4 ()Ljava/lang/String; + public final fun getPopUntilContentChange-pSECbL4 ()Ljava/lang/String; + public final fun getPopUntilCurrentDestinationChange-pSECbL4 ()Ljava/lang/String; + public final fun getPopUntilScaffoldValueChange-pSECbL4 ()Ljava/lang/String; +} + +public abstract interface class androidx/compose/material3/adaptive/navigation/ThreePaneScaffoldNavigator { + public abstract fun canNavigateBack--pgVGNs (Ljava/lang/String;)Z + public static synthetic fun canNavigateBack--pgVGNs$default (Landroidx/compose/material3/adaptive/navigation/ThreePaneScaffoldNavigator;Ljava/lang/String;ILjava/lang/Object;)Z + public abstract fun getCurrentDestination ()Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldDestinationItem; + public abstract fun getScaffoldDirective ()Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective; + public abstract fun getScaffoldValue ()Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldValue; + public abstract fun isDestinationHistoryAware ()Z + public abstract fun navigateBack--pgVGNs (Ljava/lang/String;)Z + public static synthetic fun navigateBack--pgVGNs$default (Landroidx/compose/material3/adaptive/navigation/ThreePaneScaffoldNavigator;Ljava/lang/String;ILjava/lang/Object;)Z + public abstract fun navigateTo (Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole;Ljava/lang/Object;)V + public static synthetic fun navigateTo$default (Landroidx/compose/material3/adaptive/navigation/ThreePaneScaffoldNavigator;Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldRole;Ljava/lang/Object;ILjava/lang/Object;)V + public abstract fun setDestinationHistoryAware (Z)V +} + +public final class androidx/compose/material3/adaptive/navigation/ThreePaneScaffoldNavigatorKt { + public static final fun rememberListDetailPaneScaffoldNavigator (Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective;Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldAdaptStrategies;ZLandroidx/compose/runtime/Composer;II)Landroidx/compose/material3/adaptive/navigation/ThreePaneScaffoldNavigator; + public static final fun rememberListDetailPaneScaffoldNavigator (Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective;Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldAdaptStrategies;ZLjava/util/List;Landroidx/compose/runtime/Composer;II)Landroidx/compose/material3/adaptive/navigation/ThreePaneScaffoldNavigator; + public static final fun rememberSupportingPaneScaffoldNavigator (Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective;Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldAdaptStrategies;ZLandroidx/compose/runtime/Composer;II)Landroidx/compose/material3/adaptive/navigation/ThreePaneScaffoldNavigator; + public static final fun rememberSupportingPaneScaffoldNavigator (Landroidx/compose/material3/adaptive/layout/PaneScaffoldDirective;Landroidx/compose/material3/adaptive/layout/ThreePaneScaffoldAdaptStrategies;ZLjava/util/List;Landroidx/compose/runtime/Composer;II)Landroidx/compose/material3/adaptive/navigation/ThreePaneScaffoldNavigator; +} + diff --git a/compose/material3/adaptive/adaptive-navigation/build.gradle b/compose/material3/adaptive/adaptive-navigation/build.gradle index e7f9947512310..67a4b86cb92b4 100644 --- a/compose/material3/adaptive/adaptive-navigation/build.gradle +++ b/compose/material3/adaptive/adaptive-navigation/build.gradle @@ -21,29 +21,38 @@ * Please use that script when creating a new project, rather than copying an existing project and * modifying its settings. */ + +import androidx.build.AndroidXComposePlugin +import androidx.build.JetbrainsAndroidXPlugin import androidx.build.LibraryType -import androidx.build.PlatformIdentifier import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("AndroidXPlugin") id("com.android.library") id("AndroidXComposePlugin") + id("JetbrainsAndroidXPlugin") } -androidXMultiplatform { +AndroidXComposePlugin.applyAndConfigureKotlinPlugin(project) +JetbrainsAndroidXPlugin.applyAndConfigure(project) + +androidXComposeMultiplatform { android() desktop() + darwin() + wasm() + js() +} - defaultPlatform(PlatformIdentifier.ANDROID) - +kotlin { sourceSets { commonMain { dependencies { implementation(libs.kotlinStdlibCommon) api(project(":compose:material3:adaptive:adaptive-layout")) - implementation("androidx.compose.foundation:foundation:1.6.5") - implementation("androidx.compose.ui:ui-util:1.6.5") + implementation(project(":compose:foundation:foundation")) + implementation(project(":compose:ui:ui-util")) } } @@ -89,7 +98,7 @@ androidXMultiplatform { dependencies { implementation(project(":compose:material3:material3")) implementation(project(":compose:test-utils")) - implementation(project(":window:window-testing")) +// implementation(project(":window:window-testing")) implementation(libs.junit) implementation(libs.testRunner) implementation(libs.truth) @@ -104,6 +113,22 @@ androidXMultiplatform { implementation(libs.truth) } } + + skikoMain.dependsOn(commonMain) + desktopMain.dependsOn(skikoMain) + nonJvmMain.dependsOn(skikoMain) + webMain.dependsOn(nonJvmMain) + jsMain.dependsOn(webMain) + wasmJsMain.dependsOn(webMain) + nativeMain.dependsOn(nonJvmMain) + + skikoTest.dependsOn(commonTest) + desktopTest.dependsOn(skikoTest) + nonJvmTest.dependsOn(skikoTest) + webTest.dependsOn(nonJvmTest) + jsTest.dependsOn(webTest) + wasmJsTest.dependsOn(webTest) + nativeTest.dependsOn(nonJvmTest) } } @@ -113,7 +138,7 @@ android { androidx { name = "Material Adaptive" - type = LibraryType.PUBLISHED_LIBRARY_ONLY_USED_BY_KOTLIN_CONSUMERS + type = LibraryType.PUBLISHED_LIBRARY inceptionYear = "2023" description = "Compose Material Design Adaptive Library" legacyDisableKotlinStrictApiMode = true diff --git a/compose/material3/adaptive/adaptive-navigation/src/commonMain/kotlin/androidx/compose/material3/adaptive/navigation/BackNavigationBehavior.kt b/compose/material3/adaptive/adaptive-navigation/src/commonMain/kotlin/androidx/compose/material3/adaptive/navigation/BackNavigationBehavior.kt index e3ba0c414e995..07c722a037945 100644 --- a/compose/material3/adaptive/adaptive-navigation/src/commonMain/kotlin/androidx/compose/material3/adaptive/navigation/BackNavigationBehavior.kt +++ b/compose/material3/adaptive/adaptive-navigation/src/commonMain/kotlin/androidx/compose/material3/adaptive/navigation/BackNavigationBehavior.kt @@ -20,6 +20,7 @@ import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi import androidx.compose.material3.adaptive.layout.PaneAdaptedValue import androidx.compose.material3.adaptive.layout.ThreePaneScaffoldDestinationItem import androidx.compose.material3.adaptive.layout.ThreePaneScaffoldRole +import kotlin.jvm.JvmInline /** A class to control how back navigation should behave in a [ThreePaneScaffoldNavigator]. */ @ExperimentalMaterial3AdaptiveApi diff --git a/compose/material3/adaptive/adaptive/api/desktop/adaptive.api b/compose/material3/adaptive/adaptive/api/desktop/adaptive.api new file mode 100644 index 0000000000000..9dcdd36621bf1 --- /dev/null +++ b/compose/material3/adaptive/adaptive/api/desktop/adaptive.api @@ -0,0 +1,51 @@ +public abstract interface annotation class androidx/compose/material3/adaptive/ExperimentalMaterial3AdaptiveApi : java/lang/annotation/Annotation { +} + +public final class androidx/compose/material3/adaptive/HingeInfo { + public static final field $stable I + public fun (Landroidx/compose/ui/geometry/Rect;ZZZZ)V + public fun equals (Ljava/lang/Object;)Z + public final fun getBounds ()Landroidx/compose/ui/geometry/Rect; + public fun hashCode ()I + public final fun isFlat ()Z + public final fun isOccluding ()Z + public final fun isSeparating ()Z + public final fun isVertical ()Z + public fun toString ()Ljava/lang/String; +} + +public final class androidx/compose/material3/adaptive/Posture { + public static final field $stable I + public fun ()V + public fun (ZLjava/util/List;)V + public synthetic fun (ZLjava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun equals (Ljava/lang/Object;)Z + public final fun getHingeList ()Ljava/util/List; + public fun hashCode ()I + public final fun isTabletop ()Z + public fun toString ()Ljava/lang/String; +} + +public final class androidx/compose/material3/adaptive/PostureKt { + public static final fun getAllHorizontalHingeBounds (Landroidx/compose/material3/adaptive/Posture;)Ljava/util/List; + public static final fun getAllVerticalHingeBounds (Landroidx/compose/material3/adaptive/Posture;)Ljava/util/List; + public static final fun getOccludingHorizontalHingeBounds (Landroidx/compose/material3/adaptive/Posture;)Ljava/util/List; + public static final fun getOccludingVerticalHingeBounds (Landroidx/compose/material3/adaptive/Posture;)Ljava/util/List; + public static final fun getSeparatingHorizontalHingeBounds (Landroidx/compose/material3/adaptive/Posture;)Ljava/util/List; + public static final fun getSeparatingVerticalHingeBounds (Landroidx/compose/material3/adaptive/Posture;)Ljava/util/List; +} + +public final class androidx/compose/material3/adaptive/WindowAdaptiveInfo { + public static final field $stable I + public fun (Landroidx/window/core/layout/WindowSizeClass;Landroidx/compose/material3/adaptive/Posture;)V + public fun equals (Ljava/lang/Object;)Z + public final fun getWindowPosture ()Landroidx/compose/material3/adaptive/Posture; + public final fun getWindowSizeClass ()Landroidx/window/core/layout/WindowSizeClass; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class androidx/compose/material3/adaptive/WindowAdaptiveInfo_skikoKt { + public static final fun currentWindowAdaptiveInfo (Landroidx/compose/runtime/Composer;I)Landroidx/compose/material3/adaptive/WindowAdaptiveInfo; +} + diff --git a/compose/material3/adaptive/adaptive/build.gradle b/compose/material3/adaptive/adaptive/build.gradle index 269c3844ac05d..bfdaf08af4816 100644 --- a/compose/material3/adaptive/adaptive/build.gradle +++ b/compose/material3/adaptive/adaptive/build.gradle @@ -21,29 +21,38 @@ * Please use that script when creating a new project, rather than copying an existing project and * modifying its settings. */ + +import androidx.build.AndroidXComposePlugin +import androidx.build.JetbrainsAndroidXPlugin import androidx.build.LibraryType -import androidx.build.PlatformIdentifier import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("AndroidXPlugin") id("com.android.library") id("AndroidXComposePlugin") + id("JetbrainsAndroidXPlugin") } -androidXMultiplatform { +AndroidXComposePlugin.applyAndConfigureKotlinPlugin(project) +JetbrainsAndroidXPlugin.applyAndConfigure(project) + +androidXComposeMultiplatform { android() desktop() + darwin() + wasm() + js() +} - defaultPlatform(PlatformIdentifier.ANDROID) - +kotlin { sourceSets { commonMain { dependencies { implementation(libs.kotlinStdlibCommon) - api("androidx.compose.foundation:foundation:1.6.5") - api("androidx.compose.ui:ui-geometry:1.6.5") - api("androidx.window:window-core:1.3.0-rc01") + api(project(":compose:foundation:foundation")) + api(project(":compose:ui:ui-geometry")) + api(project(":window:window-core")) } } @@ -62,9 +71,10 @@ androidXMultiplatform { androidMain { dependsOn(jvmMain) dependencies { - api("androidx.annotation:annotation:1.1.0") - api("androidx.annotation:annotation-experimental:1.4.0") - api("androidx.window:window:1.3.0-rc01") + api(project(":annotation:annotation")) + //dependencies are not available in JB fork + //api(project(":annotation:annotation-experimental")) + //api(project(":window:window")) } } @@ -89,7 +99,8 @@ androidXMultiplatform { dependencies { implementation(project(":compose:material3:material3")) implementation(project(":compose:test-utils")) - implementation(project(":window:window-testing")) + //dependency is not available in JB fork + //implementation(project(":window:window-testing")) implementation(libs.junit) implementation(libs.testRunner) implementation(libs.truth) @@ -104,6 +115,22 @@ androidXMultiplatform { implementation(libs.truth) } } + + skikoMain.dependsOn(commonMain) + desktopMain.dependsOn(skikoMain) + nonJvmMain.dependsOn(skikoMain) + webMain.dependsOn(nonJvmMain) + jsMain.dependsOn(webMain) + wasmJsMain.dependsOn(webMain) + nativeMain.dependsOn(nonJvmMain) + + skikoTest.dependsOn(commonTest) + desktopTest.dependsOn(skikoTest) + nonJvmTest.dependsOn(skikoTest) + webTest.dependsOn(nonJvmTest) + jsTest.dependsOn(webTest) + wasmJsTest.dependsOn(webTest) + nativeTest.dependsOn(nonJvmTest) } } @@ -113,7 +140,7 @@ android { androidx { name = "Material Adaptive" - type = LibraryType.PUBLISHED_LIBRARY_ONLY_USED_BY_KOTLIN_CONSUMERS + type = LibraryType.PUBLISHED_LIBRARY inceptionYear = "2023" description = "Compose Material Design Adaptive Library" legacyDisableKotlinStrictApiMode = true diff --git a/compose/material3/adaptive/adaptive/src/desktopMain/kotlin/androidx/compose/material3/adaptive/DesktopWindowInfo.desktop.kt b/compose/material3/adaptive/adaptive/src/skikoMain/kotlin/androidx/compose/material3/adaptive/WindowAdaptiveInfo.skiko.kt similarity index 55% rename from compose/material3/adaptive/adaptive/src/desktopMain/kotlin/androidx/compose/material3/adaptive/DesktopWindowInfo.desktop.kt rename to compose/material3/adaptive/adaptive/src/skikoMain/kotlin/androidx/compose/material3/adaptive/WindowAdaptiveInfo.skiko.kt index a32d0d4249a96..1fd4eaa7cbb0e 100644 --- a/compose/material3/adaptive/adaptive/src/desktopMain/kotlin/androidx/compose/material3/adaptive/DesktopWindowInfo.desktop.kt +++ b/compose/material3/adaptive/adaptive/src/skikoMain/kotlin/androidx/compose/material3/adaptive/WindowAdaptiveInfo.skiko.kt @@ -17,8 +17,20 @@ package androidx.compose.material3.adaptive import androidx.compose.runtime.Composable +import androidx.compose.ui.ExperimentalComposeUiApi +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.platform.LocalWindowInfo +import androidx.compose.ui.unit.toSize +import androidx.window.core.layout.WindowSizeClass +@OptIn(ExperimentalComposeUiApi::class) @Composable actual fun currentWindowAdaptiveInfo(): WindowAdaptiveInfo { - TODO("Not yet implemented") + val density = LocalDensity.current + val windowInfo = LocalWindowInfo.current + val size = with(density) { windowInfo.containerSize.toSize().toDpSize() } + return WindowAdaptiveInfo( + WindowSizeClass.compute(size.width.value, size.height.value), + Posture() //postures and hinges are relevant to android devices only + ) } diff --git a/compose/mpp/demo/build.gradle.kts b/compose/mpp/demo/build.gradle.kts index 5ef3e6e5d97ad..5c64969eea7d7 100644 --- a/compose/mpp/demo/build.gradle.kts +++ b/compose/mpp/demo/build.gradle.kts @@ -154,6 +154,7 @@ kotlin { implementation(project(":compose:foundation:foundation-layout")) implementation(project(":compose:material3:material3")) implementation(project(":compose:material3:material3-window-size-class")) + implementation(project(":compose:material3:adaptive:adaptive")) implementation(project(":compose:material:material")) implementation(project(":compose:mpp")) implementation(project(":compose:runtime:runtime")) diff --git a/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/components/Adaptive.kt b/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/components/Adaptive.kt new file mode 100644 index 0000000000000..6d3972ff78f07 --- /dev/null +++ b/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/components/Adaptive.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package androidx.compose.mpp.demo.components + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Text +import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp + +@Composable +fun AdaptiveExample() { + Box(modifier = Modifier.fillMaxSize().padding(40.dp), contentAlignment = Alignment.Center) { + val adaptiveInfo = currentWindowAdaptiveInfo() + Text("WindowAdaptiveInfo\n" + + "WidthSizeClass=${adaptiveInfo.windowSizeClass.windowWidthSizeClass}\n" + + "HeightSizeClass=${adaptiveInfo.windowSizeClass.windowHeightSizeClass}\n" + + "isTabletop=${adaptiveInfo.windowPosture.isTabletop}\n" + + "hingeList=${adaptiveInfo.windowPosture.hingeList}") + } +} \ No newline at end of file diff --git a/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/components/Components.kt b/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/components/Components.kt index e9c1784bd08ad..29179ac9f232d 100644 --- a/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/components/Components.kt +++ b/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/components/Components.kt @@ -60,4 +60,5 @@ val Components = Screen.Selection( Screen.Example("NestedScroll") { NestedScrollExample() }, Screen.Example("Selection") { SelectionExample() }, Screen.Example("Pager") { PagerExample() }, + Screen.Example("WindowAdaptiveInfo") { AdaptiveExample() }, ) diff --git a/gradle.properties b/gradle.properties index bacf0979afe77..94330d1fe32c3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -108,12 +108,15 @@ artifactRedirecting.androidx.compose.foundation.version=1.7.0-beta06 artifactRedirecting.androidx.compose.material.version=1.7.0-beta06 # Look for `COMPOSE_MATERIAL3_COMMON` in libraryversions.toml artifactRedirecting.androidx.compose.material3.common.version=1.0.0-alpha01 +# Look for `COMPOSE_MATERIAL3_ADAPTIVE` in libraryversions.toml +artifactRedirecting.androidx.compose.material3.adaptive.version=1.0.0-beta04 # We use artifactRedirecting not only for Compose libs: artifactRedirecting.androidx.collection.version=1.4.0 artifactRedirecting.androidx.annotation.version=1.8.0 artifactRedirecting.androidx.lifecycle.version=2.8.0 artifactRedirecting.androidx.navigation.version=2.8.0-beta05 artifactRedirecting.androidx.savedstate.version=1.2.1 +artifactRedirecting.androidx.window.core.version=1.3.0 # For the purpose of substituteForRedirectedPublishedDependencies (look for it in the code) artifactRedirecting.modules-for-knative-manifest=\ diff --git a/libraryversions.toml b/libraryversions.toml index 5cf14b71cfaad..8358072efcd14 100644 --- a/libraryversions.toml +++ b/libraryversions.toml @@ -197,7 +197,7 @@ COMPOSE_FOUNDATION = { group = "org.jetbrains.compose.foundation", atomicGroupVe COMPOSE_MATERIAL = { group = "org.jetbrains.compose.material", atomicGroupVersion = "versions.COMPOSE" } COMPOSE_MATERIAL3 = { group = "org.jetbrains.compose.material3", atomicGroupVersion = "versions.COMPOSE_MATERIAL3" } COMPOSE_MATERIAL3_COMMON = { group = "org.jetbrains.compose.material3.common", atomicGroupVersion = "versions.COMPOSE_MATERIAL3_COMMON", overrideInclude = [ ":compose:material3:material3-common" ] } -COMPOSE_MATERIAL3_ADAPTIVE = { group = "androidx.compose.material3.material3-adaptive", atomicGroupVersion = "versions.COMPOSE_MATERIAL3_ADAPTIVE" } +COMPOSE_MATERIAL3_ADAPTIVE = { group = "org.jetbrains.compose.material3.adaptive", atomicGroupVersion = "versions.COMPOSE_MATERIAL3_ADAPTIVE" } COMPOSE_RUNTIME = { group = "org.jetbrains.compose.runtime", atomicGroupVersion = "versions.COMPOSE" } COMPOSE_UI = { group = "org.jetbrains.compose.ui", atomicGroupVersion = "versions.COMPOSE" } CONCURRENT = { group = "androidx.concurrent", atomicGroupVersion = "versions.FUTURES" } @@ -292,6 +292,7 @@ WEAR_TILES = { group = "androidx.wear.tiles", atomicGroupVersion = "versions.WEA WEAR_WATCHFACE = { group = "androidx.wear.watchface", atomicGroupVersion = "versions.WEAR_WATCHFACE" } WEBKIT = { group = "androidx.webkit", atomicGroupVersion = "versions.WEBKIT" } WINDOW = { group = "androidx.window", atomicGroupVersion = "versions.WINDOW" } +WINDOW_CORE = { group = "org.jetbrains.window.core", atomicGroupVersion = "versions.WINDOW", overrideInclude = [ ":window:window-core" ] } WINDOW_EXTENSIONS = { group = "androidx.window.extensions", atomicGroupVersion = "versions.WINDOW_EXTENSIONS" } WINDOW_EXTENSIONS_CORE = { group = "androidx.window.extensions.core", atomicGroupVersion = "versions.WINDOW_EXTENSIONS_CORE" } WINDOW_SIDECAR = { group = "androidx.window.sidecar", atomicGroupVersion = "versions.WINDOW_SIDECAR" } diff --git a/mpp/build.gradle.kts b/mpp/build.gradle.kts index 97f6bef8c530b..8e59c51a36759 100644 --- a/mpp/build.gradle.kts +++ b/mpp/build.gradle.kts @@ -54,6 +54,9 @@ val libraryToComponents = mapOf( ComposeComponent(":compose:material:material-icons-core"), ComposeComponent(":compose:material:material-ripple"), ComposeComponent(":compose:material3:material3-window-size-class"), + ComposeComponent(":compose:material3:adaptive:adaptive"), + ComposeComponent(":compose:material3:adaptive:adaptive-layout"), + ComposeComponent(":compose:material3:adaptive:adaptive-navigation"), ComposeComponent(":compose:runtime:runtime", supportedPlatforms = ComposePlatforms.ALL), ComposeComponent(":compose:runtime:runtime-saveable", supportedPlatforms = ComposePlatforms.ALL), ComposeComponent(":compose:ui:ui"), @@ -107,6 +110,9 @@ val libraryToComponents = mapOf( "SAVEDSTATE" to listOf( ComposeComponent(":savedstate:savedstate", viewModelPlatforms), ), + "WINDOW" to listOf( + ComposeComponent(":window:window-core", viewModelPlatforms), + ), ) val libraryToTasks = mapOf( diff --git a/settings.gradle b/settings.gradle index 254eb95ede37b..535a0e03a4dd9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -157,7 +157,9 @@ includeProject(":compose:lint:common-test") includeProject(":compose:material") includeProject(":compose:material3:material3") includeProject(":compose:material3:material3-common") -//includeProject(":compose:material3:material3-adaptive") +includeProject(":compose:material3:adaptive:adaptive") +includeProject(":compose:material3:adaptive:adaptive-layout") +includeProject(":compose:material3:adaptive:adaptive-navigation") includeProject(":compose:material3:material3-lint") includeProject(":compose:material3:material3-window-size-class") includeProject(":compose:material3:material3-window-size-class:material3-window-size-class-samples", "compose/material3/material3-window-size-class/samples") @@ -256,3 +258,4 @@ includeProject(":internal-testutils-mockito", "testutils/testutils-mockito") includeBuild("placeholder") includeProject(":mpp") +includeProject(":window:window-core") diff --git a/window/window-core/api/desktop/window-core.api b/window/window-core/api/desktop/window-core.api new file mode 100644 index 0000000000000..5ddf074d4c345 --- /dev/null +++ b/window/window-core/api/desktop/window-core.api @@ -0,0 +1,46 @@ +public abstract interface annotation class androidx/window/core/ExperimentalWindowCoreApi : java/lang/annotation/Annotation { +} + +public final class androidx/window/core/layout/WindowHeightSizeClass { + public static final field COMPACT Landroidx/window/core/layout/WindowHeightSizeClass; + public static final field Companion Landroidx/window/core/layout/WindowHeightSizeClass$Companion; + public static final field EXPANDED Landroidx/window/core/layout/WindowHeightSizeClass; + public static final field MEDIUM Landroidx/window/core/layout/WindowHeightSizeClass; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class androidx/window/core/layout/WindowHeightSizeClass$Companion { +} + +public final class androidx/window/core/layout/WindowSizeClass { + public static final field Companion Landroidx/window/core/layout/WindowSizeClass$Companion; + public synthetic fun (Landroidx/window/core/layout/WindowWidthSizeClass;Landroidx/window/core/layout/WindowHeightSizeClass;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public static final fun compute (FF)Landroidx/window/core/layout/WindowSizeClass; + public static final fun compute (IIF)Landroidx/window/core/layout/WindowSizeClass; + public fun equals (Ljava/lang/Object;)Z + public final fun getWindowHeightSizeClass ()Landroidx/window/core/layout/WindowHeightSizeClass; + public final fun getWindowWidthSizeClass ()Landroidx/window/core/layout/WindowWidthSizeClass; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class androidx/window/core/layout/WindowSizeClass$Companion { + public final fun compute (FF)Landroidx/window/core/layout/WindowSizeClass; + public final fun compute (IIF)Landroidx/window/core/layout/WindowSizeClass; +} + +public final class androidx/window/core/layout/WindowWidthSizeClass { + public static final field COMPACT Landroidx/window/core/layout/WindowWidthSizeClass; + public static final field Companion Landroidx/window/core/layout/WindowWidthSizeClass$Companion; + public static final field EXPANDED Landroidx/window/core/layout/WindowWidthSizeClass; + public static final field MEDIUM Landroidx/window/core/layout/WindowWidthSizeClass; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class androidx/window/core/layout/WindowWidthSizeClass$Companion { +} + diff --git a/window/window-core/build.gradle b/window/window-core/build.gradle index b4060735b4993..940af1556d29c 100644 --- a/window/window-core/build.gradle +++ b/window/window-core/build.gradle @@ -21,25 +21,52 @@ * Please use that script when creating a new project, rather than copying an existing project and * modifying its settings. */ + +import androidx.build.JetbrainsAndroidXPlugin import androidx.build.LibraryType import androidx.build.PlatformIdentifier +import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType plugins { id("AndroidXPlugin") id("com.android.library") + id("JetbrainsAndroidXPlugin") } +JetbrainsAndroidXPlugin.applyAndConfigure(project) + androidXMultiplatform { - jvm() + desktop() android() + mac() + linux() + ios() + js() + wasm() + + defaultPlatform(PlatformIdentifier.ANDROID) +} + +kotlin { + js { + browser() + } + wasmJs() - defaultPlatform(PlatformIdentifier.JVM) + watchosArm64() + watchosArm32() + watchosX64() + watchosSimulatorArm64() + tvosArm64() + tvosX64() + tvosSimulatorArm64() + mingwX64() sourceSets { commonMain { dependencies { api(libs.kotlinStdlib) - api("androidx.annotation:annotation:1.7.0") + api(project(":annotation:annotation")) } } @@ -54,9 +81,16 @@ androidXMultiplatform { } } - androidInstrumentedTest { - dependencies { - implementation(libs.testRunner) + jvmMain.dependsOn(commonMain) + androidMain.dependsOn(jvmMain) + desktopMain.dependsOn(jvmMain) + nonJvmMain.dependsOn(commonMain) + + targets.all { target -> + if (target.platformType !in [KotlinPlatformType.jvm, KotlinPlatformType.androidJvm, KotlinPlatformType.common]) { + target.compilations["main"].defaultSourceSet { + dependsOn(nonJvmMain) + } } } } @@ -72,3 +106,8 @@ androidx { inceptionYear = "2022" description = "WindowManager Core Library." } + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} diff --git a/window/window-core/gradle.properties b/window/window-core/gradle.properties new file mode 100644 index 0000000000000..3b97aadaeb661 --- /dev/null +++ b/window/window-core/gradle.properties @@ -0,0 +1,18 @@ +# +# Copyright 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# TODO Determine redirection group based on package and remove explicit config +artifactRedirecting.androidx.groupId=androidx.window.core \ No newline at end of file diff --git a/window/window-core/src/commonMain/kotlin/androidx/window/core/layout/WindowSizeClass.kt b/window/window-core/src/commonMain/kotlin/androidx/window/core/layout/WindowSizeClass.kt index 8d61d8a1b0ce1..1b4502874433f 100644 --- a/window/window-core/src/commonMain/kotlin/androidx/window/core/layout/WindowSizeClass.kt +++ b/window/window-core/src/commonMain/kotlin/androidx/window/core/layout/WindowSizeClass.kt @@ -64,7 +64,7 @@ class WindowSizeClass private constructor( override fun equals(other: Any?): Boolean { if (this === other) return true - if (javaClass != other?.javaClass) return false + if (other == null || this::class != other::class) return false other as WindowSizeClass