@@ -64,11 +64,13 @@ import androidx.compose.ui.Modifier
6464import androidx.compose.ui.draw.clip
6565import androidx.compose.ui.graphics.Brush
6666import androidx.compose.ui.graphics.Color
67+ import androidx.compose.ui.layout.onSizeChanged
6768import androidx.compose.ui.text.font.FontWeight
6869import androidx.compose.ui.text.style.TextAlign
6970import androidx.compose.ui.unit.dp
7071import androidx.compose.ui.unit.sp
7172import androidx.compose.ui.platform.LocalContext
73+ import androidx.compose.ui.platform.LocalDensity
7274import androidx.lifecycle.viewmodel.compose.viewModel
7375import java.text.SimpleDateFormat
7476import java.util.Date
@@ -139,8 +141,10 @@ class MainActivity : ComponentActivity() {
139141fun ChatScreen (executor : AutomationExecutor ) {
140142 val viewModel: ChatViewModel = viewModel()
141143 val context = LocalContext .current
144+ val density = LocalDensity .current
142145 var inputText by rememberSaveable { mutableStateOf(" " ) }
143146 var endpointUrl by rememberSaveable { mutableStateOf(viewModel.agentUrl) }
147+ var composerHeightPx by rememberSaveable { mutableStateOf(0 ) }
144148 val listState = rememberLazyListState()
145149
146150 val speechLauncher = rememberLauncherForActivityResult(ActivityResultContracts .StartActivityForResult ()) { result ->
@@ -182,6 +186,8 @@ fun ChatScreen(executor: AutomationExecutor) {
182186 }
183187 }
184188
189+ val composerBottomInset = with (density) { composerHeightPx.toDp() }
190+
185191 Box (
186192 modifier = Modifier
187193 .fillMaxSize()
@@ -242,7 +248,7 @@ fun ChatScreen(executor: AutomationExecutor) {
242248 modifier = Modifier
243249 .fillMaxSize()
244250 .padding(horizontal = 16 .dp)
245- .padding(bottom = 132 .dp ),
251+ .padding(bottom = composerBottomInset ),
246252 verticalArrangement = Arrangement .spacedBy(12 .dp),
247253 ) {
248254 item { Spacer (Modifier .height(12 .dp)) }
@@ -265,7 +271,9 @@ fun ChatScreen(executor: AutomationExecutor) {
265271 },
266272 enabled = viewModel.isConnected && ! viewModel.isConnecting,
267273 isConnecting = viewModel.isConnecting,
268- modifier = Modifier .align(Alignment .BottomCenter ),
274+ modifier = Modifier
275+ .align(Alignment .BottomCenter )
276+ .onSizeChanged { composerHeightPx = it.height },
269277 )
270278 }
271279 }
0 commit comments