Skip to content

Commit

Permalink
feat: [ANDROAPP-5802] sonarqube
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmateos committed Feb 2, 2024
1 parent 005f879 commit 27948f7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import org.dhis2.commons.di.dagger.PerFragment

@PerFragment
@Subcomponent(modules = [SchedulingModule::class])
interface SchedulingComponent {
fun interface SchedulingComponent {
fun inject(schedulingDialog: SchedulingDialog)
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class SchedulingDialog(
dialog.isFutureDatesAllowed(viewModel.eventDate.value.allowFutureDates)
dialog.setListener(
object : OnDatePickerListener {
override fun onNegativeClick() {}
override fun onNegativeClick() {
// Unused
}
override fun onPositiveClick(datePicker: DatePicker) {
viewModel.onDateSet(
datePicker.year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,24 @@ fun SchedulingDialogUi(
derivedStateOf { optionSelected == yesNoOptions.first() }
}

val onButtonClick = {
when {
scheduleNew -> viewModel.scheduleEvent()
else -> onDismiss()
}
}
BottomSheetShell(
title = stringResource(id = R.string.schedule_next) + " " + when (programStages.size) {
1 -> programStages.first().displayName()
else -> stringResource(id = R.string.event)
} + "?",
title = bottomSheetTitle(programStages),
buttonBlock = {
Button(
modifier = Modifier.fillMaxWidth(),
style = ButtonStyle.FILLED,
enabled = !scheduleNew ||
!date.dateValue.isNullOrEmpty() &&
catCombo.isCompleted,
text = when (scheduleNew) {
true -> stringResource(id = R.string.schedule)
false -> stringResource(id = R.string.done)
},
) {
if (scheduleNew) {
viewModel.scheduleEvent()
} else {
onDismiss()
}
}
text = buttonTitle(scheduleNew),
onClick = onButtonClick,
)
},
showSectionDivider = false,
content = {
Expand Down Expand Up @@ -143,3 +138,17 @@ fun SchedulingDialogUi(
onDismiss = onDismiss,
)
}

@Composable
fun bottomSheetTitle(programStages: List<ProgramStage>): String =
stringResource(id = R.string.schedule_next) + " " +
when (programStages.size) {
1 -> programStages.first().displayName()
else -> stringResource(id = R.string.event)
} + "?"

@Composable
fun buttonTitle(scheduleNew: Boolean): String = when (scheduleNew) {
true -> stringResource(id = R.string.schedule)
false -> stringResource(id = R.string.done)
}

0 comments on commit 27948f7

Please sign in to comment.