Skip to content

Instantly share code, notes, and snippets.

@waseefakhtar
Last active August 29, 2023 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waseefakhtar/ed26d03491c0ebbbc571c49ccc705cc3 to your computer and use it in GitHub Desktop.
Save waseefakhtar/ed26d03491c0ebbbc571c49ccc705cc3 to your computer and use it in GitHub Desktop.
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AddMedicationScreen() {
// Previously implemented code.
Column(
modifier = Modifier
.padding(16.dp, 16.dp)
.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
// Previously implemented code.
Spacer(modifier = Modifier.padding(8.dp))
Button(
modifier = Modifier
.fillMaxWidth()
.height(56.dp)
.align(Alignment.CenterHorizontally),
onClick = {
validateMedication(
name = medicationName,
dosage = numberOfDosage.toIntOrNull() ?: 0,
recurrence = recurrence,
endDate = endDate,
morningSelection = isMorningSelected,
afternoonSelection = isAfternoonSelected,
eveningSelection = isEveningSelected,
nightSelection = isNightSelected,
onInvalidate = {
Toast.makeText(
context,
context.getString(R.string.value_is_empty, context.getString(it)),
Toast.LENGTH_LONG
).show()
},
onValidate = {
// TODO: Navigate to next screen / Store medication info
Toast.makeText(
context,
context.getString(R.string.success),
Toast.LENGTH_LONG
).show()
}
)
},
shape = MaterialTheme.shapes.extraLarge
) {
Text(
text = stringResource(id = R.string.save),
style = MaterialTheme.typography.bodyLarge
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment