mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
linter
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
parent
63cb98ece7
commit
73ed4cbf8f
@ -68,7 +68,7 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
@AutoInjector(NextcloudTalkApplication::class)
|
@AutoInjector(NextcloudTalkApplication::class)
|
||||||
class DateTimeCompose(val bundle: Bundle) {
|
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 {
|
init {
|
||||||
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
||||||
@ -108,20 +108,20 @@ class DateTimeCompose(val bundle: Bundle) {
|
|||||||
usePlatformDefaultWidth = isCollapsed.value
|
usePlatformDefaultWidth = isCollapsed.value
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
Surface(
|
Surface(
|
||||||
shape = RoundedCornerShape(8.dp),
|
shape = RoundedCornerShape(INT_8.dp),
|
||||||
modifier = Modifier.animateContentSize()
|
modifier = Modifier.animateContentSize()
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(16.dp)
|
.padding(INT_16.dp)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
) {
|
) {
|
||||||
Header()
|
Header()
|
||||||
Body()
|
Body()
|
||||||
CollapsableDateTime(shouldDismiss, isCollapsed)
|
CollapsableDateTime(shouldDismiss, isCollapsed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,44 +131,47 @@ class DateTimeCompose(val bundle: Bundle) {
|
|||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
) {
|
) {
|
||||||
TextButton(onClick = {
|
TextButton(
|
||||||
val user = userManager.currentUser.blockingGet()
|
onClick = {
|
||||||
val roomToken = bundle.getString(BundleKeys.KEY_ROOM_TOKEN)!!
|
val user = userManager.currentUser.blockingGet()
|
||||||
val messageId = bundle.getString(BundleKeys.KEY_MESSAGE_ID)!!
|
val roomToken = bundle.getString(BundleKeys.KEY_ROOM_TOKEN)!!
|
||||||
val apiVersion = bundle.getInt(BundleKeys.KEY_CHAT_API_VERSION)
|
val messageId = bundle.getString(BundleKeys.KEY_MESSAGE_ID)!!
|
||||||
chatViewModel.deleteReminder(user, roomToken, messageId, apiVersion)
|
val apiVersion = bundle.getInt(BundleKeys.KEY_CHAT_API_VERSION)
|
||||||
shouldDismiss.value = true
|
chatViewModel.deleteReminder(user, roomToken, messageId, apiVersion)
|
||||||
},
|
shouldDismiss.value = true
|
||||||
modifier = Modifier
|
},
|
||||||
.weight(.33f)
|
modifier = Modifier
|
||||||
|
.weight(CUBED_PADDING)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
"Delete",
|
"Delete",
|
||||||
color = Color.Red,
|
color = Color.Red
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
TextButton(onClick = {
|
TextButton(
|
||||||
val user = userManager.currentUser.blockingGet()
|
onClick = {
|
||||||
val roomToken = bundle.getString(BundleKeys.KEY_ROOM_TOKEN)!!
|
val user = userManager.currentUser.blockingGet()
|
||||||
val messageId = bundle.getString(BundleKeys.KEY_MESSAGE_ID)!!
|
val roomToken = bundle.getString(BundleKeys.KEY_ROOM_TOKEN)!!
|
||||||
val apiVersion = bundle.getInt(BundleKeys.KEY_CHAT_API_VERSION)
|
val messageId = bundle.getString(BundleKeys.KEY_MESSAGE_ID)!!
|
||||||
val offset = timeState.value.atZone(ZoneOffset.systemDefault()).offset
|
val apiVersion = bundle.getInt(BundleKeys.KEY_CHAT_API_VERSION)
|
||||||
val timeVal = timeState.value.toEpochSecond(offset)
|
val offset = timeState.value.atZone(ZoneOffset.systemDefault()).offset
|
||||||
chatViewModel.setReminder(user, roomToken, messageId, timeVal.toInt(), apiVersion)
|
val timeVal = timeState.value.toEpochSecond(offset)
|
||||||
shouldDismiss.value = true
|
chatViewModel.setReminder(user, roomToken, messageId, timeVal.toInt(), apiVersion)
|
||||||
},
|
shouldDismiss.value = true
|
||||||
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.weight(.33f)
|
.weight(CUBED_PADDING)
|
||||||
) {
|
) {
|
||||||
Text("Set")
|
Text("Set")
|
||||||
}
|
}
|
||||||
|
|
||||||
TextButton(onClick = {
|
TextButton(
|
||||||
shouldDismiss.value = true
|
onClick = {
|
||||||
},
|
shouldDismiss.value = true
|
||||||
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.weight(.33f)
|
.weight(CUBED_PADDING)
|
||||||
) {
|
) {
|
||||||
Text("Close")
|
Text("Close")
|
||||||
}
|
}
|
||||||
@ -180,32 +183,32 @@ class DateTimeCompose(val bundle: Bundle) {
|
|||||||
val currTime = LocalDateTime.now()
|
val currTime = LocalDateTime.now()
|
||||||
|
|
||||||
val laterToday = LocalDateTime.now()
|
val laterToday = LocalDateTime.now()
|
||||||
.withHour(18)
|
.withHour(INT_18)
|
||||||
.withMinute(0)
|
.withMinute(0)
|
||||||
.withSecond(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()
|
val tomorrow = LocalDateTime.now()
|
||||||
.plusDays(1)
|
.plusDays(1)
|
||||||
.withHour(8)
|
.withHour(INT_8)
|
||||||
.withMinute(0)
|
.withMinute(0)
|
||||||
.withSecond(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()
|
val thisWeekend = LocalDateTime.now()
|
||||||
.with(nextOrSame(DayOfWeek.SATURDAY))
|
.with(nextOrSame(DayOfWeek.SATURDAY))
|
||||||
.withHour(8)
|
.withHour(INT_8)
|
||||||
.withMinute(0)
|
.withMinute(0)
|
||||||
.withSecond(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()
|
val nextWeek = LocalDateTime.now()
|
||||||
.plusWeeks(1)
|
.plusWeeks(1)
|
||||||
.with(nextOrSame(DayOfWeek.MONDAY))
|
.with(nextOrSame(DayOfWeek.MONDAY))
|
||||||
.withHour(8)
|
.withHour(INT_8)
|
||||||
.withMinute(0)
|
.withMinute(0)
|
||||||
.withSecond(0)
|
.withSecond(0)
|
||||||
val nextWeekStr = nextWeek.format(DateTimeFormatter.ofPattern("dd MMM, HH:mm a"))
|
val nextWeekStr = nextWeek.format(DateTimeFormatter.ofPattern(PATTERN))
|
||||||
|
|
||||||
if (currTime < laterToday) {
|
if (currTime < laterToday) {
|
||||||
TimeOption(
|
TimeOption(
|
||||||
@ -248,10 +251,9 @@ class DateTimeCompose(val bundle: Bundle) {
|
|||||||
private fun Header() {
|
private fun Header() {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(8.dp)
|
.padding(INT_8.dp)
|
||||||
) {
|
) {
|
||||||
Text("Remind Me Later", modifier = Modifier.weight(1f))
|
Text("Remind Me Later", modifier = Modifier.weight(1f))
|
||||||
// Spacer(modifier = Modifier.width(32.dp))
|
|
||||||
|
|
||||||
val reminderState = chatViewModel.getReminderExistState
|
val reminderState = chatViewModel.getReminderExistState
|
||||||
.asFlow()
|
.asFlow()
|
||||||
@ -259,14 +261,16 @@ class DateTimeCompose(val bundle: Bundle) {
|
|||||||
|
|
||||||
when (reminderState.value) {
|
when (reminderState.value) {
|
||||||
is ChatViewModel.GetReminderExistState -> {
|
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())
|
timeState.value = LocalDateTime.ofInstant(Instant.ofEpochSecond(timeL), ZoneId.systemDefault())
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeState.value != LocalDateTime.ofEpochSecond(0,0, ZoneOffset.MIN)) {
|
if (timeState.value != LocalDateTime.ofEpochSecond(0, 0, ZoneOffset.MIN)) {
|
||||||
Text(timeState.value.format(DateTimeFormatter.ofPattern("dd MMM, HH:mm a")))
|
Text(timeState.value.format(DateTimeFormatter.ofPattern(PATTERN)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HorizontalDivider()
|
HorizontalDivider()
|
||||||
@ -286,11 +290,11 @@ class DateTimeCompose(val bundle: Bundle) {
|
|||||||
val timePickerState = rememberTimePickerState()
|
val timePickerState = rememberTimePickerState()
|
||||||
|
|
||||||
DatePicker(
|
DatePicker(
|
||||||
state = datePickerState,
|
state = datePickerState
|
||||||
)
|
)
|
||||||
|
|
||||||
TimePicker(
|
TimePicker(
|
||||||
state = timePickerState,
|
state = timePickerState
|
||||||
)
|
)
|
||||||
|
|
||||||
val date = datePickerState.selectedDateMillis?.let {
|
val date = datePickerState.selectedDateMillis?.let {
|
||||||
@ -307,20 +311,16 @@ class DateTimeCompose(val bundle: Bundle) {
|
|||||||
} else {
|
} else {
|
||||||
timeState.value = LocalDate.now().atTime(timePickerState.hour, timePickerState.minute)
|
timeState.value = LocalDate.now().atTime(timePickerState.hour, timePickerState.minute)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Submission(shouldDismiss)
|
Submission(shouldDismiss)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun GeneralIconButton(
|
fun GeneralIconButton(icon: ImageVector, label: String, onClick: () -> Unit) {
|
||||||
icon: ImageVector,
|
|
||||||
label: String,
|
|
||||||
onClick: () -> Unit
|
|
||||||
) {
|
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = onClick) {
|
onClick = onClick
|
||||||
|
) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.Start
|
horizontalArrangement = Arrangement.Start
|
||||||
@ -328,31 +328,37 @@ class DateTimeCompose(val bundle: Bundle) {
|
|||||||
Icon(
|
Icon(
|
||||||
imageVector = icon,
|
imageVector = icon,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
modifier = Modifier.size(24.dp)
|
modifier = Modifier.size(INT_24.dp)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
Spacer(modifier = Modifier.width(INT_8.dp))
|
||||||
Text(text = label)
|
Text(text = label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun TimeOption(
|
private fun TimeOption(label: String, timeString: String, onClick: () -> Unit) {
|
||||||
label: String,
|
|
||||||
timeString: String,
|
|
||||||
onClick: () -> Unit
|
|
||||||
) {
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(8.dp)
|
.padding(INT_8.dp)
|
||||||
.clickable { onClick() }
|
.clickable { onClick() }
|
||||||
) {
|
) {
|
||||||
Text(label, modifier = Modifier.weight(0.5f))
|
Text(label, modifier = Modifier.weight(HALF_WEIGHT))
|
||||||
Text(timeString, modifier = Modifier.weight(0.5f))
|
Text(timeString, modifier = Modifier.weight(HALF_WEIGHT))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val PATTERN = "dd MMM, HH:mm a"
|
||||||
|
private const val HALF_WEIGHT = 0.5f
|
||||||
|
private const val INT_8 = 8
|
||||||
|
private const val INT_16 = 16
|
||||||
|
private const val INT_18 = 18
|
||||||
|
private const val INT_24 = 24
|
||||||
|
private const val CUBED_PADDING = 0.33f
|
||||||
|
}
|
||||||
|
|
||||||
// Preview Logic
|
// Preview Logic
|
||||||
// class DummyProvider : PreviewParameterProvider<String> {
|
// class DummyProvider : PreviewParameterProvider<String> {
|
||||||
// override val values: Sequence<String> = sequenceOf()
|
// override val values: Sequence<String> = sequenceOf()
|
||||||
|
Loading…
Reference in New Issue
Block a user