This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun validateMedication( | |
name: String, | |
dosage: Int, | |
recurrence: String, | |
endDate: Long, | |
morningSelection: Boolean, | |
afternoonSelection: Boolean, | |
eveningSelection: Boolean, | |
nightSelection: Boolean, | |
onInvalidate: (Int) -> Unit, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(ExperimentalMaterial3Api::class) | |
@Composable | |
fun AddMedicationScreen() { | |
// Previously implemented code. | |
Column( | |
modifier = Modifier | |
.padding(16.dp, 16.dp) | |
.verticalScroll(rememberScrollState()), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun showMaxSelectionToast( | |
numberOfDosage: String, | |
context: Context | |
) { | |
Toast.makeText( | |
context, | |
"You're selecting ${(numberOfDosage.toIntOrNull() ?: 0) + 1} time(s) of days which is more than the number of dosage.", | |
Toast.LENGTH_LONG | |
).show() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun handleSelection( | |
isSelected: Boolean, | |
selectionCount: Int, | |
canSelectMoreTimesOfDay: Boolean, | |
onStateChange: (Int, Boolean) -> Unit, | |
onShowMaxSelectionError: () -> Unit | |
) { | |
if (isSelected) { | |
onStateChange(selectionCount - 1, !isSelected) | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(ExperimentalMaterial3Api::class) | |
@Composable | |
fun AddMedicationScreen() { | |
// Previously implemented code. | |
var isMorningSelected by rememberSaveable { mutableStateOf(false) } | |
var isAfternoonSelected by rememberSaveable { mutableStateOf(false) } | |
var isEveningSelected by rememberSaveable { mutableStateOf(false) } | |
var isNightSelected by rememberSaveable { mutableStateOf(false) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(ExperimentalMaterial3Api::class) | |
@Composable | |
fun EndDateTextField(endDate: (Long) -> Unit) { | |
Text( | |
text = stringResource(id = R.string.end_date), | |
style = MaterialTheme.typography.bodyLarge | |
) | |
val interactionSource = remember { MutableInteractionSource() } | |
val isPressed: Boolean by interactionSource.collectIsPressedAsState() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(ExperimentalMaterial3Api::class) | |
@Composable | |
fun AddMedicationScreen() { | |
// Previously implemented. | |
var endDate by rememberSaveable { mutableStateOf(Date().time) } | |
Column( | |
modifier = Modifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class TimesOfDay { | |
Morning, | |
Afternoon, | |
Evening, | |
Night | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(ExperimentalMaterial3Api::class) | |
@Composable | |
fun RecurrenceDropdownMenu(recurrence: (String) -> Unit) { | |
Column( | |
verticalArrangement = Arrangement.spacedBy(8.dp) | |
) { | |
Text( | |
text = stringResource(id = R.string.recurrence), | |
style = MaterialTheme.typography.bodyLarge | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(ExperimentalMaterial3Api::class) | |
@Composable | |
fun AddMedicationScreen() { | |
// Previously implememted. | |
var numberOfDosage by rememberSaveable { mutableStateOf("1") } | |
var recurrence by rememberSaveable { mutableStateOf(Recurrence.Daily.name) } | |
Column( | |
modifier = Modifier | |
.padding(16.dp, 16.dp) |
NewerOlder