Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
Signed-off-by: rapterjet2004 <[email protected]>
  • Loading branch information
rapterjet2004 committed Dec 20, 2024
1 parent fc9451f commit 99f1c46
Showing 1 changed file with 61 additions and 61 deletions.
122 changes: 61 additions & 61 deletions app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimeCompose.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import javax.inject.Inject

@AutoInjector(NextcloudTalkApplication::class)
class DateTimeCompose(val bundle: Bundle) {
private var timeState = mutableStateOf(LocalDateTime.ofEpochSecond(0,0, ZoneOffset.MIN))
private var timeState = mutableStateOf(LocalDateTime.ofEpochSecond(0, 0, ZoneOffset.MIN))

init {
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
Expand Down Expand Up @@ -108,20 +108,20 @@ class DateTimeCompose(val bundle: Bundle) {
usePlatformDefaultWidth = isCollapsed.value
)
) {
Surface(
shape = RoundedCornerShape(8.dp),
modifier = Modifier.animateContentSize()
) {
Column(
modifier = Modifier
.padding(16.dp)
.fillMaxWidth()
) {
Header()
Body()
CollapsableDateTime(shouldDismiss, isCollapsed)
}
}
Surface(
shape = RoundedCornerShape(8.dp),
modifier = Modifier.animateContentSize()
) {
Column(
modifier = Modifier
.padding(16.dp)
.fillMaxWidth()
) {
Header()
Body()
CollapsableDateTime(shouldDismiss, isCollapsed)
}
}
}
}
}
Expand All @@ -131,42 +131,45 @@ class DateTimeCompose(val bundle: Bundle) {
Row(
modifier = Modifier.fillMaxWidth()
) {
TextButton(onClick = {
val user = userManager.currentUser.blockingGet()
val roomToken = bundle.getString(BundleKeys.KEY_ROOM_TOKEN)!!
val messageId = bundle.getString(BundleKeys.KEY_MESSAGE_ID)!!
val apiVersion = bundle.getInt(BundleKeys.KEY_CHAT_API_VERSION)
chatViewModel.deleteReminder(user, roomToken, messageId, apiVersion)
shouldDismiss.value = true
},
modifier = Modifier
.weight(.33f)
TextButton(
onClick = {
val user = userManager.currentUser.blockingGet()
val roomToken = bundle.getString(BundleKeys.KEY_ROOM_TOKEN)!!
val messageId = bundle.getString(BundleKeys.KEY_MESSAGE_ID)!!
val apiVersion = bundle.getInt(BundleKeys.KEY_CHAT_API_VERSION)
chatViewModel.deleteReminder(user, roomToken, messageId, apiVersion)
shouldDismiss.value = true
},
modifier = Modifier
.weight(.33f)
) {
Text(
"Delete",
color = Color.Red,
color = Color.Red
)
}

TextButton(onClick = {
val user = userManager.currentUser.blockingGet()
val roomToken = bundle.getString(BundleKeys.KEY_ROOM_TOKEN)!!
val messageId = bundle.getString(BundleKeys.KEY_MESSAGE_ID)!!
val apiVersion = bundle.getInt(BundleKeys.KEY_CHAT_API_VERSION)
val offset = timeState.value.atZone(ZoneOffset.systemDefault()).offset
val timeVal = timeState.value.toEpochSecond(offset)
chatViewModel.setReminder(user, roomToken, messageId, timeVal.toInt(), apiVersion)
shouldDismiss.value = true
},
TextButton(
onClick = {
val user = userManager.currentUser.blockingGet()
val roomToken = bundle.getString(BundleKeys.KEY_ROOM_TOKEN)!!
val messageId = bundle.getString(BundleKeys.KEY_MESSAGE_ID)!!
val apiVersion = bundle.getInt(BundleKeys.KEY_CHAT_API_VERSION)
val offset = timeState.value.atZone(ZoneOffset.systemDefault()).offset
val timeVal = timeState.value.toEpochSecond(offset)
chatViewModel.setReminder(user, roomToken, messageId, timeVal.toInt(), apiVersion)
shouldDismiss.value = true
},
modifier = Modifier
.weight(.33f)
) {
Text("Set")
}

TextButton(onClick = {
shouldDismiss.value = true
},
TextButton(
onClick = {
shouldDismiss.value = true
},
modifier = Modifier
.weight(.33f)
) {
Expand All @@ -183,29 +186,29 @@ class DateTimeCompose(val bundle: Bundle) {
.withHour(18)
.withMinute(0)
.withSecond(0)
val laterTodayStr = laterToday.format(DateTimeFormatter.ofPattern("dd MMM, HH:mm a"))
val laterTodayStr = laterToday.format(DateTimeFormatter.ofPattern(PATTERN))

val tomorrow = LocalDateTime.now()
.plusDays(1)
.withHour(8)
.withMinute(0)
.withSecond(0)
val tomorrowStr = tomorrow.format(DateTimeFormatter.ofPattern("dd MMM, HH:mm a"))
val tomorrowStr = tomorrow.format(DateTimeFormatter.ofPattern(PATTERN))

val thisWeekend = LocalDateTime.now()
.with(nextOrSame(DayOfWeek.SATURDAY))
.withHour(8)
.withMinute(0)
.withSecond(0)
val thisWeekendStr = thisWeekend.format(DateTimeFormatter.ofPattern("dd MMM, HH:mm a"))
val thisWeekendStr = thisWeekend.format(DateTimeFormatter.ofPattern(PATTERN))

val nextWeek = LocalDateTime.now()
.plusWeeks(1)
.with(nextOrSame(DayOfWeek.MONDAY))
.withHour(8)
.withMinute(0)
.withSecond(0)
val nextWeekStr = nextWeek.format(DateTimeFormatter.ofPattern("dd MMM, HH:mm a"))
val nextWeekStr = nextWeek.format(DateTimeFormatter.ofPattern(PATTERN))

if (currTime < laterToday) {
TimeOption(
Expand Down Expand Up @@ -251,22 +254,23 @@ class DateTimeCompose(val bundle: Bundle) {
.padding(8.dp)
) {
Text("Remind Me Later", modifier = Modifier.weight(1f))
// Spacer(modifier = Modifier.width(32.dp))

val reminderState = chatViewModel.getReminderExistState
.asFlow()
.collectAsState(ChatViewModel.GetReminderStartState)

when (reminderState.value) {
is ChatViewModel.GetReminderExistState -> {
val timeL = (reminderState.value as ChatViewModel.GetReminderExistState).reminder.timestamp!!.toLong()
val timeL =
(reminderState.value as ChatViewModel.GetReminderExistState).reminder.timestamp!!.toLong()
timeState.value = LocalDateTime.ofInstant(Instant.ofEpochSecond(timeL), ZoneId.systemDefault())
}

else -> {}
}

if (timeState.value != LocalDateTime.ofEpochSecond(0,0, ZoneOffset.MIN)) {
Text(timeState.value.format(DateTimeFormatter.ofPattern("dd MMM, HH:mm a")))
if (timeState.value != LocalDateTime.ofEpochSecond(0, 0, ZoneOffset.MIN)) {
Text(timeState.value.format(DateTimeFormatter.ofPattern(PATTERN)))
}
}
HorizontalDivider()
Expand All @@ -286,11 +290,11 @@ class DateTimeCompose(val bundle: Bundle) {
val timePickerState = rememberTimePickerState()

DatePicker(
state = datePickerState,
state = datePickerState
)

TimePicker(
state = timePickerState,
state = timePickerState
)

val date = datePickerState.selectedDateMillis?.let {
Expand All @@ -307,20 +311,16 @@ class DateTimeCompose(val bundle: Bundle) {
} else {
timeState.value = LocalDate.now().atTime(timePickerState.hour, timePickerState.minute)
}

}
Submission(shouldDismiss)
}
}

@Composable
fun GeneralIconButton(
icon: ImageVector,
label: String,
onClick: () -> Unit
) {
fun GeneralIconButton(icon: ImageVector, label: String, onClick: () -> Unit) {
TextButton(
onClick = onClick) {
onClick = onClick
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start
Expand All @@ -337,11 +337,7 @@ class DateTimeCompose(val bundle: Bundle) {
}

@Composable
private fun TimeOption(
label: String,
timeString: String,
onClick: () -> Unit
) {
private fun TimeOption(label: String, timeString: String, onClick: () -> Unit) {
Row(
modifier = Modifier
.fillMaxWidth()
Expand All @@ -353,6 +349,10 @@ class DateTimeCompose(val bundle: Bundle) {
}
}

companion object {
private const val PATTERN = "dd MMM, HH:mm a"
}

// Preview Logic
// class DummyProvider : PreviewParameterProvider<String> {
// override val values: Sequence<String> = sequenceOf()
Expand Down

0 comments on commit 99f1c46

Please sign in to comment.