Jasmin Fajkic
10/25/2022, 7:53 PMJasmin Fajkic
10/25/2022, 7:53 PM@Composable
fun CreatePostContent() {
val post = remember {
mutableStateOf("")
}
Scaffold(
modifier = Modifier
.background(Style.colors.content)
.navigationBarsPadding(),
topBar = {
Row(modifier = Modifier
.height(80.dp)
.fillMaxWidth()
.background(Color.Yellow)) {
Text(text = "Hello")
}
},
bottomBar = {
Row(modifier = Modifier
.imePadding()
.height(60.dp)
.fillMaxWidth()
.background(Color.Green)) {
Text("bootom")
}
},
floatingActionButton = {
FloatingActionButton(onClick = { /*TODO*/ }){
Text("Hello")
}
})
{
LazyColumn(modifier = Modifier.padding(it)) {
item {
TextField(
modifier = Modifier
.fillMaxWidth(),
value = post.value,
onValueChange = { text -> post.value = text },
placeholder = { Text("Enter something") },
colors = TextFieldDefaults.textFieldColors(
containerColor = Color.Gray,
disabledIndicatorColor = Color.Gray,
unfocusedIndicatorColor = Color.Gray,
focusedIndicatorColor = Color.Gray,
placeholderColor = Color.Blue,
textColor = Color.Blue,
)
)
}
}
}
}
Jasmin Fajkic
10/25/2022, 7:54 PMJasmin Fajkic
10/25/2022, 7:55 PMJasmin Fajkic
10/25/2022, 7:56 PMColton Idle
10/25/2022, 10:22 PMJasmin Fajkic
10/26/2022, 6:02 AMval height = remember {
mutableStateOf(0)
}
val scope = rememberCoroutineScope()
val state = rememberLazyListState()
LaunchedEffect(key1 = height.value) {
state.animateScrollBy(100f)
}
val kbVisible = WindowInsets.isImeVisible
LaunchedEffect(key1 = kbVisible) {
if(!kbVisible) {
height.value = 0
}
}
TextField(
modifier = Modifier
.fillMaxWidth()
.onGloballyPositioned {
scope.launch {
height.value = it.size.height
}
},
value = post.value,
onValueChange = { text -> post.value = text },
placeholder = { Text("Enter something") },
colors = TextFieldDefaults.textFieldColors(
containerColor = Color.Gray,
disabledIndicatorColor = Color.Gray,
unfocusedIndicatorColor = Color.Gray,
focusedIndicatorColor = Color.Gray,
placeholderColor = Color.Blue,
textColor = Color.Blue,
)
)