Skip to content

Commit

Permalink
Impl changes, unable to replicate 1.)
Browse files Browse the repository at this point in the history
Signed-off-by: rapterjet2004 <[email protected]>
  • Loading branch information
rapterjet2004 authored and mahibi committed Jan 9, 2025
1 parent f5fece9 commit dcffa62
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class ChatViewModel @Inject constructor(

object GetReminderStartState : ViewState
open class GetReminderExistState(val reminder: Reminder) : ViewState
object GetReminderStateSet : ViewState

private val _getReminderExistState: MutableLiveData<ViewState> = MutableLiveData(GetReminderStartState)

Expand Down Expand Up @@ -310,6 +311,10 @@ class ChatViewModel @Inject constructor(
?.subscribe(GetReminderObserver())
}

fun overrideReminderState() {
_getReminderExistState.value = GetReminderStateSet
}

fun deleteReminder(user: User, roomToken: String, messageId: String, chatApiVersion: Int) {
chatNetworkDataSource.deleteReminder(user, roomToken, messageId, chatApiVersion)
.subscribeOn(Schedulers.io())
Expand Down Expand Up @@ -754,7 +759,7 @@ class ChatViewModel @Inject constructor(
val model = ConversationModel.mapToConversationModel(it, userProvider.currentUser.blockingGet())
ConversationUtils.isNoteToSelfConversation(model)
}
_getNoteToSelfAvailability.value = NoteToSelfAvailableState(noteToSelf.token!!)
_getNoteToSelfAvailability.value = NoteToSelfAvailableState(noteToSelf.token)
} catch (e: NoSuchElementException) {
_getNoteToSelfAvailability.value = NoteToSelfNotAvailableState
Log.e(TAG, "Note to self not found $e")
Expand Down
32 changes: 22 additions & 10 deletions app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimeCompose.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class DateTimeCompose(val bundle: Bundle) {
@Inject
lateinit var viewThemeUtils: ViewThemeUtils

// TODO, can't seem to replicate 1.) on Sow's comment
// TODO make an issue out of the problem I gave marcel

@Composable
fun GetDateTimeDialog(shouldDismiss: MutableState<Boolean>, context: Context) {
if (shouldDismiss.value) {
Expand Down Expand Up @@ -144,7 +147,7 @@ class DateTimeCompose(val bundle: Bundle) {
.weight(CUBED_PADDING)
) {
Text(
"Delete",
stringResource(R.string.nc_delete),
color = Color.Red
)
}
Expand All @@ -163,7 +166,7 @@ class DateTimeCompose(val bundle: Bundle) {
modifier = Modifier
.weight(CUBED_PADDING)
) {
Text("Set")
Text(stringResource(R.string.set))
}

TextButton(
Expand All @@ -173,7 +176,7 @@ class DateTimeCompose(val bundle: Bundle) {
modifier = Modifier
.weight(CUBED_PADDING)
) {
Text("Close")
Text(stringResource(R.string.close))
}
}
}
Expand Down Expand Up @@ -215,7 +218,7 @@ class DateTimeCompose(val bundle: Bundle) {
label = stringResource(R.string.later_today),
timeString = laterTodayStr
) {
timeState.value = laterToday
setTime(laterToday)
}
}

Expand All @@ -224,7 +227,7 @@ class DateTimeCompose(val bundle: Bundle) {
label = stringResource(R.string.tomorrow),
timeString = tomorrowStr
) {
timeState.value = tomorrow
setTime(tomorrow)
}
}

Expand All @@ -233,27 +236,32 @@ class DateTimeCompose(val bundle: Bundle) {
label = stringResource(R.string.this_weekend),
timeString = thisWeekendStr
) {
timeState.value = thisWeekend
setTime(thisWeekend)
}
}

TimeOption(
label = stringResource(R.string.next_week),
timeString = nextWeekStr
) {
timeState.value = nextWeek
setTime(nextWeek)
}

HorizontalDivider()
}

private fun setTime(localDateTime: LocalDateTime) {
timeState.value = localDateTime
chatViewModel.overrideReminderState()
}

@Composable
private fun Header() {
Row(
modifier = Modifier
.padding(INT_8.dp)
) {
Text("Remind Me Later", modifier = Modifier.weight(1f))
Text(stringResource(R.string.nc_remind), modifier = Modifier.weight(1f))

val reminderState = chatViewModel.getReminderExistState
.asFlow()
Expand All @@ -269,6 +277,7 @@ class DateTimeCompose(val bundle: Bundle) {
else -> {}
}


if (timeState.value != LocalDateTime.ofEpochSecond(0, 0, ZoneOffset.MIN)) {
Text(timeState.value.format(DateTimeFormatter.ofPattern(PATTERN)))
}
Expand Down Expand Up @@ -307,9 +316,12 @@ class DateTimeCompose(val bundle: Bundle) {
val day = date.dayOfMonth
val hour = timePickerState.hour
val minute = timePickerState.minute
timeState.value = LocalDateTime.of(year, month, day, hour, minute)
val newTime = LocalDateTime.of(year, month, day, hour, minute)
setTime(newTime)

} else {
timeState.value = LocalDate.now().atTime(timePickerState.hour, timePickerState.minute)
val newTime = LocalDate.now().atTime(timePickerState.hour, timePickerState.minute)
setTime(newTime)
}
}
Submission(shouldDismiss)
Expand Down

0 comments on commit dcffa62

Please sign in to comment.