Skip to content

Commit

Permalink
Add TextFields demo page (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-avdeev-jb authored Jul 3, 2023
1 parent 79604d4 commit 13bc342
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,6 +27,7 @@ val MainScreen = Screen.Selection(
Screen.ScaffoldExample("ApplicationLayouts") { ApplicationLayouts(it) },
Screen.Example("GraphicsLayerSettings") { GraphicsLayerSettings() },
LazyLayouts,
TextFields,
)

sealed interface Screen {
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
)
}

0 comments on commit 13bc342

Please sign in to comment.