@@ -11,13 +11,15 @@ import androidx.compose.foundation.layout.fillMaxWidth
1111import androidx.compose.foundation.layout.padding
1212import androidx.compose.foundation.lazy.LazyColumn
1313import androidx.compose.foundation.lazy.items
14+ import androidx.compose.foundation.lazy.rememberLazyListState
1415import androidx.compose.foundation.shape.RoundedCornerShape
1516import androidx.compose.foundation.text.BasicTextField
1617import androidx.compose.material3.MaterialTheme
1718import androidx.compose.material3.Text
1819import androidx.compose.material3.surfaceColorAtElevation
1920import androidx.compose.runtime.Composable
2021import androidx.compose.runtime.CompositionLocalProvider
22+ import androidx.compose.runtime.LaunchedEffect
2123import androidx.compose.ui.Alignment
2224import androidx.compose.ui.Modifier
2325import androidx.compose.ui.draw.clip
@@ -41,11 +43,18 @@ fun ColumnScope.CalculatorDisplay(
4143 .clip(RoundedCornerShape (24 .dp))
4244 .background(MaterialTheme .colorScheme.surfaceColorAtElevation(10 .dp))
4345 ) {
46+ val listState = rememberLazyListState()
47+
48+ LaunchedEffect (calculatorViewModel.history.toList()) {
49+ if (calculatorViewModel.history.isNotEmpty())
50+ listState.animateScrollToItem(calculatorViewModel.history.size - 1 );
51+ }
4452 LazyColumn (
4553 Modifier
4654 .fillMaxWidth()
4755 .padding(horizontal = 16 .dp, vertical = 8 .dp)
4856 .weight(1f ),
57+ state = listState,
4958 horizontalAlignment = Alignment .End ,
5059 verticalArrangement = Arrangement .spacedBy(8 .dp, alignment = Alignment .Bottom )
5160 ) {
0 commit comments