-
-
Save Arunshaik2001/3dfbfc6cdba20b6f4e39aae1e8cb2bf7 to your computer and use it in GitHub Desktop.
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
@Composable | |
fun ReminderEditScreen() { | |
Scaffold() { | |
val titleInputValue = remember { mutableStateOf(TextFieldValue()) } | |
val titleError = remember { mutableStateOf("") } | |
val descriptionInputValue = remember { mutableStateOf(TextFieldValue()) } | |
val descriptionError = remember { mutableStateOf("") } | |
var localDateTime: LocalDateTime? by remember { | |
mutableStateOf(null) | |
} | |
val remindTypeState = remember { | |
mutableStateOf(RemindType.NONE) | |
} | |
val mContext = LocalContext.current | |
BoxWithLayout { | |
Column( | |
Modifier | |
.padding(10.dp) | |
.fillMaxSize() | |
.verticalScroll(rememberScrollState()) | |
.weight(1f, false), | |
horizontalAlignment = Alignment.CenterHorizontally, | |
verticalArrangement = Arrangement.SpaceEvenly | |
) { | |
Text( | |
text = "Set Reminder", | |
fontSize = 30.sp, | |
fontWeight = FontWeight.Bold | |
) | |
Spacer(modifier = Modifier.height(10.dp)) | |
OutlinedTextFieldValidation(value = titleInputValue.value.text, onValueChange = { | |
titleInputValue.value = TextFieldValue(it) | |
}, placeholder = { | |
Text( | |
text = "Enter your title" | |
) | |
}, | |
keyboardOptions = KeyboardOptions( | |
capitalization = KeyboardCapitalization.None, | |
autoCorrect = true, | |
keyboardType = KeyboardType.Text, | |
imeAction = ImeAction.Done | |
), | |
textStyle = TextStyle( | |
color = Color.Black, fontSize = TextUnit.Unspecified, | |
fontFamily = FontFamily.SansSerif | |
), | |
maxLines = 1, | |
singleLine = true, | |
modifier = Modifier | |
.border(5.dp, Color.Unspecified, RoundedCornerShape(10.dp)) | |
.fillMaxWidth() | |
.background( | |
color = Color(0xffe2ebf0), | |
shape = CircleShape | |
), | |
shape = CircleShape, | |
error = titleError.value | |
) | |
Spacer(modifier = Modifier.height(10.dp)) | |
OutlinedTextFieldValidation( | |
value = descriptionInputValue.value.text, | |
onValueChange = { | |
descriptionInputValue.value = TextFieldValue(it) | |
}, | |
placeholder = { | |
Text( | |
text = "Enter your subtitle" | |
) | |
}, | |
keyboardOptions = KeyboardOptions( | |
capitalization = KeyboardCapitalization.None, | |
autoCorrect = true, | |
keyboardType = KeyboardType.Text, | |
imeAction = ImeAction.Done | |
), | |
textStyle = TextStyle( | |
color = Color.Black, fontSize = TextUnit.Unspecified, | |
fontFamily = FontFamily.SansSerif | |
), | |
maxLines = 1, | |
singleLine = true, | |
modifier = Modifier | |
.fillMaxWidth() | |
.background( | |
color = Color(0xffe2ebf0), | |
shape = CircleShape | |
), | |
shape = CircleShape, | |
error = descriptionError.value | |
) | |
Spacer(modifier = Modifier.height(10.dp)) | |
DatePicker { | |
localDateTime = it | |
} | |
Spacer(modifier = Modifier.height(20.dp)) | |
TimePicker(localDateTime) { | |
localDateTime = it | |
} | |
RepeatTypeDropDown { | |
remindTypeState.value = it | |
} | |
Button(onClick = { | |
val result = validateData( | |
titleInputValue, | |
descriptionInputValue, | |
titleError, | |
descriptionError, | |
localDateTime, | |
mContext | |
) | |
if (!result) { | |
return@Button | |
} | |
val title = titleInputValue.value.text | |
val description = descriptionInputValue.value.text | |
val startTimeInMillis = | |
localDateTime!!.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() | |
val reminderType = remindTypeState.value.toString() | |
val intent = Intent() | |
intent.action = Intent.ACTION_SEND | |
intent.data = | |
Uri.parse("remindme://reminder?title=${title}&description=${description}&startTimeInMillis=${startTimeInMillis}&reminderType=${reminderType}") | |
mContext.startActivity(intent) | |
}) { | |
Text(text = "Set Reminder") | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment