From d67059f63760536d121e6f8692c3ab475d127d1a Mon Sep 17 00:00:00 2001 From: akesi seli Date: Thu, 26 Dec 2024 12:10:54 +0100 Subject: [PATCH 1/6] update l10n --- composeApp/src/commonMain/composeResources/values/strings.xml | 1 + .../eattrash/raccoonforfriendica/resources/SharedStrings.kt | 3 +++ .../livefast/eattrash/raccoonforfriendica/core/l10n/Strings.kt | 1 + .../raccoonforfriendica/core/l10n/testutils/MockStrings.kt | 2 ++ 4 files changed, 7 insertions(+) diff --git a/composeApp/src/commonMain/composeResources/values/strings.xml b/composeApp/src/commonMain/composeResources/values/strings.xml index 489502d93..52a3d2595 100644 --- a/composeApp/src/commonMain/composeResources/values/strings.xml +++ b/composeApp/src/commonMain/composeResources/values/strings.xml @@ -381,6 +381,7 @@ in reply to re-shared by Local + Card Compact Distraction free Full diff --git a/composeApp/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/resources/SharedStrings.kt b/composeApp/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/resources/SharedStrings.kt index 0f708c510..5e95bdcf1 100644 --- a/composeApp/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/resources/SharedStrings.kt +++ b/composeApp/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/resources/SharedStrings.kt @@ -405,6 +405,7 @@ import raccoonforfriendica.composeapp.generated.resources.time_second_short import raccoonforfriendica.composeapp.generated.resources.timeline_all import raccoonforfriendica.composeapp.generated.resources.timeline_entry_in_reply_to import raccoonforfriendica.composeapp.generated.resources.timeline_entry_reblogged_by +import raccoonforfriendica.composeapp.generated.resources.timeline_layout_card import raccoonforfriendica.composeapp.generated.resources.timeline_layout_compact import raccoonforfriendica.composeapp.generated.resources.timeline_layout_distraction_free import raccoonforfriendica.composeapp.generated.resources.timeline_layout_full @@ -1212,6 +1213,8 @@ class SharedStrings : Strings { @Composable get() = stringResource(Res.string.timeline_entry_in_reply_to) override val timelineEntryRebloggedBy: String @Composable get() = stringResource(Res.string.timeline_entry_reblogged_by) + override val timelineLayoutCard: String + @Composable get() = stringResource(Res.string.timeline_layout_card) override val timelineLayoutCompact: String @Composable get() = stringResource(Res.string.timeline_layout_compact) override val timelineLayoutDistractionFree: String diff --git a/core/l10n/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/l10n/Strings.kt b/core/l10n/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/l10n/Strings.kt index af29e9f0b..85fbd9bab 100644 --- a/core/l10n/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/l10n/Strings.kt +++ b/core/l10n/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/l10n/Strings.kt @@ -392,6 +392,7 @@ interface Strings { val timelineAll: String @Composable get val timelineEntryInReplyTo: String @Composable get val timelineEntryRebloggedBy: String @Composable get + val timelineLayoutCard: String @Composable get val timelineLayoutCompact: String @Composable get val timelineLayoutDistractionFree: String @Composable get val timelineLayoutFull: String @Composable get diff --git a/core/l10n/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/l10n/testutils/MockStrings.kt b/core/l10n/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/l10n/testutils/MockStrings.kt index 813865f13..c6946f6bd 100644 --- a/core/l10n/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/l10n/testutils/MockStrings.kt +++ b/core/l10n/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/l10n/testutils/MockStrings.kt @@ -791,6 +791,8 @@ class MockStrings : Strings { @Composable get() = retrieve("timelineEntryInReplyTo") override val timelineEntryRebloggedBy: String @Composable get() = retrieve("timelineEntryRebloggedBy") + override val timelineLayoutCard: String + @Composable get() = retrieve("timelineLayoutCard") override val timelineLayoutCompact: String @Composable get() = retrieve("timelineLayoutCompact") override val timelineLayoutDistractionFree: String From 639546d38b1a3595111486c5fc97bf148cb7e4fc Mon Sep 17 00:00:00 2001 From: akesi seli Date: Thu, 26 Dec 2024 12:11:12 +0100 Subject: [PATCH 2/6] add enum value --- .../core/appearance/data/TimelineLayout.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/appearance/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/appearance/data/TimelineLayout.kt b/core/appearance/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/appearance/data/TimelineLayout.kt index 3da9210ad..cd6e4c92e 100644 --- a/core/appearance/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/appearance/data/TimelineLayout.kt +++ b/core/appearance/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/appearance/data/TimelineLayout.kt @@ -7,12 +7,14 @@ enum class TimelineLayout { Full, DistractionFree, Compact, + Card, } fun TimelineLayout.toInt(): Int = when (this) { TimelineLayout.DistractionFree -> 1 TimelineLayout.Compact -> 2 + TimelineLayout.Card -> 3 else -> 0 } @@ -20,6 +22,7 @@ fun Int.toTimelineLayout(): TimelineLayout = when (this) { 1 -> TimelineLayout.DistractionFree 2 -> TimelineLayout.Compact + 3 -> TimelineLayout.Card else -> TimelineLayout.Full } @@ -29,4 +32,5 @@ fun TimelineLayout.toReadableName(): String = TimelineLayout.Full -> LocalStrings.current.timelineLayoutFull TimelineLayout.DistractionFree -> LocalStrings.current.timelineLayoutDistractionFree TimelineLayout.Compact -> LocalStrings.current.timelineLayoutCompact + TimelineLayout.Card -> LocalStrings.current.timelineLayoutCard } From e59e5cbd04c9d388b81fc895668a742524720f94 Mon Sep 17 00:00:00 2001 From: akesi seli Date: Thu, 26 Dec 2024 12:11:27 +0100 Subject: [PATCH 3/6] implement new layout and divider --- .../core/commonui/content/CardTimelineItem.kt | 351 ++++++++++++++++++ .../core/commonui/content/TimelineDivider.kt | 28 ++ .../core/commonui/content/TimelineItem.kt | 33 ++ .../commonui/content/TimelineReplyItem.kt | 2 +- 4 files changed, 413 insertions(+), 1 deletion(-) create mode 100644 core/commonui/content/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/commonui/content/CardTimelineItem.kt create mode 100644 core/commonui/content/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/commonui/content/TimelineDivider.kt diff --git a/core/commonui/content/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/commonui/content/CardTimelineItem.kt b/core/commonui/content/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/commonui/content/CardTimelineItem.kt new file mode 100644 index 000000000..d40994279 --- /dev/null +++ b/core/commonui/content/src/commonMain/kotlin/com/livefast/eattrash/raccoonforfriendica/core/commonui/content/CardTimelineItem.kt @@ -0,0 +1,351 @@ +package com.livefast.eattrash.raccoonforfriendica.core.commonui.content + +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.MoreVert +import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.material3.surfaceColorAtElevation +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.shadow +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.layout.onGloballyPositioned +import androidx.compose.ui.layout.positionInParent +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.semantics.clearAndSetSemantics +import androidx.compose.ui.semantics.heading +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.unit.DpOffset +import androidx.compose.ui.unit.dp +import com.livefast.eattrash.raccoonforfriendica.core.appearance.theme.CornerSize +import com.livefast.eattrash.raccoonforfriendica.core.appearance.theme.IconSize +import com.livefast.eattrash.raccoonforfriendica.core.appearance.theme.Spacing +import com.livefast.eattrash.raccoonforfriendica.core.commonui.components.CustomDropDown +import com.livefast.eattrash.raccoonforfriendica.domain.content.data.TimelineEntryModel +import com.livefast.eattrash.raccoonforfriendica.domain.content.data.UserModel +import com.livefast.eattrash.raccoonforfriendica.domain.content.data.embeddedImageUrls + +@Composable +internal fun CardTimelineItem( + entryToDisplay: TimelineEntryModel, + modifier: Modifier = Modifier, + actionsEnabled: Boolean = true, + autoloadImages: Boolean = true, + blurNsfw: Boolean = true, + extendedSocialInfoEnabled: Boolean = false, + maxBodyLines: Int = Int.MAX_VALUE, + maxTitleLines: Int = Int.MAX_VALUE, + options: List