mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-09 03:58:44 +01:00
* fix: bottom sheet title position * feat: new bottom sheet * feat: use bottom sheet to share * chore: update viewmodels * fix: avoid sharing multiple times same URL
This commit is contained in:
parent
fd80fd20ae
commit
8d4decf608
@ -52,11 +52,15 @@ class BlockBottomSheet(
|
||||
verticalArrangement = Arrangement.spacedBy(Spacing.s),
|
||||
) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.community_detail_block),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -62,7 +62,11 @@ class ColorBottomSheet : Screen {
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.settings_custom_seed_color),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -53,7 +53,11 @@ class CommentBarThemeBottomSheet : Screen {
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.settings_comment_bar_theme),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -56,7 +56,11 @@ class DurationBottomSheet(
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.settings_zombie_mode_interval),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -59,7 +59,11 @@ class FontFamilyBottomSheet(
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.settings_ui_font_family),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -59,7 +59,11 @@ class FontScaleBottomSheet(
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.settings_content_font_scale),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -45,7 +45,11 @@ class InboxTypeSheet : Screen {
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.inbox_listing_type_title),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -48,7 +48,11 @@ class LanguageBottomSheet : Screen {
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.settings_language),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -54,7 +54,11 @@ class ListingTypeBottomSheet(
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.home_listing_title),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -47,7 +47,11 @@ class PostLayoutBottomSheet : Screen {
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.settings_post_layout),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -53,7 +53,7 @@ fun RawContentDialog(
|
||||
val shareHelper = remember { getShareHelper() }
|
||||
val onShareLambda = rememberCallback {
|
||||
val query = clipboardManager.getText()?.text.orEmpty()
|
||||
shareHelper.share(query, "text/plain")
|
||||
shareHelper.share(query)
|
||||
}
|
||||
val onQuoteLambda = rememberCallback {
|
||||
val query = clipboardManager.getText()?.text.orEmpty()
|
||||
|
@ -45,7 +45,11 @@ class ReportListTypeSheet : Screen {
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.report_list_type_title),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -0,0 +1,87 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
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.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import cafe.adriel.voyager.core.screen.Screen
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.BottomSheetHandle
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.navigation.di.getNavigationCoordinator
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.NotificationCenterEvent
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.di.getNotificationCenter
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.onClick
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.rememberCallback
|
||||
import com.github.diegoberaldin.raccoonforlemmy.resources.MR
|
||||
import dev.icerock.moko.resources.compose.stringResource
|
||||
|
||||
class ShareBottomSheet(
|
||||
private val urls: List<String>,
|
||||
) : Screen {
|
||||
|
||||
@Composable
|
||||
override fun Content() {
|
||||
val navigationCoordinator = remember { getNavigationCoordinator() }
|
||||
val notificationCenter = remember { getNotificationCenter() }
|
||||
|
||||
Column(
|
||||
modifier = Modifier.padding(
|
||||
top = Spacing.s,
|
||||
start = Spacing.s,
|
||||
end = Spacing.s,
|
||||
bottom = Spacing.m,
|
||||
),
|
||||
verticalArrangement = Arrangement.spacedBy(Spacing.s),
|
||||
) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.post_action_share),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth().verticalScroll(rememberScrollState()),
|
||||
verticalArrangement = Arrangement.spacedBy(Spacing.xxxs),
|
||||
) {
|
||||
for (value in urls) {
|
||||
Row(
|
||||
modifier = Modifier.padding(
|
||||
horizontal = Spacing.s,
|
||||
vertical = Spacing.m,
|
||||
).fillMaxWidth().onClick(
|
||||
onClick = rememberCallback {
|
||||
val event = NotificationCenterEvent.Share(value)
|
||||
notificationCenter.send(event)
|
||||
navigationCoordinator.hideBottomSheet()
|
||||
},
|
||||
),
|
||||
) {
|
||||
Text(
|
||||
text = value,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -51,7 +51,11 @@ class SliderBottomSheet(
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.settings_zombie_mode_scroll_amount),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -85,7 +85,11 @@ internal class SortBottomSheetMain(
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.home_sort_title),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
@ -189,7 +193,11 @@ internal class SortBottomSheetTop(
|
||||
contentDescription = null,
|
||||
)
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = SortType.Top.Generic.toReadableName() + "…",
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -52,7 +52,11 @@ class ThemeBottomSheet : Screen {
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.settings_ui_theme),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -47,7 +47,11 @@ class VoteFormatBottomSheet : Screen {
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = stringResource(MR.strings.settings_vote_format),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
|
@ -71,7 +71,11 @@ class VoteThemeBottomSheet(
|
||||
) {
|
||||
BottomSheetHandle()
|
||||
Text(
|
||||
modifier = Modifier.padding(start = Spacing.s, top = Spacing.s),
|
||||
modifier = Modifier.padding(
|
||||
start = Spacing.s,
|
||||
top = Spacing.s,
|
||||
end = Spacing.s,
|
||||
),
|
||||
text = if (downvote) {
|
||||
stringResource(MR.strings.settings_downvote_color)
|
||||
} else {
|
||||
|
@ -58,4 +58,6 @@ sealed interface NotificationCenterEvent {
|
||||
val communityId: Int? = null,
|
||||
val instanceId: Int? = null,
|
||||
) : NotificationCenterEvent
|
||||
|
||||
data class Share(val url: String) : NotificationCenterEvent
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import org.koin.core.module.Module
|
||||
|
||||
@Stable
|
||||
interface ShareHelper {
|
||||
fun share(url: String, mimeType: String)
|
||||
fun share(url: String, mimeType: String = "text/plain")
|
||||
}
|
||||
|
||||
expect val shareHelperModule: Module
|
||||
|
@ -49,7 +49,6 @@ interface SettingsMviModel :
|
||||
data class ChangeZombieModeScrollAmount(val value: Float) : Intent
|
||||
data class ChangeMarkAsReadWhileScrolling(val value: Boolean) : Intent
|
||||
data class ChangeDefaultInboxUnreadOnly(val value: Boolean) : Intent
|
||||
data class ChangeSharePostOriginal(val value: Boolean) : Intent
|
||||
data class ChangeSearchPostTitleOnly(val value: Boolean) : Intent
|
||||
}
|
||||
|
||||
@ -89,7 +88,6 @@ interface SettingsMviModel :
|
||||
val availableSortTypesForPosts: List<SortType> = emptyList(),
|
||||
val availableSortTypesForComments: List<SortType> = emptyList(),
|
||||
val commentBarTheme: CommentBarTheme = CommentBarTheme.Blue,
|
||||
val sharePostOriginal: Boolean = true,
|
||||
val searchPostTitleOnly: Boolean = false,
|
||||
)
|
||||
|
||||
|
@ -539,17 +539,6 @@ class SettingsScreen : Screen {
|
||||
},
|
||||
)
|
||||
|
||||
// share posts from original instance
|
||||
SettingsSwitchRow(
|
||||
title = stringResource(MR.strings.settings_share_post_original),
|
||||
value = uiState.sharePostOriginal,
|
||||
onValueChanged = rememberCallbackArgs(model) { value ->
|
||||
model.reduce(
|
||||
SettingsMviModel.Intent.ChangeSharePostOriginal(value)
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
// search posts only in title
|
||||
SettingsSwitchRow(
|
||||
title = stringResource(MR.strings.settings_search_posts_title_only),
|
||||
|
@ -334,10 +334,6 @@ class SettingsViewModel(
|
||||
changeDefaultInboxUnreadOnly(intent.value)
|
||||
}
|
||||
|
||||
is SettingsMviModel.Intent.ChangeSharePostOriginal -> {
|
||||
changeSharePostOriginal(intent.value)
|
||||
}
|
||||
|
||||
is SettingsMviModel.Intent.ChangeSearchPostTitleOnly -> {
|
||||
changeSearchPostTitleOnly(intent.value)
|
||||
}
|
||||
@ -654,16 +650,6 @@ class SettingsViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
private fun changeSharePostOriginal(value: Boolean) {
|
||||
mvi.updateState { it.copy(sharePostOriginal = value) }
|
||||
mvi.scope?.launch {
|
||||
val settings = settingsRepository.currentSettings.value.copy(
|
||||
sharePostOriginal = value
|
||||
)
|
||||
saveSettings(settings)
|
||||
}
|
||||
}
|
||||
|
||||
private fun changeSearchPostTitleOnly(value: Boolean) {
|
||||
mvi.updateState { it.copy(searchPostTitleOnly = value) }
|
||||
mvi.scope?.launch {
|
||||
|
@ -256,7 +256,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 الفراولة</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 قوس المطر</string>
|
||||
<string name="message_confirm_exit">ضغط على 🔙 مرة أخرى للخروج</string>
|
||||
<string name="settings_share_post_original">مشاركة المشاركات من المثيل الأصلي</string>
|
||||
<string name="community_action_unsubscribe">إلغاء الاشتراك</string>
|
||||
<string name="settings_search_posts_title_only">البحث عن المشاركات فقط في العنوان</string>
|
||||
<string name="settings_content_font_family">عائلة خطوط المحتوى</string>
|
||||
|
@ -287,7 +287,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Strawberry</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Rainbow</string>
|
||||
<string name="message_confirm_exit">Tap 🔙 again to exit</string>
|
||||
<string name="settings_share_post_original">Share posts from original instance</string>
|
||||
<string name="community_action_unsubscribe">Unsubscribe</string>
|
||||
<string name="settings_search_posts_title_only">Search posts only in title</string>
|
||||
<string name="settings_content_font_family">Content font family</string>
|
||||
|
@ -266,8 +266,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Ягода</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 дъга</string>
|
||||
<string name="message_confirm_exit">Докоснете 🔙 отново, за да излезете</string>
|
||||
<string name="settings_share_post_original">Споделяйте публикации от оригиналния екземпляр
|
||||
</string>
|
||||
<string name="community_action_unsubscribe">Отписване</string>
|
||||
<string name="settings_search_posts_title_only">Търсете публикации само в заглавието</string>
|
||||
<string name="settings_content_font_family">Семейство шрифтове за съдържание</string>
|
||||
|
@ -258,7 +258,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Jahoda</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Duha</string>
|
||||
<string name="message_confirm_exit">Pro ukončení klepněte znovu na 🔙</string>
|
||||
<string name="settings_share_post_original">Sdílejte příspěvky z původní instance</string>
|
||||
<string name="community_action_unsubscribe">Odhlásit odběr</string>
|
||||
<string name="settings_search_posts_title_only">Hledejte příspěvky pouze v názvu</string>
|
||||
<string name="settings_content_font_family">Rodina písem obsahu</string>
|
||||
|
@ -258,7 +258,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Jordbær</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Regnbue</string>
|
||||
<string name="message_confirm_exit">Tryk på 🔙 igen for at afslutte</string>
|
||||
<string name="settings_share_post_original">Del indlæg fra den oprindelige instans</string>
|
||||
<string name="community_action_unsubscribe">Opsige abonnement</string>
|
||||
<string name="settings_search_posts_title_only">Søg kun efter indlæg i titlen</string>
|
||||
<string name="settings_content_font_family">Indhold skrifttypefamilie</string>
|
||||
|
@ -264,7 +264,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Erdbeere</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Regenbogen</string>
|
||||
<string name="message_confirm_exit">Tippen Sie erneut auf 🔙, um den Vorgang zu beenden</string>
|
||||
<string name="settings_share_post_original">Teilen Sie Beiträge von der Originalinstanz</string>
|
||||
<string name="community_action_unsubscribe">Abbestellen</string>
|
||||
<string name="settings_search_posts_title_only">Durchsuchen Sie Beiträge nur nach Titel</string>
|
||||
<string name="settings_content_font_family">Content-Schriftfamilie</string>
|
||||
|
@ -267,8 +267,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Φράουλα</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Ουράνιο τόξο</string>
|
||||
<string name="message_confirm_exit">Πατήστε ξανά 🔙 για έξοδο</string>
|
||||
<string name="settings_share_post_original">Μοιραστείτε αναρτήσεις από το αρχικό παράδειγμα
|
||||
</string>
|
||||
<string name="community_action_unsubscribe">Απεγγραφή</string>
|
||||
<string name="settings_search_posts_title_only">Αναζήτηση αναρτήσεων μόνο στον τίτλο</string>
|
||||
<string name="settings_content_font_family">Γραμματοσειρά περιεχομένων</string>
|
||||
|
@ -257,7 +257,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Frago</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Ĉielarko</string>
|
||||
<string name="message_confirm_exit">Frapu 🔙 denove por eliri</string>
|
||||
<string name="settings_share_post_original">Kunhavigi afiŝojn de origina nodo</string>
|
||||
<string name="community_action_unsubscribe">Malaboni</string>
|
||||
<string name="settings_search_posts_title_only">Serĉi afiŝojn nur en titolo</string>
|
||||
<string name="settings_content_font_family">Enhavo tiparo</string>
|
||||
|
@ -262,9 +262,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Fresa</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Arcoíris</string>
|
||||
<string name="message_confirm_exit">Tocar 🔙 nuevamente para salir</string>
|
||||
<string name="settings_share_post_original">Compartir publicaciones desde la instancia
|
||||
original
|
||||
</string>
|
||||
<string name="community_action_unsubscribe">Cancelar suscripción</string>
|
||||
<string name="settings_search_posts_title_only">Buscar publicaciones sólo en el título</string>
|
||||
<string name="settings_content_font_family">Fuente del contenido</string>
|
||||
|
@ -258,7 +258,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Maasikas</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Vikerkaar</string>
|
||||
<string name="message_confirm_exit">Väljumiseks puudutage uuesti 🔙</string>
|
||||
<string name="settings_share_post_original">Jaga postitusi algsest eksemplarist</string>
|
||||
<string name="community_action_unsubscribe">Loobu tellimusest</string>
|
||||
<string name="settings_search_posts_title_only">Otsi postitusi ainult pealkirjast</string>
|
||||
<string name="settings_content_font_family">Sisu fondiperekond</string>
|
||||
|
@ -258,7 +258,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Mansikka</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Sateenkaari</string>
|
||||
<string name="message_confirm_exit">Poistu napauttamalla 🔙 uudelleen</string>
|
||||
<string name="settings_share_post_original">Jaa viestejä alkuperäisestä esiintymisestä</string>
|
||||
<string name="community_action_unsubscribe">Lopeta tilaus</string>
|
||||
<string name="settings_search_posts_title_only">Hae viestejä vain otsikosta</string>
|
||||
<string name="settings_content_font_family">Sisällön kirjasinperhe</string>
|
||||
|
@ -261,8 +261,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Fraise</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Arc-en-ciel</string>
|
||||
<string name="message_confirm_exit">Appuyez à nouveau sur 🔙 pour quitter</string>
|
||||
<string name="settings_share_post_original">Partager les publications de l\'instance d\'origine
|
||||
</string>
|
||||
<string name="community_action_unsubscribe">Se désabonner</string>
|
||||
<string name="settings_search_posts_title_only">Rechercher les publications uniquement dans le
|
||||
titre
|
||||
|
@ -267,7 +267,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Sú talún</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Bogha ceatha</string>
|
||||
<string name="message_confirm_exit">Tapáil 🔙 arís chun imeacht</string>
|
||||
<string name="settings_share_post_original">Roinn postálacha ón mbunús</string>
|
||||
<string name="community_action_unsubscribe">Díliostáil</string>
|
||||
<string name="settings_search_posts_title_only">Cuardaigh postálacha i dteideal amháin</string>
|
||||
<string name="settings_content_font_family">Teaghlach cló ábhar</string>
|
||||
|
@ -263,7 +263,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Jagoda</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Duga</string>
|
||||
<string name="message_confirm_exit">Ponovno dodirnite 🔙 za izlaz</string>
|
||||
<string name="settings_share_post_original">Dijelite postove iz izvorne instance</string>
|
||||
<string name="community_action_unsubscribe">Odjavi pretplatu</string>
|
||||
<string name="settings_search_posts_title_only">Pretraži postove samo u naslovu</string>
|
||||
<string name="settings_content_font_family">Obitelj fontova sadržaja</string>
|
||||
|
@ -262,7 +262,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Eper</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Szivárvány</string>
|
||||
<string name="message_confirm_exit">A kilépéshez érintse meg ismét a 🔙 elemet</string>
|
||||
<string name="settings_share_post_original">Oszd meg az eredeti példány bejegyzéseit</string>
|
||||
<string name="community_action_unsubscribe">Leiratkozás</string>
|
||||
<string name="settings_search_posts_title_only">Keresés a bejegyzésekben csak a címben</string>
|
||||
<string name="settings_content_font_family">Tartalmi betűtípuscsalád</string>
|
||||
|
@ -262,7 +262,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Fragola</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Arcobaleno</string>
|
||||
<string name="message_confirm_exit">Premi due volte 🔙 per uscire</string>
|
||||
<string name="settings_share_post_original">Condividi post dall\'istanza originale</string>
|
||||
<string name="community_action_unsubscribe">Disiscriviti</string>
|
||||
<string name="settings_search_posts_title_only">Cerca solo nel titolo dei post</string>
|
||||
<string name="settings_content_font_family">Font contenuti</string>
|
||||
|
@ -260,8 +260,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Braškių</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Vaivorykštė</string>
|
||||
<string name="message_confirm_exit">Bakstelėkite 🔙 dar kartą, kad išeitumėte</string>
|
||||
<string name="settings_share_post_original">Bendrinkite įrašus iš pradinio egzemplioriaus
|
||||
</string>
|
||||
<string name="community_action_unsubscribe">Atsisakyti prenumeratos</string>
|
||||
<string name="settings_search_posts_title_only">Ieškoti įrašų tik pavadinime</string>
|
||||
<string name="settings_content_font_family">Turinio šriftų šeima</string>
|
||||
|
@ -262,7 +262,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Zemeņu</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Varavīksne</string>
|
||||
<string name="message_confirm_exit">Lai izietu, vēlreiz pieskarieties 🔙</string>
|
||||
<string name="settings_share_post_original">Kopīgojiet ziņas no sākotnējās instances</string>
|
||||
<string name="community_action_unsubscribe">Anulēt abonementu</string>
|
||||
<string name="settings_search_posts_title_only">Meklēt ziņas tikai virsrakstā</string>
|
||||
<string name="settings_content_font_family">Satura fontu saime</string>
|
||||
|
@ -263,7 +263,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Frawli</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Qawsalla</string>
|
||||
<string name="message_confirm_exit">Tektek mill-ġdid 🔙 biex toħroġ</string>
|
||||
<string name="settings_share_post_original">Aqsam il-postijiet mill-istanza oriġinali</string>
|
||||
<string name="community_action_unsubscribe">Annulla l-abbonament</string>
|
||||
<string name="settings_search_posts_title_only">Fittex postijiet biss fit-titlu</string>
|
||||
<string name="settings_content_font_family">Familja tat-tipa tal-kontenut</string>
|
||||
|
@ -261,8 +261,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Aardbei</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Regenboog</string>
|
||||
<string name="message_confirm_exit">Tik nogmaals op 🔙 om af te sluiten</string>
|
||||
<string name="settings_share_post_original">Deel berichten van de oorspronkelijke instantie
|
||||
</string>
|
||||
<string name="community_action_unsubscribe">Uitschrijven</string>
|
||||
<string name="settings_search_posts_title_only">Zoek berichten alleen op titel</string>
|
||||
<string name="settings_content_font_family">Inhoud lettertypefamilie</string>
|
||||
|
@ -260,8 +260,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Jordbær</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Regnbue</string>
|
||||
<string name="message_confirm_exit">Trykk på 🔙 igjen for å avslutte</string>
|
||||
<string name="settings_share_post_original">Del innlegg fra den opprinnelige forekomsten
|
||||
</string>
|
||||
<string name="community_action_unsubscribe">Avslutte abonnementet</string>
|
||||
<string name="settings_search_posts_title_only">Søk kun innlegg i tittel</string>
|
||||
<string name="settings_content_font_family">Innhold fontfamilie</string>
|
||||
|
@ -261,7 +261,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Truskawka</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Tęcza</string>
|
||||
<string name="message_confirm_exit">Kliknij ponownie 🔙, aby wyjść</string>
|
||||
<string name="settings_share_post_original">Udostępniaj posty z oryginalnej instancji</string>
|
||||
<string name="community_action_unsubscribe">Zrezygnuj z subskrypcji</string>
|
||||
<string name="settings_search_posts_title_only">Szukaj postów tylko po tytule</string>
|
||||
<string name="settings_content_font_family">Rodzina czcionek treści</string>
|
||||
|
@ -260,8 +260,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Morango</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Arco-íris</string>
|
||||
<string name="message_confirm_exit">Tocar em 🔙 novamente para sair</string>
|
||||
<string name="settings_share_post_original">Compartilhar postagens da instância original
|
||||
</string>
|
||||
<string name="community_action_unsubscribe">Cancelar subscrição</string>
|
||||
<string name="settings_search_posts_title_only">Pesquise postagens apenas no título</string>
|
||||
<string name="settings_content_font_family">Fonte dos conteúdos</string>
|
||||
|
@ -259,7 +259,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Căpșună</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Curcubeu</string>
|
||||
<string name="message_confirm_exit">Apasă din nou 🔙 pentru a ieși</string>
|
||||
<string name="settings_share_post_original">Distribui postări din instanța originală</string>
|
||||
<string name="community_action_unsubscribe">Dezabonează-te</string>
|
||||
<string name="settings_search_posts_title_only">Căută postări numai în titlu</string>
|
||||
<string name="settings_content_font_family">Font conținuturilor</string>
|
||||
|
@ -261,8 +261,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Клубника</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Радуга</string>
|
||||
<string name="message_confirm_exit">Нажмите 🔙 еще раз, чтобы выйти</string>
|
||||
<string name="settings_share_post_original">Делитесь сообщениями из исходного экземпляра
|
||||
</string>
|
||||
<string name="community_action_unsubscribe">Отписаться</string>
|
||||
<string name="settings_search_posts_title_only">Искать сообщения только по заголовку</string>
|
||||
<string name="settings_content_font_family">Размер шрифта контента</string>
|
||||
|
@ -259,7 +259,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Jordgubbe</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Regnbåge</string>
|
||||
<string name="message_confirm_exit">Tryck på 🔙 igen för att avsluta</string>
|
||||
<string name="settings_share_post_original">Dela inlägg från den ursprungliga instansen</string>
|
||||
<string name="community_action_unsubscribe">Säga upp</string>
|
||||
<string name="settings_search_posts_title_only">Sök endast inlägg i rubriken</string>
|
||||
<string name="settings_content_font_family">Teckenstorlek för innehåll</string>
|
||||
|
@ -260,7 +260,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Jahodový</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Dúha</string>
|
||||
<string name="message_confirm_exit">Opätovným klepnutím na 🔙 ukončíte</string>
|
||||
<string name="settings_share_post_original">Zdieľajte príspevky z pôvodnej inštancie</string>
|
||||
<string name="community_action_unsubscribe">Zrušte odber</string>
|
||||
<string name="settings_search_posts_title_only">Hľadajte príspevky iba v názve</string>
|
||||
<string name="settings_content_font_family">Veľkosť písma obsahu</string>
|
||||
|
@ -258,7 +258,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Jagoda</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Mavrica</string>
|
||||
<string name="message_confirm_exit">Znova tapnite 🔙 za izhod</string>
|
||||
<string name="settings_share_post_original">Delite objave iz prvotnega primerka</string>
|
||||
<string name="community_action_unsubscribe">Odjavi se</string>
|
||||
<string name="settings_search_posts_title_only">Išči objave samo v naslovu</string>
|
||||
<string name="settings_content_font_family">Velikost pisave vsebine</string>
|
||||
|
@ -264,7 +264,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Luleshtrydhe</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Ylber</string>
|
||||
<string name="message_confirm_exit">Prekni sërish 🔙 për të dalë</string>
|
||||
<string name="settings_share_post_original">Ndani postimet nga shembulli origjinal</string>
|
||||
<string name="community_action_unsubscribe">Çregjistrohu</string>
|
||||
<string name="settings_search_posts_title_only">Kërkoni postimet vetëm në titull</string>
|
||||
<string name="settings_content_font_family">Madhësia e shkronjave të përmbajtjes</string>
|
||||
|
@ -261,7 +261,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Çilek</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Gökkuşağı</string>
|
||||
<string name="message_confirm_exit">Çıkmak için 🔙 simgesine tekrar dokunun</string>
|
||||
<string name="settings_share_post_original">Orijinal örnekteki gönderileri paylaşın</string>
|
||||
<string name="community_action_unsubscribe">Abonelikten çık</string>
|
||||
<string name="settings_search_posts_title_only">Gönderileri yalnızca başlıkta ara</string>
|
||||
<string name="settings_content_font_family">İçerik yazı tipi boyutu</string>
|
||||
|
@ -260,8 +260,6 @@
|
||||
<string name="settings_comment_bar_theme_red">🍓 Полуниця</string>
|
||||
<string name="settings_comment_bar_theme_multi">🌈 Веселка</string>
|
||||
<string name="message_confirm_exit">Натисніть 🔙 ще раз, щоб вийти</string>
|
||||
<string name="settings_share_post_original">Діліться публікаціями з оригінального екземпляра
|
||||
</string>
|
||||
<string name="community_action_unsubscribe">Відписатися</string>
|
||||
<string name="settings_search_posts_title_only">Шукати публікації лише за назвою</string>
|
||||
<string name="settings_content_font_family">Розмір шрифту вмісту</string>
|
||||
|
@ -26,7 +26,6 @@ interface CommunityDetailMviModel :
|
||||
data object Subscribe : Intent
|
||||
data object Unsubscribe : Intent
|
||||
data class DeletePost(val id: Int) : Intent
|
||||
data class SharePost(val id: Int) : Intent
|
||||
data class MarkAsRead(val id: Int) : Intent
|
||||
data class Hide(val id: Int) : Intent
|
||||
data object Block : Intent
|
||||
@ -38,10 +37,12 @@ interface CommunityDetailMviModel :
|
||||
data class ModLockPost(val id: Int) : Intent
|
||||
data class ModToggleModUser(val id: Int) : Intent
|
||||
data object ToggleFavorite : Intent
|
||||
data class Share(val url: String) : Intent
|
||||
}
|
||||
|
||||
data class UiState(
|
||||
val community: CommunityModel = CommunityModel(),
|
||||
val instance: String = "",
|
||||
val isLogged: Boolean = false,
|
||||
val refreshing: Boolean = false,
|
||||
val asyncInProgress: Boolean = false,
|
||||
|
@ -87,6 +87,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.PostCard
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.PostCardPlaceholder
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.di.getFabNestedScrollConnection
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.RawContentDialog
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.ShareBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.SortBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.navigation.di.getNavigationCoordinator
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.di.getNotificationCenter
|
||||
@ -791,9 +792,22 @@ class CommunityDetailScreen(
|
||||
CommunityDetailMviModel.Intent.Hide(post.id)
|
||||
)
|
||||
|
||||
OptionId.Share -> model.reduce(
|
||||
CommunityDetailMviModel.Intent.SharePost(post.id)
|
||||
OptionId.Share -> {
|
||||
val urls = listOfNotNull(
|
||||
post.originalUrl,
|
||||
"https://${uiState.instance}/post/${post.id}"
|
||||
).distinct()
|
||||
if (urls.size == 1) {
|
||||
model.reduce(
|
||||
CommunityDetailMviModel.Intent.Share(
|
||||
urls.first()
|
||||
)
|
||||
)
|
||||
} else {
|
||||
val screen = ShareBottomSheet(urls = urls)
|
||||
navigationCoordinator.showBottomSheet(screen)
|
||||
}
|
||||
}
|
||||
|
||||
OptionId.FeaturePost -> model.reduce(
|
||||
CommunityDetailMviModel.Intent.ModFeaturePost(
|
||||
|
@ -63,6 +63,8 @@ class CommunityDetailViewModel(
|
||||
mvi.updateState {
|
||||
it.copy(
|
||||
community = it.community.takeIf { c -> c.id != 0 } ?: community,
|
||||
instance = otherInstance.takeIf { n -> n.isNotEmpty() }
|
||||
?: apiConfigurationRepository.instance.value,
|
||||
)
|
||||
}
|
||||
|
||||
@ -131,6 +133,9 @@ class CommunityDetailViewModel(
|
||||
.onEach { evt ->
|
||||
applySortType(evt.value)
|
||||
}.launchIn(this)
|
||||
notificationCenter.subscribe(NotificationCenterEvent.Share::class).onEach { evt ->
|
||||
shareHelper.share(evt.url)
|
||||
}.launchIn(this)
|
||||
|
||||
if (uiState.value.currentUserId == null) {
|
||||
val auth = identityRepository.authToken.value.orEmpty()
|
||||
@ -164,6 +169,10 @@ class CommunityDetailViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
is CommunityDetailMviModel.Intent.Share -> {
|
||||
shareHelper.share(intent.url)
|
||||
}
|
||||
|
||||
is CommunityDetailMviModel.Intent.SavePost -> {
|
||||
if (intent.feedback) {
|
||||
hapticFeedback.vibrate()
|
||||
@ -187,11 +196,6 @@ class CommunityDetailViewModel(
|
||||
CommunityDetailMviModel.Intent.Subscribe -> subscribe()
|
||||
CommunityDetailMviModel.Intent.Unsubscribe -> unsubscribe()
|
||||
is CommunityDetailMviModel.Intent.DeletePost -> handlePostDelete(intent.id)
|
||||
is CommunityDetailMviModel.Intent.SharePost -> {
|
||||
uiState.value.posts.firstOrNull { it.id == intent.id }?.also { post ->
|
||||
share(post = post)
|
||||
}
|
||||
}
|
||||
|
||||
CommunityDetailMviModel.Intent.Block -> blockCommunity()
|
||||
CommunityDetailMviModel.Intent.BlockInstance -> blockInstance()
|
||||
@ -486,20 +490,6 @@ class CommunityDetailViewModel(
|
||||
mvi.updateState { it.copy(posts = it.posts.filter { post -> post.id != id }) }
|
||||
}
|
||||
|
||||
private fun share(post: PostModel) {
|
||||
val shareOriginal = settingsRepository.currentSettings.value.sharePostOriginal
|
||||
val url = if (shareOriginal) {
|
||||
post.originalUrl.orEmpty()
|
||||
} else if (otherInstance.isNotEmpty()) {
|
||||
"https://${otherInstance}/post/${post.id}"
|
||||
} else {
|
||||
"https://${apiConfigurationRepository.instance.value}/post/${post.id}"
|
||||
}
|
||||
if (url.isNotEmpty()) {
|
||||
shareHelper.share(url, "text/plain")
|
||||
}
|
||||
}
|
||||
|
||||
private fun blockCommunity() {
|
||||
mvi.updateState { it.copy(asyncInProgress = true) }
|
||||
mvi.scope?.launch(Dispatchers.IO) {
|
||||
|
@ -18,10 +18,10 @@ interface MultiCommunityMviModel :
|
||||
data class UpVotePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class DownVotePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class SavePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class SharePost(val id: Int) : Intent
|
||||
data class MarkAsRead(val id: Int) : Intent
|
||||
data class Hide(val id: Int) : Intent
|
||||
data object ClearRead : Intent
|
||||
data class Share(val url: String) : Intent
|
||||
}
|
||||
|
||||
data class UiState(
|
||||
|
@ -66,6 +66,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.OptionId
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.PostCard
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.PostCardPlaceholder
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.di.getFabNestedScrollConnection
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.ShareBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.SortBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.navigation.di.getNavigationCoordinator
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.data.MultiCommunityModel
|
||||
@ -391,9 +392,22 @@ class MultiCommunityScreen(
|
||||
)
|
||||
)
|
||||
|
||||
OptionId.Share -> model.reduce(
|
||||
MultiCommunityMviModel.Intent.SharePost(post.id)
|
||||
OptionId.Share -> {
|
||||
val urls = listOfNotNull(
|
||||
post.originalUrl,
|
||||
"https://${uiState.instance}/post/${post.id}"
|
||||
).distinct()
|
||||
if (urls.size == 1) {
|
||||
model.reduce(
|
||||
MultiCommunityMviModel.Intent.Share(
|
||||
urls.first()
|
||||
)
|
||||
)
|
||||
} else {
|
||||
val screen = ShareBottomSheet(urls = urls)
|
||||
navigationCoordinator.showBottomSheet(screen)
|
||||
}
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
|
@ -72,6 +72,9 @@ class MultiCommunityViewModel(
|
||||
.onEach { evt ->
|
||||
applySortType(evt.value)
|
||||
}.launchIn(this)
|
||||
notificationCenter.subscribe(NotificationCenterEvent.Share::class).onEach { evt ->
|
||||
shareHelper.share(evt.url)
|
||||
}.launchIn(this)
|
||||
|
||||
if (uiState.value.currentUserId == null) {
|
||||
val auth = identityRepository.authToken.value.orEmpty()
|
||||
@ -120,9 +123,9 @@ class MultiCommunityViewModel(
|
||||
)
|
||||
}
|
||||
|
||||
is MultiCommunityMviModel.Intent.SharePost -> share(
|
||||
post = uiState.value.posts.first { it.id == intent.id }
|
||||
)
|
||||
is MultiCommunityMviModel.Intent.Share -> {
|
||||
shareHelper.share(intent.url)
|
||||
}
|
||||
|
||||
is MultiCommunityMviModel.Intent.UpVotePost -> {
|
||||
if (intent.feedback) {
|
||||
@ -314,18 +317,6 @@ class MultiCommunityViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
private fun share(post: PostModel) {
|
||||
val shareOriginal = settingsRepository.currentSettings.value.sharePostOriginal
|
||||
val url = if (shareOriginal) {
|
||||
post.originalUrl.orEmpty()
|
||||
} else {
|
||||
"https://${apiConfigurationRepository.instance.value}/post/${post.id}"
|
||||
}
|
||||
if (url.isNotEmpty()) {
|
||||
shareHelper.share(url, "text/plain")
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearRead() {
|
||||
hideReadPosts = true
|
||||
mvi.updateState {
|
||||
|
@ -19,7 +19,7 @@ interface ProfileLoggedMviModel :
|
||||
data object LoadNextPage : Intent
|
||||
data class DeletePost(val id: Int) : Intent
|
||||
data class DeleteComment(val id: Int) : Intent
|
||||
data class SharePost(val id: Int) : Intent
|
||||
data class Share(val url: String) : Intent
|
||||
data class UpVotePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class DownVotePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class SavePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
@ -31,6 +31,7 @@ interface ProfileLoggedMviModel :
|
||||
|
||||
data class UiState(
|
||||
val user: UserModel? = null,
|
||||
val instance: String = "",
|
||||
val section: ProfileLoggedSection = ProfileLoggedSection.Posts,
|
||||
val refreshing: Boolean = false,
|
||||
val loading: Boolean = false,
|
||||
|
@ -49,6 +49,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.PostCardPl
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.ProfileLoggedSection
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.UserHeader
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.RawContentDialog
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.ShareBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.navigation.TabNavigationSection
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.navigation.di.getNavigationCoordinator
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.NotificationCenterEvent
|
||||
@ -279,9 +280,22 @@ object ProfileLoggedScreen : Tab {
|
||||
rawContent = post
|
||||
}
|
||||
|
||||
OptionId.Share -> model.reduce(
|
||||
ProfileLoggedMviModel.Intent.SharePost(post.id)
|
||||
OptionId.Share -> {
|
||||
val urls = listOfNotNull(
|
||||
post.originalUrl,
|
||||
"https://${uiState.instance}/post/${post.id}"
|
||||
).distinct()
|
||||
if (urls.size == 1) {
|
||||
model.reduce(
|
||||
ProfileLoggedMviModel.Intent.Share(
|
||||
urls.first()
|
||||
)
|
||||
)
|
||||
} else {
|
||||
val screen = ShareBottomSheet(urls = urls)
|
||||
navigationCoordinator.showBottomSheet(screen)
|
||||
}
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ class ProfileLoggedViewModel(
|
||||
@OptIn(FlowPreview::class)
|
||||
override fun onStarted() {
|
||||
mvi.onStarted()
|
||||
mvi.updateState { it.copy(instance = apiConfigurationRepository.instance.value) }
|
||||
mvi.scope?.launch(Dispatchers.IO) {
|
||||
themeRepository.postLayout.onEach { layout ->
|
||||
mvi.updateState { it.copy(postLayout = layout) }
|
||||
@ -83,6 +84,9 @@ class ProfileLoggedViewModel(
|
||||
notificationCenter.subscribe(NotificationCenterEvent.PostDeleted::class).onEach { evt ->
|
||||
handlePostDelete(evt.model.id)
|
||||
}.launchIn(this)
|
||||
notificationCenter.subscribe(NotificationCenterEvent.Share::class).onEach { evt ->
|
||||
shareHelper.share(evt.url)
|
||||
}.launchIn(this)
|
||||
|
||||
if (uiState.value.posts.isEmpty()) {
|
||||
refreshUser()
|
||||
@ -104,10 +108,8 @@ class ProfileLoggedViewModel(
|
||||
refresh()
|
||||
}
|
||||
|
||||
is ProfileLoggedMviModel.Intent.SharePost -> {
|
||||
uiState.value.posts.firstOrNull { it.id == intent.id }?.also { post ->
|
||||
share(post = post)
|
||||
}
|
||||
is ProfileLoggedMviModel.Intent.Share -> {
|
||||
shareHelper.share(intent.url)
|
||||
}
|
||||
|
||||
is ProfileLoggedMviModel.Intent.DownVoteComment -> {
|
||||
@ -452,16 +454,4 @@ class ProfileLoggedViewModel(
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
private fun share(post: PostModel) {
|
||||
val shareOriginal = settingsRepository.currentSettings.value.sharePostOriginal
|
||||
val url = if (shareOriginal) {
|
||||
post.originalUrl.orEmpty()
|
||||
} else {
|
||||
"https://${apiConfigurationRepository.instance.value}/post/${post.id}"
|
||||
}
|
||||
if (url.isNotEmpty()) {
|
||||
shareHelper.share(url, "text/plain")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,15 +31,16 @@ interface PostDetailMviModel :
|
||||
data class DeleteComment(val commentId: Int) : Intent
|
||||
data object DeletePost : Intent
|
||||
data object HapticIndication : Intent
|
||||
data object SharePost : Intent
|
||||
data object ModFeaturePost : Intent
|
||||
data object ModLockPost : Intent
|
||||
data class ModDistinguishComment(val commentId: Int) : Intent
|
||||
data class ModToggleModUser(val id: Int) : Intent
|
||||
data class Share(val url: String) : Intent
|
||||
}
|
||||
|
||||
data class UiState(
|
||||
val post: PostModel = PostModel(),
|
||||
val instance: String = "",
|
||||
val isModerator: Boolean = false,
|
||||
val isLogged: Boolean = false,
|
||||
val refreshing: Boolean = false,
|
||||
|
@ -87,6 +87,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.OptionId
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.PostCard
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.di.getFabNestedScrollConnection
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.RawContentDialog
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.ShareBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.SortBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.navigation.di.getNavigationCoordinator
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.di.getNotificationCenter
|
||||
@ -469,7 +470,18 @@ class PostDetailScreen(
|
||||
rawContent = uiState.post
|
||||
}
|
||||
|
||||
OptionId.Share -> model.reduce(PostDetailMviModel.Intent.SharePost)
|
||||
OptionId.Share -> {
|
||||
val urls = listOfNotNull(
|
||||
post.originalUrl,
|
||||
"https://${uiState.instance}/post/${post.id}"
|
||||
).distinct()
|
||||
if (urls.size == 1) {
|
||||
model.reduce(PostDetailMviModel.Intent.Share(urls.first()))
|
||||
} else {
|
||||
val screen = ShareBottomSheet(urls = urls)
|
||||
navigationCoordinator.showBottomSheet(screen)
|
||||
}
|
||||
}
|
||||
|
||||
OptionId.FeaturePost -> model.reduce(
|
||||
PostDetailMviModel.Intent.ModFeaturePost,
|
||||
|
@ -53,7 +53,12 @@ class PostDetailViewModel(
|
||||
|
||||
override fun onStarted() {
|
||||
mvi.onStarted()
|
||||
|
||||
mvi.updateState {
|
||||
it.copy(
|
||||
instance = otherInstance.takeIf { n -> n.isNotEmpty() }
|
||||
?: apiConfigurationRepository.instance.value,
|
||||
)
|
||||
}
|
||||
mvi.scope?.launch(Dispatchers.Main) {
|
||||
notificationCenter.subscribe(NotificationCenterEvent.PostUpdated::class).onEach { evt ->
|
||||
handlePostUpdate(evt.model)
|
||||
@ -113,6 +118,9 @@ class PostDetailViewModel(
|
||||
notificationCenter.subscribe(NotificationCenterEvent.PostUpdated::class).onEach {
|
||||
refreshPost()
|
||||
}.launchIn(this)
|
||||
notificationCenter.subscribe(NotificationCenterEvent.Share::class).onEach { evt ->
|
||||
shareHelper.share(evt.url)
|
||||
}.launchIn(this)
|
||||
}
|
||||
|
||||
mvi.scope?.launch(Dispatchers.IO) {
|
||||
@ -259,6 +267,10 @@ class PostDetailViewModel(
|
||||
toggleSavePost(post = intent.post)
|
||||
}
|
||||
|
||||
is PostDetailMviModel.Intent.Share -> {
|
||||
shareHelper.share(intent.url)
|
||||
}
|
||||
|
||||
is PostDetailMviModel.Intent.UpVoteComment -> {
|
||||
if (intent.feedback) {
|
||||
hapticFeedback.vibrate()
|
||||
@ -282,9 +294,6 @@ class PostDetailViewModel(
|
||||
|
||||
is PostDetailMviModel.Intent.DeleteComment -> deleteComment(intent.commentId)
|
||||
PostDetailMviModel.Intent.DeletePost -> deletePost()
|
||||
PostDetailMviModel.Intent.SharePost -> share(
|
||||
post = uiState.value.post,
|
||||
)
|
||||
|
||||
is PostDetailMviModel.Intent.ToggleExpandComment -> {
|
||||
uiState.value.comments.firstOrNull { it.id == intent.commentId }
|
||||
@ -475,7 +484,9 @@ class PostDetailViewModel(
|
||||
post = post,
|
||||
downVoted = newValue,
|
||||
)
|
||||
mvi.updateState { it.copy(post = newPost) }
|
||||
mvi.updateState {
|
||||
it.copy(post = newPost)
|
||||
}
|
||||
mvi.scope?.launch(Dispatchers.IO) {
|
||||
try {
|
||||
val auth = identityRepository.authToken.value.orEmpty()
|
||||
@ -629,20 +640,6 @@ class PostDetailViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
private fun share(post: PostModel) {
|
||||
val shareOriginal = settingsRepository.currentSettings.value.sharePostOriginal
|
||||
val url = if (shareOriginal) {
|
||||
post.originalUrl.orEmpty()
|
||||
} else if (otherInstance.isNotEmpty()) {
|
||||
"https://${otherInstance}/post/${post.id}"
|
||||
} else {
|
||||
"https://${apiConfigurationRepository.instance.value}/post/${post.id}"
|
||||
}
|
||||
if (url.isNotEmpty()) {
|
||||
shareHelper.share(url, "text/plain")
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleExpanded(comment: CommentModel) {
|
||||
mvi.scope?.launch {
|
||||
val commentId = comment.id
|
||||
|
@ -25,7 +25,7 @@ interface PostListMviModel :
|
||||
data class HandlePostUpdate(val post: PostModel) : Intent
|
||||
data object HapticIndication : Intent
|
||||
data class DeletePost(val id: Int) : Intent
|
||||
data class SharePost(val id: Int) : Intent
|
||||
data class Share(val url: String) : Intent
|
||||
data class MarkAsRead(val id: Int) : Intent
|
||||
data class Hide(val id: Int) : Intent
|
||||
data object ClearRead : Intent
|
||||
|
@ -69,6 +69,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.di.getFabN
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.BlockBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.ListingTypeBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.RawContentDialog
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.ShareBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.SortBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.navigation.TabNavigationSection
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.navigation.di.getDrawerCoordinator
|
||||
@ -515,9 +516,22 @@ class PostListScreen : Screen {
|
||||
)
|
||||
)
|
||||
|
||||
OptionId.Share -> model.reduce(
|
||||
PostListMviModel.Intent.SharePost(post.id)
|
||||
OptionId.Share -> {
|
||||
val urls = listOfNotNull(
|
||||
post.originalUrl,
|
||||
"https://${uiState.instance}/post/${post.id}"
|
||||
).distinct()
|
||||
if (urls.size == 1) {
|
||||
model.reduce(
|
||||
PostListMviModel.Intent.Share(
|
||||
urls.first()
|
||||
)
|
||||
)
|
||||
} else {
|
||||
val screen = ShareBottomSheet(urls = urls)
|
||||
navigationCoordinator.showBottomSheet(screen)
|
||||
}
|
||||
}
|
||||
|
||||
OptionId.Block -> {
|
||||
val screen = BlockBottomSheet(
|
||||
|
@ -124,6 +124,9 @@ class PostListViewModel(
|
||||
instanceId != null -> blockInstance(instanceId)
|
||||
}
|
||||
}.launchIn(this)
|
||||
notificationCenter.subscribe(NotificationCenterEvent.Share::class).onEach { evt ->
|
||||
shareHelper.share(evt.url)
|
||||
}.launchIn(this)
|
||||
|
||||
zombieModeHelper.index.onEach { index ->
|
||||
if (uiState.value.zombieModeActive) {
|
||||
@ -205,10 +208,8 @@ class PostListViewModel(
|
||||
PostListMviModel.Intent.HapticIndication -> hapticFeedback.vibrate()
|
||||
is PostListMviModel.Intent.HandlePostUpdate -> handlePostUpdate(intent.post)
|
||||
is PostListMviModel.Intent.DeletePost -> handlePostDelete(intent.id)
|
||||
is PostListMviModel.Intent.SharePost -> {
|
||||
uiState.value.posts.firstOrNull { it.id == intent.id }?.also { post ->
|
||||
share(post = post)
|
||||
}
|
||||
is PostListMviModel.Intent.Share -> {
|
||||
shareHelper.share(intent.url)
|
||||
}
|
||||
|
||||
is PostListMviModel.Intent.MarkAsRead -> {
|
||||
@ -458,18 +459,6 @@ class PostListViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
private fun share(post: PostModel) {
|
||||
val shareOriginal = settingsRepository.currentSettings.value.sharePostOriginal
|
||||
val url = if (shareOriginal) {
|
||||
post.originalUrl.orEmpty()
|
||||
} else {
|
||||
"https://${apiConfigurationRepository.instance.value}/post/${post.id}"
|
||||
}
|
||||
if (url.isNotEmpty()) {
|
||||
shareHelper.share(url, "text/plain")
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearRead() {
|
||||
hideReadPosts = true
|
||||
mvi.updateState {
|
||||
|
@ -23,15 +23,16 @@ interface SavedItemsMviModel :
|
||||
data class UpVotePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class DownVotePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class SavePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class SharePost(val id: Int) : Intent
|
||||
data class UpVoteComment(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class DownVoteComment(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class SaveComment(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class Share(val url: String) : Intent
|
||||
}
|
||||
|
||||
data class UiState(
|
||||
val section: SavedItemsSection = SavedItemsSection.Posts,
|
||||
val user: UserModel? = null,
|
||||
val instance: String = "",
|
||||
val refreshing: Boolean = false,
|
||||
val loading: Boolean = false,
|
||||
val canFetchMore: Boolean = true,
|
||||
|
@ -59,6 +59,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.OptionId
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.PostCard
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.di.getFabNestedScrollConnection
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.RawContentDialog
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.ShareBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.SortBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.navigation.di.getNavigationCoordinator
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.di.getSettingsRepository
|
||||
@ -299,11 +300,20 @@ class SavedItemsScreen : Screen {
|
||||
}
|
||||
|
||||
OptionId.Share -> {
|
||||
val urls = listOfNotNull(
|
||||
post.originalUrl,
|
||||
"https://${uiState.instance}/post/${post.id}"
|
||||
).distinct()
|
||||
if (urls.size == 1) {
|
||||
model.reduce(
|
||||
SavedItemsMviModel.Intent.SharePost(
|
||||
post.id
|
||||
SavedItemsMviModel.Intent.Share(
|
||||
urls.first()
|
||||
)
|
||||
)
|
||||
} else {
|
||||
val screen = ShareBottomSheet(urls = urls)
|
||||
navigationCoordinator.showBottomSheet(screen)
|
||||
}
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
|
@ -45,6 +45,7 @@ class SavedItemsViewModel(
|
||||
|
||||
override fun onStarted() {
|
||||
mvi.onStarted()
|
||||
mvi.updateState { it.copy(instance = apiConfigurationRepository.instance.value) }
|
||||
mvi.scope?.launch {
|
||||
themeRepository.postLayout.onEach { layout ->
|
||||
mvi.updateState { it.copy(postLayout = layout) }
|
||||
@ -68,6 +69,10 @@ class SavedItemsViewModel(
|
||||
.onEach { evt ->
|
||||
applySortType(evt.value)
|
||||
}.launchIn(this)
|
||||
notificationCenter.subscribe(NotificationCenterEvent.Share::class).onEach { evt ->
|
||||
shareHelper.share(evt.url)
|
||||
}.launchIn(this)
|
||||
|
||||
if (mvi.uiState.value.posts.isEmpty()) {
|
||||
val sortTypes = getSortTypesUseCase.getTypesForSavedItems()
|
||||
mvi.updateState { it.copy(availableSortTypes = sortTypes) }
|
||||
@ -117,6 +122,10 @@ class SavedItemsViewModel(
|
||||
)
|
||||
}
|
||||
|
||||
is SavedItemsMviModel.Intent.Share -> {
|
||||
shareHelper.share(intent.url)
|
||||
}
|
||||
|
||||
is SavedItemsMviModel.Intent.UpVoteComment -> {
|
||||
if (intent.feedback) {
|
||||
hapticFeedback.vibrate()
|
||||
@ -136,9 +145,6 @@ class SavedItemsViewModel(
|
||||
}
|
||||
|
||||
is SavedItemsMviModel.Intent.ChangeSort -> applySortType(intent.value)
|
||||
is SavedItemsMviModel.Intent.SharePost -> share(
|
||||
post = uiState.value.posts.first { it.id == intent.id }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -399,16 +405,4 @@ class SavedItemsViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun share(post: PostModel) {
|
||||
val shareOriginal = settingsRepository.currentSettings.value.sharePostOriginal
|
||||
val url = if (shareOriginal) {
|
||||
post.originalUrl.orEmpty()
|
||||
} else {
|
||||
"https://${apiConfigurationRepository.instance.value}/post/${post.id}"
|
||||
}
|
||||
if (url.isNotEmpty()) {
|
||||
shareHelper.share(url, "text/plain")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,13 +28,14 @@ interface UserDetailMviModel :
|
||||
data class DownVoteComment(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class SaveComment(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data object HapticIndication : Intent
|
||||
data class SharePost(val id: Int) : Intent
|
||||
data class Share(val url: String) : Intent
|
||||
data object Block : Intent
|
||||
data object BlockInstance : Intent
|
||||
}
|
||||
|
||||
data class UiState(
|
||||
val isLogged: Boolean = false,
|
||||
val instance: String = "",
|
||||
val currentUserId: Int? = null,
|
||||
val section: UserDetailSection = UserDetailSection.Posts,
|
||||
val sortType: SortType = SortType.Active,
|
||||
|
@ -86,6 +86,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.UserDetail
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.UserHeader
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.di.getFabNestedScrollConnection
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.RawContentDialog
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.ShareBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.SortBottomSheet
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.navigation.di.getNavigationCoordinator
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.di.getNotificationCenter
|
||||
@ -603,9 +604,22 @@ class UserDetailScreen(
|
||||
rawContent = post
|
||||
}
|
||||
|
||||
OptionId.Share -> model.reduce(
|
||||
UserDetailMviModel.Intent.SharePost(post.id)
|
||||
OptionId.Share -> {
|
||||
val urls = listOfNotNull(
|
||||
post.originalUrl,
|
||||
"https://${uiState.instance}/post/${post.id}"
|
||||
).distinct()
|
||||
if (urls.size == 1) {
|
||||
model.reduce(
|
||||
UserDetailMviModel.Intent.Share(
|
||||
urls.first()
|
||||
)
|
||||
)
|
||||
} else {
|
||||
val screen = ShareBottomSheet(urls = urls)
|
||||
navigationCoordinator.showBottomSheet(screen)
|
||||
}
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
|
@ -53,6 +53,12 @@ class UserDetailViewModel(
|
||||
|
||||
override fun onStarted() {
|
||||
mvi.onStarted()
|
||||
mvi.updateState {
|
||||
it.copy(
|
||||
instance = otherInstance.takeIf { n -> n.isNotEmpty() }
|
||||
?: apiConfigurationRepository.instance.value,
|
||||
)
|
||||
}
|
||||
mvi.scope?.launch {
|
||||
themeRepository.postLayout.onEach { layout ->
|
||||
mvi.updateState { it.copy(postLayout = layout) }
|
||||
@ -64,6 +70,9 @@ class UserDetailViewModel(
|
||||
.onEach { evt ->
|
||||
applySortType(evt.value)
|
||||
}.launchIn(this)
|
||||
notificationCenter.subscribe(NotificationCenterEvent.Share::class).onEach { evt ->
|
||||
shareHelper.share(evt.url)
|
||||
}.launchIn(this)
|
||||
}
|
||||
mvi.updateState {
|
||||
it.copy(
|
||||
@ -173,10 +182,8 @@ class UserDetailViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
is UserDetailMviModel.Intent.SharePost -> {
|
||||
uiState.value.posts.firstOrNull { it.id == intent.id }?.also { post ->
|
||||
share(post = post)
|
||||
}
|
||||
is UserDetailMviModel.Intent.Share -> {
|
||||
shareHelper.share(intent.url)
|
||||
}
|
||||
|
||||
UserDetailMviModel.Intent.Block -> blockUser()
|
||||
@ -478,20 +485,6 @@ class UserDetailViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
private fun share(post: PostModel) {
|
||||
val shareOriginal = settingsRepository.currentSettings.value.sharePostOriginal
|
||||
val url = if (shareOriginal) {
|
||||
post.originalUrl.orEmpty()
|
||||
} else if (otherInstance.isNotEmpty()) {
|
||||
"https://${otherInstance}/post/${post.id}"
|
||||
} else {
|
||||
"https://${apiConfigurationRepository.instance.value}/post/${post.id}"
|
||||
}
|
||||
if (url.isNotEmpty()) {
|
||||
shareHelper.share(url, "text/plain")
|
||||
}
|
||||
}
|
||||
|
||||
private fun blockUser() {
|
||||
mvi.updateState { it.copy(asyncInProgress = true) }
|
||||
mvi.scope?.launch(Dispatchers.IO) {
|
||||
|
@ -75,7 +75,7 @@ class WebViewScreen(
|
||||
Icon(
|
||||
modifier = Modifier.onClick(
|
||||
onClick = rememberCallback {
|
||||
shareHelper.share(url, "text/plain")
|
||||
shareHelper.share(url)
|
||||
},
|
||||
),
|
||||
imageVector = Icons.Default.Share,
|
||||
|
Loading…
x
Reference in New Issue
Block a user