Skip to content

Instantly share code, notes, and snippets.

@Arunshaik2001
Created November 6, 2022 14:55
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 Arunshaik2001/3dfbfc6cdba20b6f4e39aae1e8cb2bf7 to your computer and use it in GitHub Desktop.
Save Arunshaik2001/3dfbfc6cdba20b6f4e39aae1e8cb2bf7 to your computer and use it in GitHub Desktop.
@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