aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Franks <riggaroo@google.com>2023-02-24 16:57:58 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2023-02-24 16:57:58 +0000
commit2cf6079112df04100c3878beb5f0b07623d3f43b (patch)
tree39838473269793356a164b382e8f067ce8a2b31e
parent5b8283654efc37fd78b36f3286c2c0a0f12472d9 (diff)
parent14f75ebfb5b7fb0d936a12de1251fb72cd5e1b61 (diff)
downloadsupport-2cf6079112df04100c3878beb5f0b07623d3f43b.tar.gz
Merge "Delete Intrinsics & ConstraintLayout in favour of github" into androidx-main
-rw-r--r--compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/ConstraintLayout.kt106
-rw-r--r--compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/Intrinsics.kt185
2 files changed, 0 insertions, 291 deletions
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/ConstraintLayout.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/ConstraintLayout.kt
deleted file mode 100644
index f2dce6f45c8..00000000000
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/ConstraintLayout.kt
+++ /dev/null
@@ -1,106 +0,0 @@
-// ktlint-disable indent https://github.com/pinterest/ktlint/issues/967
-/*
- * Copyright 2021 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.
- */
-
-// Ignore lint warnings in documentation snippets
-@file:Suppress("unused", "UNUSED_PARAMETER", "UNUSED_VARIABLE")
-
-package androidx.compose.integration.docs.layout
-
-/**
- * This file lets DevRel track changes to snippets present in
- * https://developer.android.com/jetpack/compose/layouts/constraintlayout
- *
- * No action required if it's modified.
- */
-
-// TODO: uncomment when constraint layout for compose releases, and add that dependency
-/*
-private object LayoutSnippet17 {
- @Composable
- fun ConstraintLayoutContent() {
- ConstraintLayout {
- // Create references for the composables to constrain
- val (button, text) = createRefs()
-
- Button(
- onClick = { */
- /* Do something *//*
- },
- // Assign reference "button" to the Button composable
- // and constrain it to the top of the ConstraintLayout
- modifier = Modifier.constrainAs(button) {
- top.linkTo(parent.top, margin = 16.dp)
- }
- ) {
- Text("Button")
- }
-
- // Assign reference "text" to the Text composable
- // and constrain it to the bottom of the Button composable
- Text("Text", Modifier.constrainAs(text) {
- top.linkTo(button.bottom, margin = 16.dp)
- })
- }
- }
-}
-*/
-
-/**
- * Decoupled API
- *//*
-
-@Suppress("Deprecation")
-private object LayoutSnippet18 {
- @Composable
- fun DecoupledConstraintLayout() {
- BoxWithConstraints {
- val constraints = if (minWidth < 600.dp) {
- decoupledConstraints(margin = 16.dp) // Portrait constraints
- } else {
- decoupledConstraints(margin = 32.dp) // Landscape constraints
- }
-
- ConstraintLayout(constraints) {
- Button(
- onClick = { */
- /* Do something *//*
- },
- modifier = Modifier.layoutId("button")
- ) {
- Text("Button")
- }
-
- Text("Text", Modifier.layoutId("text"))
- }
- }
- }
-
- private fun decoupledConstraints(margin: Dp): ConstraintSet {
- return ConstraintSet {
- val button = createRefFor("button")
- val text = createRefFor("text")
-
- constrain(button) {
- top.linkTo(parent.top, margin = margin)
- }
- constrain(text) {
- top.linkTo(button.bottom, margin)
- }
- }
- }
-}
-*/
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/Intrinsics.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/Intrinsics.kt
deleted file mode 100644
index 7cc4eb4c167..00000000000
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/Intrinsics.kt
+++ /dev/null
@@ -1,185 +0,0 @@
-// ktlint-disable indent https://github.com/pinterest/ktlint/issues/967
-/*
- * Copyright 2021 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.
- */
-
-// Ignore lint warnings in documentation snippets
-@file:Suppress("unused", "UNUSED_PARAMETER", "UNUSED_VARIABLE")
-
-package androidx.compose.integration.docs.layout
-
-import androidx.compose.foundation.layout.Row
-import androidx.compose.foundation.layout.fillMaxHeight
-import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.width
-import androidx.compose.foundation.layout.wrapContentWidth
-import androidx.compose.material.Divider
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.Surface
-import androidx.compose.material.Text
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.layout.IntrinsicMeasurable
-import androidx.compose.ui.layout.IntrinsicMeasureScope
-import androidx.compose.ui.layout.Layout
-import androidx.compose.ui.layout.LayoutModifier
-import androidx.compose.ui.layout.Measurable
-import androidx.compose.ui.layout.MeasurePolicy
-import androidx.compose.ui.layout.MeasureResult
-import androidx.compose.ui.layout.MeasureScope
-import androidx.compose.ui.unit.Constraints
-import androidx.compose.ui.unit.dp
-
-/**
- * This file lets DevRel track changes to snippets present in
- * https://developer.android.com/jetpack/compose/layouts/intrinsic-measurements
- *
- * No action required if it's modified.
- */
-
-private object IntrinsicsSnippet1 {
-
- @Composable
- fun TwoTexts(modifier: Modifier = Modifier, text1: String, text2: String) {
- Row(modifier = modifier) {
- Text(
- modifier = Modifier
- .weight(1f)
- .padding(start = 4.dp)
- .wrapContentWidth(Alignment.Start),
- text = text1
- )
- Divider(
- color = Color.Black,
- modifier = Modifier.fillMaxHeight().width(1.dp)
- )
- Text(
- modifier = Modifier
- .weight(1f)
- .padding(end = 4.dp)
- .wrapContentWidth(Alignment.End),
-
- text = text2
- )
- }
- }
-
- // @Preview
- @Composable
- fun TwoTextsPreview() {
- MaterialTheme {
- Surface {
- TwoTexts(text1 = "Hi", text2 = "there")
- }
- }
- }
-}
-
-private object IntrinsicsSnippet2 {
-
- @Composable
- fun TwoTexts(modifier: Modifier = Modifier, text1: String, text2: String) {
- Row(modifier = modifier) {
- Text(
- modifier = Modifier
- .weight(1f)
- .padding(start = 4.dp)
- .wrapContentWidth(Alignment.Start),
- text = text1
- )
- Divider(
- color = Color.Black,
- modifier = Modifier.fillMaxHeight().width(1.dp)
- )
- Text(
- modifier = Modifier
- .weight(1f)
- .padding(end = 4.dp)
- .wrapContentWidth(Alignment.End),
-
- text = text2
- )
- }
- }
-
- // @Preview
- @Composable
- fun TwoTextsPreview() {
- MaterialTheme {
- Surface {
- TwoTexts(text1 = "Hi", text2 = "there")
- }
- }
- }
-}
-
-private object IntrinsicsSnippet3 {
- @Composable
- fun MyCustomComposable(
- modifier: Modifier = Modifier,
- content: @Composable () -> Unit
- ) {
- Layout(
- content = content,
- modifier = modifier,
- measurePolicy = object : MeasurePolicy {
- override fun MeasureScope.measure(
- measurables: List<Measurable>,
- constraints: Constraints
- ): MeasureResult {
- // Measure and layout here
- TODO() // NOTE: Omit in the code snippets
- }
-
- override fun IntrinsicMeasureScope.minIntrinsicWidth(
- measurables: List<IntrinsicMeasurable>,
- height: Int
- ): Int {
- // Logic here
- TODO() // NOTE: Omit in the code snippets
- }
-
- // Other intrinsics related methods have a default value,
- // you can override only the methods that you need.
- }
- )
- }
-}
-
-private object IntrinsicsSnippet4 {
- fun Modifier.myCustomModifier(/* ... */) = this then object : LayoutModifier {
-
- override fun MeasureScope.measure(
- measurable: Measurable,
- constraints: Constraints
- ): MeasureResult {
- // Measure and layout here
- TODO() // NOTE: Omit in the code snippets
- }
-
- override fun IntrinsicMeasureScope.minIntrinsicWidth(
- measurable: IntrinsicMeasurable,
- height: Int
- ): Int {
- // Logic here
- TODO() // NOTE: Omit in the code snippets
- }
-
- // Other intrinsics related methods have a default value,
- // you can override only the methods that you need.
- }
-}