@@ -21,7 +21,6 @@ import androidx.compose.ui.Modifier
2121import androidx.compose.ui.graphics.Color
2222import androidx.compose.ui.platform.LocalContext
2323import androidx.compose.ui.res.dimensionResource
24- import androidx.compose.ui.res.painterResource
2524import androidx.compose.ui.res.stringArrayResource
2625import androidx.compose.ui.res.stringResource
2726import androidx.compose.ui.text.AnnotatedString
@@ -555,94 +554,33 @@ private fun ColumnScope.ActionPage(viewModel: UpsertFilterViewModel) {
555554 }
556555 }
557556 AnimatedVisibility (it is Action .BATCH && viewModel.state.values.action is Action .BATCH ) {
558- Row (
559- Modifier .fillMaxWidth(),
560- Arrangement .Center ,
561- Alignment .CenterVertically ,
562- ) {
563- val batchLength = (viewModel.state.values.action as ? Action .BATCH )?.batchLength ? : 3
564- IconButton (
565- {
566- viewModel.updateForm(
567- viewModel.state.page,
568- viewModel.state.values.copy(action = Action .BATCH ((batchLength - 1 ))),
569- )
570- },
571- enabled = batchLength > 1 ,
572- ) {
573- Icon (
574- painterResource(R .drawable.remove),
575- contentDescription = stringResource(R .string.alttext_subtract),
576- )
577- }
578- Text (
579- stringResource(
580- R .string.batch_frequency,
581- batchLength.toString().padStart(2 , ' 0' ),
582- ),
557+ IntegerInput (
558+ (viewModel.state.values.action as ? Action .BATCH )?.batchLength ? : 3 ,
559+ 1 ,
560+ 12 ,
561+ R .string.batch_frequency,
562+ ) { value ->
563+ viewModel.updateForm(
564+ viewModel.state.page,
565+ viewModel.state.values.copy(action = Action .BATCH (value)),
583566 )
584- IconButton (
585- {
586- viewModel.updateForm(
587- viewModel.state.page,
588- viewModel.state.values.copy(action = Action .BATCH ((batchLength + 1 ))),
589- )
590- },
591- enabled = batchLength < 12 ,
592- ) {
593- Icon (
594- painterResource(R .drawable.add),
595- contentDescription = stringResource(R .string.alttext_add),
596- )
597- }
598567 }
599568 }
600569 AnimatedVisibility (it is Action .DEBOUNCE && viewModel.state.values.action is Action .DEBOUNCE ) {
601570 Column (
602571 Modifier .fillMaxWidth(),
603572 Arrangement .spacedBy(dimensionResource(R .dimen.padding_medium)),
604573 ) {
605- Row (
606- Modifier .fillMaxWidth(),
607- Arrangement .Center ,
608- Alignment .CenterVertically ,
609- ) {
610- val cooldownLength =
611- (viewModel.state.values.action as ? Action .DEBOUNCE )?.cooldownLength ? : 2
612- IconButton (
613- {
614- viewModel.updateForm(
615- viewModel.state.page,
616- viewModel.state.values.copy(action = Action .DEBOUNCE ((cooldownLength - 1 ))),
617- )
618- },
619- enabled = cooldownLength > 1 ,
620- ) {
621- Icon (
622- painterResource(R .drawable.remove),
623- contentDescription = stringResource(R .string.alttext_subtract),
624- )
625- }
626- Text (
627- stringResource(
628- R .string.cooldown_length,
629- cooldownLength.toString().padStart(2 , ' 0' ),
630- ),
574+ IntegerInput (
575+ (viewModel.state.values.action as ? Action .DEBOUNCE )?.cooldownLength ? : 2 ,
576+ 1 ,
577+ 30 ,
578+ R .string.cooldown_length,
579+ ) { value ->
580+ viewModel.updateForm(
581+ viewModel.state.page,
582+ viewModel.state.values.copy(action = Action .DEBOUNCE (value)),
631583 )
632- IconButton (
633- {
634- viewModel.updateForm(
635- viewModel.state.page,
636- viewModel.state.values.copy(action = Action .DEBOUNCE ((cooldownLength + 1 ))),
637- )
638- },
639- enabled = cooldownLength < 15 ,
640- ) {
641- Icon (
642- painterResource(R .drawable.add),
643- contentDescription = stringResource(R .string.alttext_add),
644- )
645- }
646584 }
647585 Text (
648586 stringResource(R .string.explain_debounce),
@@ -682,47 +620,16 @@ private fun ColumnScope.ActionPage(viewModel: UpsertFilterViewModel) {
682620 Modifier .fillMaxWidth(),
683621 Arrangement .spacedBy(dimensionResource(R .dimen.padding_medium)),
684622 ) {
685- Row (
686- Modifier .fillMaxWidth(),
687- Arrangement .Center ,
688- Alignment .CenterVertically ,
689- ) {
690- val pauseLength =
691- (viewModel.state.values.action as ? Action .DISTURB )?.pauseLength ? : 5
692- IconButton (
693- {
694- viewModel.updateForm(
695- viewModel.state.page,
696- viewModel.state.values.copy(action = Action .DISTURB ((pauseLength - 1 ))),
697- )
698- },
699- enabled = pauseLength > 1 ,
700- ) {
701- Icon (
702- painterResource(R .drawable.remove),
703- contentDescription = stringResource(R .string.alttext_subtract),
704- )
705- }
706- Text (
707- stringResource(
708- R .string.pause_length,
709- pauseLength.toString().padStart(2 , ' 0' ),
710- ),
623+ IntegerInput (
624+ (viewModel.state.values.action as ? Action .DISTURB )?.pauseLength ? : 5 ,
625+ 1 ,
626+ 30 ,
627+ R .string.pause_length,
628+ ) { value ->
629+ viewModel.updateForm(
630+ viewModel.state.page,
631+ viewModel.state.values.copy(action = Action .DISTURB (value)),
711632 )
712- IconButton (
713- {
714- viewModel.updateForm(
715- viewModel.state.page,
716- viewModel.state.values.copy(action = Action .DISTURB ((pauseLength + 1 ))),
717- )
718- },
719- enabled = pauseLength < 15 ,
720- ) {
721- Icon (
722- painterResource(R .drawable.add),
723- contentDescription = stringResource(R .string.alttext_add),
724- )
725- }
726633 }
727634 if (! hasPermissions.getValue(Permission .NOTIFICATION_POLICY )) {
728635 ErrorText (R .string.notification_policy_permission_description)
@@ -747,48 +654,19 @@ private fun ColumnScope.ActionPage(viewModel: UpsertFilterViewModel) {
747654 Modifier .fillMaxWidth(),
748655 Arrangement .spacedBy(dimensionResource(R .dimen.padding_medium)),
749656 ) {
750- Row (
751- Modifier .fillMaxWidth(),
752- Arrangement .Center ,
753- Alignment .CenterVertically ,
754- ) {
755- val retentionLength =
756- (viewModel.state.values.action as ? Action .DISMISS_STALE )?.retentionLength
757- ? : 10
758- IconButton (
759- {
760- viewModel.updateForm(
761- viewModel.state.page,
762- viewModel.state.values.copy(action = Action .DISMISS_STALE ((retentionLength - 5 ))),
763- )
764- },
765- enabled = retentionLength > 5 ,
766- ) {
767- Icon (
768- painterResource(R .drawable.remove),
769- contentDescription = stringResource(R .string.alttext_subtract),
770- )
771- }
772- Text (
773- stringResource(
774- R .string.retention_length,
775- retentionLength.toString().padStart(2 , ' 0' ),
776- ),
657+ IntegerInput (
658+ (viewModel.state.values.action as ? Action .DISMISS_STALE )?.retentionLength ? : 15 ,
659+ 5 ,
660+ 300 ,
661+ R .string.retention_length,
662+ 5 ,
663+ 30 ,
664+ 3 ,
665+ ) { value ->
666+ viewModel.updateForm(
667+ viewModel.state.page,
668+ viewModel.state.values.copy(action = Action .DISMISS_STALE (value)),
777669 )
778- IconButton (
779- {
780- viewModel.updateForm(
781- viewModel.state.page,
782- viewModel.state.values.copy(action = Action .DISMISS_STALE ((retentionLength + 5 ))),
783- )
784- },
785- enabled = retentionLength < 60 ,
786- ) {
787- Icon (
788- painterResource(R .drawable.add),
789- contentDescription = stringResource(R .string.alttext_add),
790- )
791- }
792670 }
793671 if (! hasPermissions.getValue(Permission .SCHEDULE_EXACT_ALARM )) {
794672 ErrorText (R .string.exact_alarm_permission_description)
0 commit comments