mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-10 04:50:41 +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 -> {
|
is PostModel -> {
|
||||||
RawContentDialog(
|
RawContentDialog(
|
||||||
title = content.title,
|
title = content.title,
|
||||||
date = content.publishDate,
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
url = content.url,
|
url = content.url,
|
||||||
text = content.text,
|
text = content.text,
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
@ -874,7 +875,8 @@ class CommunityDetailScreen(
|
|||||||
is CommentModel -> {
|
is CommentModel -> {
|
||||||
RawContentDialog(
|
RawContentDialog(
|
||||||
text = content.text,
|
text = content.text,
|
||||||
date = content.publishDate,
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
rawContent = null
|
rawContent = null
|
||||||
},
|
},
|
||||||
|
@ -374,7 +374,8 @@ class CreateCommentScreen(
|
|||||||
is PostModel -> {
|
is PostModel -> {
|
||||||
RawContentDialog(
|
RawContentDialog(
|
||||||
title = content.title,
|
title = content.title,
|
||||||
date = content.publishDate,
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
url = content.url,
|
url = content.url,
|
||||||
text = content.text,
|
text = content.text,
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
@ -386,7 +387,8 @@ class CreateCommentScreen(
|
|||||||
is CommentModel -> {
|
is CommentModel -> {
|
||||||
RawContentDialog(
|
RawContentDialog(
|
||||||
text = content.text,
|
text = content.text,
|
||||||
date = content.publishDate,
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
rawContent = null
|
rawContent = null
|
||||||
},
|
},
|
||||||
|
@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.size
|
|||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.text.selection.SelectionContainer
|
import androidx.compose.foundation.text.selection.SelectionContainer
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.Edit
|
||||||
import androidx.compose.material.icons.filled.Schedule
|
import androidx.compose.material.icons.filled.Schedule
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Button
|
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 com.github.diegoberaldin.raccoonforlemmy.resources.MR
|
||||||
import dev.icerock.moko.resources.compose.stringResource
|
import dev.icerock.moko.resources.compose.stringResource
|
||||||
|
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun RawContentDialog(
|
fun RawContentDialog(
|
||||||
date: String? = null,
|
publishDate: String? = null,
|
||||||
|
updateDate: String? = null,
|
||||||
title: String? = null,
|
title: String? = null,
|
||||||
url: String? = null,
|
url: String? = null,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
@ -169,7 +170,7 @@ fun RawContentDialog(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
date?.takeIf { it.trim().isNotEmpty() }?.also {
|
publishDate?.takeIf { it.trim().isNotEmpty() }?.also {
|
||||||
item {
|
item {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
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(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
|
@ -1156,7 +1156,8 @@ class PostDetailScreen(
|
|||||||
is PostModel -> {
|
is PostModel -> {
|
||||||
RawContentDialog(
|
RawContentDialog(
|
||||||
title = content.title,
|
title = content.title,
|
||||||
date = content.publishDate,
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
url = content.url,
|
url = content.url,
|
||||||
text = content.text,
|
text = content.text,
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
@ -1183,7 +1184,8 @@ class PostDetailScreen(
|
|||||||
is CommentModel -> {
|
is CommentModel -> {
|
||||||
RawContentDialog(
|
RawContentDialog(
|
||||||
text = content.text,
|
text = content.text,
|
||||||
date = content.publishDate,
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
rawContent = null
|
rawContent = null
|
||||||
},
|
},
|
||||||
|
@ -457,7 +457,8 @@ class ReportListScreen(
|
|||||||
is PostReportModel -> {
|
is PostReportModel -> {
|
||||||
RawContentDialog(
|
RawContentDialog(
|
||||||
title = content.originalTitle,
|
title = content.originalTitle,
|
||||||
date = content.publishDate,
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
url = content.originalUrl,
|
url = content.originalUrl,
|
||||||
text = content.originalText,
|
text = content.originalText,
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
@ -468,7 +469,8 @@ class ReportListScreen(
|
|||||||
|
|
||||||
is CommentReportModel -> {
|
is CommentReportModel -> {
|
||||||
RawContentDialog(
|
RawContentDialog(
|
||||||
date = content.publishDate,
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
text = content.originalText,
|
text = content.originalText,
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
rawContent = null
|
rawContent = null
|
||||||
|
@ -458,8 +458,10 @@ class SavedItemsScreen : Screen {
|
|||||||
if (rawContent != null) {
|
if (rawContent != null) {
|
||||||
when (val content = rawContent) {
|
when (val content = rawContent) {
|
||||||
is PostModel -> {
|
is PostModel -> {
|
||||||
RawContentDialog(title = content.title,
|
RawContentDialog(
|
||||||
date = content.publishDate,
|
title = content.title,
|
||||||
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
url = content.url,
|
url = content.url,
|
||||||
text = content.text,
|
text = content.text,
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
@ -468,7 +470,8 @@ class SavedItemsScreen : Screen {
|
|||||||
onQuote = { quotation ->
|
onQuote = { quotation ->
|
||||||
rawContent = null
|
rawContent = null
|
||||||
if (quotation != null) {
|
if (quotation != null) {
|
||||||
val screen = CreateCommentScreen(originalPost = content,
|
val screen = CreateCommentScreen(
|
||||||
|
originalPost = content,
|
||||||
initialText = buildString {
|
initialText = buildString {
|
||||||
append("> ")
|
append("> ")
|
||||||
append(quotation)
|
append(quotation)
|
||||||
@ -480,9 +483,14 @@ class SavedItemsScreen : Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
is CommentModel -> {
|
is CommentModel -> {
|
||||||
RawContentDialog(text = content.text, date = content.publishDate, onDismiss = {
|
RawContentDialog(
|
||||||
|
text = content.text,
|
||||||
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
|
onDismiss = {
|
||||||
rawContent = null
|
rawContent = null
|
||||||
}, onQuote = { quotation ->
|
},
|
||||||
|
onQuote = { quotation ->
|
||||||
rawContent = null
|
rawContent = null
|
||||||
if (quotation != null) {
|
if (quotation != null) {
|
||||||
val screen = CreateCommentScreen(originalComment = content,
|
val screen = CreateCommentScreen(originalComment = content,
|
||||||
@ -493,7 +501,8 @@ class SavedItemsScreen : Screen {
|
|||||||
})
|
})
|
||||||
navigationCoordinator.showBottomSheet(screen)
|
navigationCoordinator.showBottomSheet(screen)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -836,7 +836,8 @@ class UserDetailScreen(
|
|||||||
is PostModel -> {
|
is PostModel -> {
|
||||||
RawContentDialog(
|
RawContentDialog(
|
||||||
title = content.title,
|
title = content.title,
|
||||||
date = content.publishDate,
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
url = content.url,
|
url = content.url,
|
||||||
text = content.text,
|
text = content.text,
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
@ -863,7 +864,8 @@ class UserDetailScreen(
|
|||||||
is CommentModel -> {
|
is CommentModel -> {
|
||||||
RawContentDialog(
|
RawContentDialog(
|
||||||
text = content.text,
|
text = content.text,
|
||||||
date = content.publishDate,
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
rawContent = null
|
rawContent = null
|
||||||
},
|
},
|
||||||
|
@ -31,12 +31,12 @@ actual object DateTime {
|
|||||||
val delta = Period.between(date.toLocalDate(), now.toLocalDate())
|
val delta = Period.between(date.toLocalDate(), now.toLocalDate())
|
||||||
val years = delta.years
|
val years = delta.years
|
||||||
val months = delta.months
|
val months = delta.months
|
||||||
val days = delta.days
|
|
||||||
val nowSeconds = now.toEpochSecond()
|
val nowSeconds = now.toEpochSecond()
|
||||||
val dateSeconds = date.toEpochSecond()
|
val dateSeconds = date.toEpochSecond()
|
||||||
val diffSeconds = (nowSeconds - dateSeconds)
|
val diffSeconds = (nowSeconds - dateSeconds)
|
||||||
val hours = (diffSeconds % 86400) / 3600
|
val days = diffSeconds / 86400
|
||||||
val minutes = (diffSeconds % 3600) / 60
|
val hours = ((diffSeconds % 86400) / 3600) % 24
|
||||||
|
val minutes = ((diffSeconds % 3600) / 60) % 60
|
||||||
val seconds = diffSeconds % 60
|
val seconds = diffSeconds % 60
|
||||||
return when {
|
return when {
|
||||||
years >= 1 -> buildString {
|
years >= 1 -> buildString {
|
||||||
|
@ -564,7 +564,8 @@ class PostListScreen : Screen {
|
|||||||
is PostModel -> {
|
is PostModel -> {
|
||||||
RawContentDialog(
|
RawContentDialog(
|
||||||
title = content.title,
|
title = content.title,
|
||||||
date = content.publishDate,
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
url = content.url,
|
url = content.url,
|
||||||
text = content.text,
|
text = content.text,
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
|
@ -454,7 +454,8 @@ internal object ProfileLoggedScreen : Tab {
|
|||||||
is PostModel -> {
|
is PostModel -> {
|
||||||
RawContentDialog(
|
RawContentDialog(
|
||||||
title = content.title,
|
title = content.title,
|
||||||
date = content.publishDate,
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
url = content.url,
|
url = content.url,
|
||||||
text = content.text,
|
text = content.text,
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
@ -481,7 +482,8 @@ internal object ProfileLoggedScreen : Tab {
|
|||||||
is CommentModel -> {
|
is CommentModel -> {
|
||||||
RawContentDialog(
|
RawContentDialog(
|
||||||
text = content.text,
|
text = content.text,
|
||||||
date = content.publishDate,
|
publishDate = content.publishDate,
|
||||||
|
updateDate = content.updateDate,
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
rawContent = null
|
rawContent = null
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user