From 13bc3424622f8ab3a78d664c38fec9e9b61ee022 Mon Sep 17 00:00:00 2001 From: "dima.avdeev" <99798741+dima-avdeev-jb@users.noreply.github.com> Date: Mon, 3 Jul 2023 12:47:19 +0300 Subject: [PATCH] Add TextFields demo page (#615) --- .../kotlin/androidx/compose/mpp/demo/App.kt | 2 + .../compose/mpp/demo/textfield/TextFields.kt | 52 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/textfield/TextFields.kt diff --git a/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/App.kt b/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/App.kt index 1b1ff91efa432..2a504d42691d7 100644 --- a/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/App.kt +++ b/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/App.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.lazy.items import androidx.compose.material.* import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.mpp.demo.textfield.TextFields import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.mutableStateListOf @@ -26,6 +27,7 @@ val MainScreen = Screen.Selection( Screen.ScaffoldExample("ApplicationLayouts") { ApplicationLayouts(it) }, Screen.Example("GraphicsLayerSettings") { GraphicsLayerSettings() }, LazyLayouts, + TextFields, ) sealed interface Screen { diff --git a/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/textfield/TextFields.kt b/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/textfield/TextFields.kt new file mode 100644 index 0000000000000..7070bf28c15b9 --- /dev/null +++ b/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/textfield/TextFields.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2023 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.textfield + +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material.TextField +import androidx.compose.mpp.demo.Screen +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp + +val TextFields = Screen.Selection( + "TextFields", + Screen.Example("AlmostFullscreen") { + AlmostFullscreen() + }, +) + +@Composable +private fun AlmostFullscreen() { + val textState = remember { + mutableStateOf( + buildString { + repeat(100) { + appendLine("Text line $it") + } + } + ) + } + TextField( + textState.value, { textState.value = it }, + Modifier.fillMaxSize().padding(vertical = 40.dp) + ) +} +