mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-03 07:57:39 +01:00
* fix: date prettify; closes #238 * feat: show update date in raw content
This commit is contained in:
parent
3bfb1b7fdf
commit
6cd475256e
@ -847,7 +847,8 @@ class CommunityDetailScreen(
|
||||
is PostModel -> {
|
||||
RawContentDialog(
|
||||
title = content.title,
|
||||
date = content.publishDate,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
url = content.url,
|
||||
text = content.text,
|
||||
onDismiss = {
|
||||
@ -874,7 +875,8 @@ class CommunityDetailScreen(
|
||||
is CommentModel -> {
|
||||
RawContentDialog(
|
||||
text = content.text,
|
||||
date = content.publishDate,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
onDismiss = {
|
||||
rawContent = null
|
||||
},
|
||||
|
@ -374,7 +374,8 @@ class CreateCommentScreen(
|
||||
is PostModel -> {
|
||||
RawContentDialog(
|
||||
title = content.title,
|
||||
date = content.publishDate,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
url = content.url,
|
||||
text = content.text,
|
||||
onDismiss = {
|
||||
@ -386,7 +387,8 @@ class CreateCommentScreen(
|
||||
is CommentModel -> {
|
||||
RawContentDialog(
|
||||
text = content.text,
|
||||
date = content.publishDate,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
onDismiss = {
|
||||
rawContent = null
|
||||
},
|
||||
|
@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.text.selection.SelectionContainer
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Edit
|
||||
import androidx.compose.material.icons.filled.Schedule
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
@ -37,11 +38,11 @@ import com.github.diegoberaldin.raccoonforlemmy.core.utils.share.getShareHelper
|
||||
import com.github.diegoberaldin.raccoonforlemmy.resources.MR
|
||||
import dev.icerock.moko.resources.compose.stringResource
|
||||
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun RawContentDialog(
|
||||
date: String? = null,
|
||||
publishDate: String? = null,
|
||||
updateDate: String? = null,
|
||||
title: String? = null,
|
||||
url: String? = null,
|
||||
text: String? = null,
|
||||
@ -169,7 +170,7 @@ fun RawContentDialog(
|
||||
}
|
||||
}
|
||||
|
||||
date?.takeIf { it.trim().isNotEmpty() }?.also {
|
||||
publishDate?.takeIf { it.trim().isNotEmpty() }?.also {
|
||||
item {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
@ -192,6 +193,29 @@ fun RawContentDialog(
|
||||
}
|
||||
}
|
||||
}
|
||||
updateDate?.takeIf { it.trim().isNotEmpty() }?.also {
|
||||
item {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(Spacing.xxs),
|
||||
) {
|
||||
Icon(
|
||||
modifier = Modifier.size(IconSize.m).padding(4.5.dp),
|
||||
imageVector = Icons.Default.Edit,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onBackground,
|
||||
)
|
||||
Text(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = it,
|
||||
style = MaterialTheme.typography.bodyMedium.copy(
|
||||
fontFamily = FontFamily.Monospace,
|
||||
),
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Button(
|
||||
onClick = {
|
||||
|
@ -1156,7 +1156,8 @@ class PostDetailScreen(
|
||||
is PostModel -> {
|
||||
RawContentDialog(
|
||||
title = content.title,
|
||||
date = content.publishDate,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
url = content.url,
|
||||
text = content.text,
|
||||
onDismiss = {
|
||||
@ -1183,7 +1184,8 @@ class PostDetailScreen(
|
||||
is CommentModel -> {
|
||||
RawContentDialog(
|
||||
text = content.text,
|
||||
date = content.publishDate,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
onDismiss = {
|
||||
rawContent = null
|
||||
},
|
||||
|
@ -457,7 +457,8 @@ class ReportListScreen(
|
||||
is PostReportModel -> {
|
||||
RawContentDialog(
|
||||
title = content.originalTitle,
|
||||
date = content.publishDate,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
url = content.originalUrl,
|
||||
text = content.originalText,
|
||||
onDismiss = {
|
||||
@ -468,7 +469,8 @@ class ReportListScreen(
|
||||
|
||||
is CommentReportModel -> {
|
||||
RawContentDialog(
|
||||
date = content.publishDate,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
text = content.originalText,
|
||||
onDismiss = {
|
||||
rawContent = null
|
||||
|
@ -458,8 +458,10 @@ class SavedItemsScreen : Screen {
|
||||
if (rawContent != null) {
|
||||
when (val content = rawContent) {
|
||||
is PostModel -> {
|
||||
RawContentDialog(title = content.title,
|
||||
date = content.publishDate,
|
||||
RawContentDialog(
|
||||
title = content.title,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
url = content.url,
|
||||
text = content.text,
|
||||
onDismiss = {
|
||||
@ -468,7 +470,8 @@ class SavedItemsScreen : Screen {
|
||||
onQuote = { quotation ->
|
||||
rawContent = null
|
||||
if (quotation != null) {
|
||||
val screen = CreateCommentScreen(originalPost = content,
|
||||
val screen = CreateCommentScreen(
|
||||
originalPost = content,
|
||||
initialText = buildString {
|
||||
append("> ")
|
||||
append(quotation)
|
||||
@ -480,20 +483,26 @@ class SavedItemsScreen : Screen {
|
||||
}
|
||||
|
||||
is CommentModel -> {
|
||||
RawContentDialog(text = content.text, date = content.publishDate, onDismiss = {
|
||||
rawContent = null
|
||||
}, onQuote = { quotation ->
|
||||
rawContent = null
|
||||
if (quotation != null) {
|
||||
val screen = CreateCommentScreen(originalComment = content,
|
||||
initialText = buildString {
|
||||
append("> ")
|
||||
append(quotation)
|
||||
append("\n\n")
|
||||
})
|
||||
navigationCoordinator.showBottomSheet(screen)
|
||||
RawContentDialog(
|
||||
text = content.text,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
onDismiss = {
|
||||
rawContent = null
|
||||
},
|
||||
onQuote = { quotation ->
|
||||
rawContent = null
|
||||
if (quotation != null) {
|
||||
val screen = CreateCommentScreen(originalComment = content,
|
||||
initialText = buildString {
|
||||
append("> ")
|
||||
append(quotation)
|
||||
append("\n\n")
|
||||
})
|
||||
navigationCoordinator.showBottomSheet(screen)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -836,7 +836,8 @@ class UserDetailScreen(
|
||||
is PostModel -> {
|
||||
RawContentDialog(
|
||||
title = content.title,
|
||||
date = content.publishDate,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
url = content.url,
|
||||
text = content.text,
|
||||
onDismiss = {
|
||||
@ -863,7 +864,8 @@ class UserDetailScreen(
|
||||
is CommentModel -> {
|
||||
RawContentDialog(
|
||||
text = content.text,
|
||||
date = content.publishDate,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
onDismiss = {
|
||||
rawContent = null
|
||||
},
|
||||
|
@ -31,12 +31,12 @@ actual object DateTime {
|
||||
val delta = Period.between(date.toLocalDate(), now.toLocalDate())
|
||||
val years = delta.years
|
||||
val months = delta.months
|
||||
val days = delta.days
|
||||
val nowSeconds = now.toEpochSecond()
|
||||
val dateSeconds = date.toEpochSecond()
|
||||
val diffSeconds = (nowSeconds - dateSeconds)
|
||||
val hours = (diffSeconds % 86400) / 3600
|
||||
val minutes = (diffSeconds % 3600) / 60
|
||||
val days = diffSeconds / 86400
|
||||
val hours = ((diffSeconds % 86400) / 3600) % 24
|
||||
val minutes = ((diffSeconds % 3600) / 60) % 60
|
||||
val seconds = diffSeconds % 60
|
||||
return when {
|
||||
years >= 1 -> buildString {
|
||||
|
@ -564,7 +564,8 @@ class PostListScreen : Screen {
|
||||
is PostModel -> {
|
||||
RawContentDialog(
|
||||
title = content.title,
|
||||
date = content.publishDate,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
url = content.url,
|
||||
text = content.text,
|
||||
onDismiss = {
|
||||
|
@ -454,7 +454,8 @@ internal object ProfileLoggedScreen : Tab {
|
||||
is PostModel -> {
|
||||
RawContentDialog(
|
||||
title = content.title,
|
||||
date = content.publishDate,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
url = content.url,
|
||||
text = content.text,
|
||||
onDismiss = {
|
||||
@ -481,7 +482,8 @@ internal object ProfileLoggedScreen : Tab {
|
||||
is CommentModel -> {
|
||||
RawContentDialog(
|
||||
text = content.text,
|
||||
date = content.publishDate,
|
||||
publishDate = content.publishDate,
|
||||
updateDate = content.updateDate,
|
||||
onDismiss = {
|
||||
rawContent = null
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user