Skip to content

Commit

Permalink
Re-factored the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
aritra-tech committed Mar 26, 2024
1 parent 3ef277b commit 7a63cb2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.material.icons.filled.AccessTime
import androidx.compose.material.icons.filled.DateRange
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.AssistChip
import androidx.compose.material3.BasicAlertDialog
import androidx.compose.material3.DatePicker
import androidx.compose.material3.DatePickerDialog
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -117,7 +118,6 @@ fun DateTimeDialog(
isOpen: Boolean = false,
isEdit: Boolean = false,
onDateTimeUpdated: (LocalDateTime) -> Unit,
onConfirmCallback: () -> Unit,
onDismissCallback: () -> Unit,
) {
var shouldShowDatePicker by remember {
Expand Down Expand Up @@ -208,7 +208,7 @@ fun DateTimeDialog(
}
}
if (isOpen && !isEdit) {
AlertDialog(onDismissRequest = onDismissCallback) {
BasicAlertDialog(onDismissRequest = onDismissCallback) {
Surface(
color = MaterialTheme.colorScheme.surface,
shape = RoundedCornerShape(8.dp),
Expand Down Expand Up @@ -236,7 +236,7 @@ fun DateTimeDialog(
modifier = Modifier.padding(bottom = 24.dp),
maxItemsInEachRow = 1
) {
ReminderDateTimeModel.values().forEach {
ReminderDateTimeModel.entries.forEach {
AssistChip(leadingIcon = {
Icon(imageVector = Icons.Default.AccessTime, contentDescription = "")
}, onClick = {
Expand All @@ -259,17 +259,6 @@ fun DateTimeDialog(
})
}
}
// TextButton(
// onClick = { onConfirmCallback() },
// shape = RoundedCornerShape(8.dp),
// modifier = Modifier.align(End)
// ) {
// Text(
// text = stringResource(R.string.confirm),
// fontSize = 16.sp,
// fontWeight = FontWeight.SemiBold
// )
// }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,37 +73,16 @@ fun AddEditScreen(
onUpdateReminderDateTime: (LocalDateTime?) -> Unit,
) {
val focus = LocalFocusManager.current

var title by remember {
mutableStateOf(note.title)
}
var description by remember {
mutableStateOf(note.note)
}
var showAddTodo by remember {
mutableStateOf(false)
}
val images = remember {
mutableStateListOf<Uri>()
}
val checklist = remember {
mutableStateListOf<Todo>()
}
val cancelDialogState = remember {
mutableStateOf(false)
}
var openCameraPreview by remember {
mutableStateOf(false)
}
var isEditDateTime by remember {
mutableStateOf(false)
}
var openDrawingScreen by remember {
mutableStateOf(false)
}
var shouldShowDialogDateTime by remember {
mutableStateOf(false)
}
var title by remember { mutableStateOf(note.title) }
var description by remember { mutableStateOf(note.note) }
var showAddTodo by remember { mutableStateOf(false) }
val images = remember { mutableStateListOf<Uri>() }
val checklist = remember { mutableStateListOf<Todo>() }
val cancelDialogState = remember { mutableStateOf(false) }
var openCameraPreview by remember { mutableStateOf(false) }
var isEditDateTime by remember { mutableStateOf(false) }
var openDrawingScreen by remember { mutableStateOf(false) }
var shouldShowDialogDateTime by remember { mutableStateOf(false) }

// Makes sure that the title is updated when the note is updated
LaunchedEffect(note.title) {
Expand Down Expand Up @@ -333,11 +312,13 @@ fun AddEditScreen(
}
)

DateTimeDialog(isOpen = shouldShowDialogDateTime, isEdit = isEditDateTime, onDateTimeUpdated = {
onUpdateReminderDateTime(it)
shouldShowDialogDateTime = false
}, onConfirmCallback = {
}) {
DateTimeDialog(
isOpen = shouldShowDialogDateTime, isEdit = isEditDateTime,
onDateTimeUpdated = {
onUpdateReminderDateTime(it)
shouldShowDialogDateTime = false
},
) {
shouldShowDialogDateTime = false
isEditDateTime = false
}
Expand Down

0 comments on commit 7a63cb2

Please sign in to comment.