File tree Expand file tree Collapse file tree
app/src/main/java/spam/blocker/ui Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import spam.blocker.service.SmsReceiver
2626import spam.blocker.ui.theme.DarkOrange
2727import spam.blocker.ui.theme.LocalPalette
2828import spam.blocker.ui.theme.Teal200
29+ import spam.blocker.ui.widgets.AnimatedVisibleV
2930import spam.blocker.ui.widgets.BalloonQuestionMark
3031import spam.blocker.ui.widgets.GreyLabel
3132import spam.blocker.ui.widgets.PopupDialog
@@ -158,7 +159,7 @@ fun PopupTesting(
158159 },
159160 )
160161 // SMS content
161- if (vm.selectedType.intValue != Def .ForNumber ) {
162+ AnimatedVisibleV (vm.selectedType.intValue != Def .ForNumber ) {
162163 StrInputBox (
163164 text = vm.sms.value,
164165 label = { GreyLabel (Str (R .string.sms_content)) },
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import androidx.compose.ui.layout.onGloballyPositioned
3636import androidx.compose.ui.layout.positionOnScreen
3737import androidx.compose.ui.platform.LocalContext
3838import androidx.compose.ui.semantics.semantics
39+ import androidx.compose.ui.text.TextRange
3940import androidx.compose.ui.text.TextStyle
4041import androidx.compose.ui.text.font.FontWeight
4142import androidx.compose.ui.text.input.KeyboardType
@@ -241,11 +242,21 @@ fun NumberInputBox(
241242 helpTooltip : @Composable (() -> Unit )? = null,
242243) {
243244 // Code learned from the built-in BasicTextField.kt
244- var state by remember(intValue) {
245+ var state by remember {
245246 mutableStateOf(
246247 TextFieldValue (text = intValue?.toString() ? : " " )
247248 )
248249 }
250+ LaunchedEffect (intValue) {
251+ if (intValue?.toString() != state.text) {
252+ state = TextFieldValue (
253+ text = intValue?.toString() ? : " " ,
254+ selection = TextRange (intValue?.toString()?.length ? : 0 )
255+ )
256+ }
257+ }
258+
259+
249260 // Last String value that either text field was recomposed with or updated in the onValueChange
250261 // callback. We keep track of it to prevent calling onValueChange(String) for same String when
251262 // CoreTextField's onValueChange is called multiple times without recomposition in between.
You can’t perform that action at this time.
0 commit comments