Thread
#compose
    p

    Philip Blandford

    1 year ago
    Struggling to get a chat-like interface behaving correctly - I'm using accompanist-insets to set the padding, but about half the time it shoots the textfield nearly to the top of the screen.
    @Composable
    @Preview
    private fun InsetsTest() {
      val activity = LocalContext.current as Activity
      WindowCompat.setDecorFitsSystemWindows(activity.window, false)
    
      MaterialTheme {
        ProvideWindowInsets {
    
          val text = remember { mutableStateOf("") }
    
          Column(
            Modifier
              .fillMaxSize()
              .background(Color.White)
          ) {
            Box(
              Modifier
                .fillMaxWidth()
                .weight(1f)
                .background(Color.LightGray)
            )
            Column(
              Modifier
                .navigationBarsWithImePadding()
                .background(Color.Yellow)) {
              BasicTextField(
                text.value,
                { text.value = it },
                Modifier
                  .fillMaxWidth()
                  .heightIn(50.dp)
              )
              Box(Modifier.height(50.dp))
            }
          }
        }
      }
    }
    cb

    cb

    1 year ago
    I can’t see anything obviously wrong from the code snippet FYI