diff --git a/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/data/CommentBarTheme.kt b/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/data/CommentBarTheme.kt index 5631d2ccf..d9513b5d2 100644 --- a/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/data/CommentBarTheme.kt +++ b/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/data/CommentBarTheme.kt @@ -49,4 +49,12 @@ fun CommentBarTheme?.toDownVoteColor(): Color = when (this) { CommentBarTheme.Green -> Color(0xFFAD4877) CommentBarTheme.Blue -> Color(0xFF9400D3) else -> Color.Transparent +} + +fun CommentBarTheme?.toReplyColor(): Color = when (this) { + CommentBarTheme.Rainbow -> Color(0xFFFF5722) + CommentBarTheme.Red -> Color(0xFF8BC34A) + CommentBarTheme.Green -> Color(0xFFFF9800) + CommentBarTheme.Blue -> Color(0xFF388E3C) + else -> Color.Transparent } \ No newline at end of file diff --git a/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/DefaultThemeRepository.kt b/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/DefaultThemeRepository.kt index e757ed3cb..10c87f882 100644 --- a/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/DefaultThemeRepository.kt +++ b/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/DefaultThemeRepository.kt @@ -20,6 +20,7 @@ internal class DefaultThemeRepository : ThemeRepository { override val customSeedColor = MutableStateFlow(null) override val upvoteColor = MutableStateFlow(null) override val downvoteColor = MutableStateFlow(null) + override val replyColor = MutableStateFlow(null) override val postLayout = MutableStateFlow(PostLayout.Card) override val commentBarTheme = MutableStateFlow(CommentBarTheme.Blue) @@ -72,6 +73,10 @@ internal class DefaultThemeRepository : ThemeRepository { downvoteColor.value = color } + override fun changeReplyColor(color: Color?) { + replyColor.value = color + } + override fun changePostLayout(value: PostLayout) { postLayout.value = value } diff --git a/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/ThemeRepository.kt b/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/ThemeRepository.kt index 46d6c523f..ad73e0946 100644 --- a/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/ThemeRepository.kt +++ b/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/ThemeRepository.kt @@ -21,6 +21,7 @@ interface ThemeRepository { val customSeedColor: StateFlow val upvoteColor: StateFlow val downvoteColor: StateFlow + val replyColor: StateFlow val postLayout: StateFlow val commentBarTheme: StateFlow @@ -46,6 +47,8 @@ interface ThemeRepository { fun changeDownvoteColor(color: Color?) + fun changeReplyColor(color: Color?) + fun changePostLayout(value: PostLayout) fun changeCommentBarTheme(value: CommentBarTheme) diff --git a/core/commonui/components/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/SwipeableCard.kt b/core/commonui/components/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/SwipeableCard.kt index 8b99f0163..77bbf72e8 100644 --- a/core/commonui/components/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/SwipeableCard.kt +++ b/core/commonui/components/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/SwipeableCard.kt @@ -27,6 +27,8 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.stateIn +private const val SECOND_ACTION_THRESHOLD = 0.35f + @OptIn(ExperimentalMaterial3Api::class) @Composable fun SwipeableCard( @@ -36,44 +38,78 @@ fun SwipeableCard( DismissDirection.EndToStart, ), enabled: Boolean = true, + enableSecondAction: (DismissValue) -> Boolean = { false }, content: @Composable () -> Unit, swipeContent: @Composable (DismissDirection) -> Unit, + secondSwipeContent: @Composable ((DismissDirection) -> Unit)? = null, backgroundColor: (DismissValue) -> Color, + secondBackgroundColor: ((DismissValue) -> Color)? = null, onGestureBegin: (() -> Unit)? = null, onDismissToEnd: (() -> Unit)? = null, + onSecondDismissToEnd: (() -> Unit)? = null, onDismissToStart: (() -> Unit)? = null, + onSecondDismissToStart: (() -> Unit)? = null, ) { if (enabled) { + var notified by remember { mutableStateOf(false) } + var secondNotified by remember { mutableStateOf(false) } val dismissToEndCallback by rememberUpdatedState(onDismissToEnd) val dismissToStartCallback by rememberUpdatedState(onDismissToStart) + val secondDismissToEndCallback by rememberUpdatedState(onSecondDismissToEnd) + val secondDismissToStartCallback by rememberUpdatedState(onSecondDismissToStart) val gestureBeginCallback by rememberUpdatedState(onGestureBegin) + var lastProgress by remember { mutableStateOf(0.0f) } val dismissState = rememberDismissState( - confirmValueChange = rememberCallbackArgs { direction -> - when (direction) { + confirmValueChange = rememberCallbackArgs { value -> + when (value) { DismissValue.DismissedToEnd -> { - dismissToEndCallback?.invoke() + if (lastProgress >= SECOND_ACTION_THRESHOLD) { + secondDismissToEndCallback?.invoke() + } else { + dismissToEndCallback?.invoke() + } } DismissValue.DismissedToStart -> { - dismissToStartCallback?.invoke() + if (lastProgress >= SECOND_ACTION_THRESHOLD) { + secondDismissToStartCallback?.invoke() + } else { + dismissToStartCallback?.invoke() + } } else -> Unit } + notified = false + secondNotified = false + // return false to stay dismissed false }, positionalThreshold = { _ -> 56.dp.toPx() } ) - - var notified by remember { mutableStateOf(false) } LaunchedEffect(dismissState) { snapshotFlow { dismissState.progress }.stateIn(this).onEach { progress -> - if (progress in 0.0..<1.0 && !notified) { - notified = true - gestureBeginCallback?.invoke() - } else if (progress >= 1) { - notified = false + if (!enableSecondAction(dismissState.targetValue)) { + when { + progress in 0.0f..<1.0f && !notified -> { + notified = true + gestureBeginCallback?.invoke() + } + } + } else { + when { + progress in 0.0f.. { + notified = true + gestureBeginCallback?.invoke() + } + + progress in SECOND_ACTION_THRESHOLD..<1.0f && !secondNotified -> { + secondNotified = true + gestureBeginCallback?.invoke() + } + } } + lastProgress = progress }.launchIn(this) } @@ -84,7 +120,16 @@ fun SwipeableCard( background = { val direction = dismissState.dismissDirection ?: DismissDirection.StartToEnd val bgColor by animateColorAsState( - backgroundColor(dismissState.targetValue), + targetValue = if ( + dismissState.progress < SECOND_ACTION_THRESHOLD + || dismissState.targetValue == DismissValue.Default + || !enableSecondAction(dismissState.targetValue) + ) { + backgroundColor(dismissState.targetValue) + } else { + secondBackgroundColor?.invoke(dismissState.targetValue) + ?: backgroundColor(dismissState.targetValue) + }, ) val alignment = when (direction) { DismissDirection.StartToEnd -> Alignment.CenterStart @@ -96,7 +141,14 @@ fun SwipeableCard( .padding(horizontal = 20.dp), contentAlignment = alignment, ) { - swipeContent(direction) + if ( + dismissState.progress < SECOND_ACTION_THRESHOLD + || !enableSecondAction(dismissState.targetValue) + ) { + swipeContent(direction) + } else { + secondSwipeContent?.invoke(direction) + } } }, dismissContent = { diff --git a/core/commonui/modals/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/modals/VoteThemeBottomSheet.kt b/core/commonui/modals/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/modals/VoteThemeBottomSheet.kt index 3ef4a8610..cfdd8507e 100644 --- a/core/commonui/modals/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/modals/VoteThemeBottomSheet.kt +++ b/core/commonui/modals/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/modals/VoteThemeBottomSheet.kt @@ -31,6 +31,7 @@ import cafe.adriel.voyager.core.screen.Screen import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.CommentBarTheme import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.toDownVoteColor import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.toReadableName +import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.toReplyColor import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.toUpVoteColor import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.BottomSheetHandle @@ -44,7 +45,7 @@ import com.github.diegoberaldin.raccoonforlemmy.resources.MR import dev.icerock.moko.resources.compose.stringResource class VoteThemeBottomSheet( - val downvote: Boolean, + val actionType: Int, ) : Screen { @Composable @@ -54,6 +55,7 @@ class VoteThemeBottomSheet( var customPickerDialogOpened by remember { mutableStateOf(false) } val settingsRepository = remember { getSettingsRepository() } val defaultUpvoteColor = MaterialTheme.colorScheme.primary + val defaultReplyColor = MaterialTheme.colorScheme.secondary val defaultDownvoteColor = MaterialTheme.colorScheme.tertiary Column( @@ -76,10 +78,10 @@ class VoteThemeBottomSheet( top = Spacing.s, end = Spacing.s, ), - text = if (downvote) { - stringResource(MR.strings.settings_downvote_color) - } else { - stringResource(MR.strings.settings_upvote_color) + text = when (actionType) { + 2 -> stringResource(MR.strings.settings_reply_color) + 1 -> stringResource(MR.strings.settings_downvote_color) + else -> stringResource(MR.strings.settings_upvote_color) }, style = MaterialTheme.typography.titleLarge, color = MaterialTheme.colorScheme.onBackground, @@ -113,13 +115,21 @@ class VoteThemeBottomSheet( onClick = rememberCallback { if (!isChooseCustom) { notificationCenter.send( - NotificationCenterEvent.ChangeVoteColor( - color = if (downvote) { - value?.toDownVoteColor() ?: defaultDownvoteColor - } else { - value?.toUpVoteColor() ?: defaultUpvoteColor + NotificationCenterEvent.ChangeActionColor( + color = when (actionType) { + 2 -> { + value?.toReplyColor() ?: defaultReplyColor + } + + 1 -> { + value?.toDownVoteColor() ?: defaultDownvoteColor + } + + else -> { + value?.toUpVoteColor() ?: defaultUpvoteColor + } }, - downvote = downvote, + actionType = actionType, ) ) navigationCoordinator.hideBottomSheet() @@ -141,10 +151,10 @@ class VoteThemeBottomSheet( modifier = Modifier .size(36.dp) .background( - color = if (downvote) { - value.toDownVoteColor() - } else { - value.toUpVoteColor() + color = when (actionType) { + 2 -> value.toReplyColor() + 1 -> value.toDownVoteColor() + else -> value.toUpVoteColor() }, shape = CircleShape ) @@ -162,10 +172,18 @@ class VoteThemeBottomSheet( } if (customPickerDialogOpened) { - val current = if (downvote) { - settingsRepository.currentSettings.value.downvoteColor?.let { Color(it) } - } else { - settingsRepository.currentSettings.value.upvoteColor?.let { Color(it) } + val current = when (actionType) { + 2 -> { + settingsRepository.currentSettings.value.replyColor?.let { Color(it) } + } + + 1 -> { + settingsRepository.currentSettings.value.downvoteColor?.let { Color(it) } + } + + else -> { + settingsRepository.currentSettings.value.upvoteColor?.let { Color(it) } + } } ColorPickerDialog( initialValue = current ?: MaterialTheme.colorScheme.primary, @@ -174,9 +192,9 @@ class VoteThemeBottomSheet( }, onSubmit = { color -> notificationCenter.send( - NotificationCenterEvent.ChangeVoteColor( + NotificationCenterEvent.ChangeActionColor( color = color, - downvote = downvote, + actionType = actionType, ) ) navigationCoordinator.hideBottomSheet() diff --git a/core/notifications/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/notifications/NotificationCenterEvent.kt b/core/notifications/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/notifications/NotificationCenterEvent.kt index 93e3c70af..1185f3d70 100644 --- a/core/notifications/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/notifications/NotificationCenterEvent.kt +++ b/core/notifications/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/notifications/NotificationCenterEvent.kt @@ -42,7 +42,7 @@ sealed interface NotificationCenterEvent { data class CommentUpdated(val model: CommentModel) : NotificationCenterEvent data class PostDeleted(val model: PostModel) : NotificationCenterEvent data class ChangeColor(val color: Color?) : NotificationCenterEvent - data class ChangeVoteColor(val color: Color?, val downvote: Boolean) : NotificationCenterEvent + data class ChangeActionColor(val color: Color?, val actionType: Int) : NotificationCenterEvent data class ChangeZombieScrollAmount(val value: Float) : NotificationCenterEvent data class MultiCommunityCreated(val model: MultiCommunityModel) : NotificationCenterEvent data object CloseDialog : NotificationCenterEvent diff --git a/core/persistence/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/persistence/data/SettingsModel.kt b/core/persistence/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/persistence/data/SettingsModel.kt index 269551de9..782d362c0 100644 --- a/core/persistence/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/persistence/data/SettingsModel.kt +++ b/core/persistence/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/persistence/data/SettingsModel.kt @@ -37,6 +37,6 @@ data class SettingsModel( val zombieModeScrollAmount: Float = 55f, val markAsReadWhileScrolling: Boolean = false, val commentBarTheme: Int = 0, - val sharePostOriginal: Boolean = true, + val replyColor: Int? = null, val searchPostTitleOnly: Boolean = false, ) : JavaSerializable diff --git a/core/persistence/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/persistence/repository/DefaultSettingsRepository.kt b/core/persistence/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/persistence/repository/DefaultSettingsRepository.kt index b1e69ba15..8f47d594e 100644 --- a/core/persistence/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/persistence/repository/DefaultSettingsRepository.kt +++ b/core/persistence/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/persistence/repository/DefaultSettingsRepository.kt @@ -42,7 +42,7 @@ private object KeyStoreKeys { const val ZombieModeScrollAmount = "zombieModeScrollAmount" const val MarkAsReadWhileScrolling = "markAsReadWhileScrolling" const val CommentBarTheme = "commentBarTheme" - const val SharePostOriginal = "sharePostOriginal" + const val ReplyColor = "replyColor" const val SearchPostTitleOnly = "searchPostTitleOnly" const val ContentFontFamily = "contentFontFamily" } @@ -89,7 +89,7 @@ internal class DefaultSettingsRepository( zombieModeScrollAmount = settings.zombieModeScrollAmount.toDouble(), markAsReadWhileScrolling = if (settings.markAsReadWhileScrolling) 1 else 0, commentBarTheme = settings.commentBarTheme.toLong(), - sharePostOriginal = if (settings.sharePostOriginal) 1 else 0, + replyColor = settings.replyColor?.toLong(), searchPostTitleOnly = if (settings.searchPostTitleOnly) 1 else 0, contentFontFamily = settings.contentFontFamily.toLong(), ) @@ -131,7 +131,7 @@ internal class DefaultSettingsRepository( zombieModeScrollAmount = keyStore[KeyStoreKeys.ZombieModeScrollAmount, 55f], markAsReadWhileScrolling = keyStore[KeyStoreKeys.MarkAsReadWhileScrolling, false], commentBarTheme = keyStore[KeyStoreKeys.CommentBarTheme, 0], - sharePostOriginal = keyStore[KeyStoreKeys.SharePostOriginal, true], + replyColor = if (!keyStore.containsKey(KeyStoreKeys.ReplyColor)) null else keyStore[KeyStoreKeys.ReplyColor, 0], searchPostTitleOnly = keyStore[KeyStoreKeys.SearchPostTitleOnly, false], contentFontFamily = keyStore[KeyStoreKeys.ContentFontFamily, 0], ) @@ -210,10 +210,11 @@ internal class DefaultSettingsRepository( settings.markAsReadWhileScrolling, ) keyStore.save(KeyStoreKeys.CommentBarTheme, settings.commentBarTheme) - keyStore.save( - KeyStoreKeys.SharePostOriginal, - settings.sharePostOriginal, - ) + if (settings.replyColor != null) { + keyStore.save(KeyStoreKeys.ReplyColor, settings.replyColor) + } else { + keyStore.remove(KeyStoreKeys.ReplyColor) + } keyStore.save( KeyStoreKeys.SearchPostTitleOnly, settings.searchPostTitleOnly, @@ -251,7 +252,7 @@ internal class DefaultSettingsRepository( zombieModeScrollAmount = settings.zombieModeScrollAmount.toDouble(), markAsReadWhileScrolling = if (settings.markAsReadWhileScrolling) 1L else 0L, commentBarTheme = settings.commentBarTheme.toLong(), - sharePostOriginal = if (settings.sharePostOriginal) 1L else 0L, + replyColor = settings.replyColor?.toLong(), searchPostTitleOnly = if (settings.searchPostTitleOnly) 1L else 0L, contentFontFamily = settings.contentFontFamily.toLong(), ) @@ -294,7 +295,7 @@ private fun GetBy.toModel() = SettingsModel( zombieModeScrollAmount = zombieModeScrollAmount.toFloat(), markAsReadWhileScrolling = markAsReadWhileScrolling != 0L, commentBarTheme = commentBarTheme.toInt(), - sharePostOriginal = sharePostOriginal != 0L, + replyColor = replyColor?.toInt(), searchPostTitleOnly = searchPostTitleOnly != 0L, contentFontFamily = contentFontFamily.toInt(), ) diff --git a/core/persistence/src/commonMain/sqldelight/com/github/diegoberaldin/raccoonforlemmy/core/persistence/settings.sq b/core/persistence/src/commonMain/sqldelight/com/github/diegoberaldin/raccoonforlemmy/core/persistence/settings.sq index 53638ecd1..fa2481235 100644 --- a/core/persistence/src/commonMain/sqldelight/com/github/diegoberaldin/raccoonforlemmy/core/persistence/settings.sq +++ b/core/persistence/src/commonMain/sqldelight/com/github/diegoberaldin/raccoonforlemmy/core/persistence/settings.sq @@ -29,7 +29,7 @@ CREATE TABLE SettingsEntity ( zombieModeScrollAmount REAL NOT NULL DEFAULT 100, markAsReadWhileScrolling INTEGER NOT NULL DEFAULT 0, commentBarTheme INTEGER NOT NULL DEFAULT 0, - sharePostOriginal INTEGER NOT NULL DEFAULT 1, + replyColor INTEGER DEFAULT NULL, searchPostTitleOnly INTEGER NOT NULL DEFAULT 0, contentFontFamily INTEGER NOT NULL DEFAULT 0, account_id INTEGER, @@ -68,7 +68,7 @@ INSERT OR IGNORE INTO SettingsEntity ( zombieModeScrollAmount, markAsReadWhileScrolling, commentBarTheme, - sharePostOriginal, + replyColor, searchPostTitleOnly, contentFontFamily, account_id @@ -139,7 +139,7 @@ SET theme = ?, zombieModeScrollAmount = ?, markAsReadWhileScrolling = ?, commentBarTheme = ?, - sharePostOriginal = ?, + replyColor = ?, searchPostTitleOnly = ?, contentFontFamily = ? WHERE account_id = ?; @@ -176,7 +176,7 @@ SELECT zombieModeScrollAmount, markAsReadWhileScrolling, commentBarTheme, - sharePostOriginal, + replyColor, searchPostTitleOnly, contentFontFamily FROM SettingsEntity diff --git a/core/persistence/src/commonMain/sqldelight/migrations/18.sqm b/core/persistence/src/commonMain/sqldelight/migrations/18.sqm new file mode 100644 index 000000000..fa3cef9a8 --- /dev/null +++ b/core/persistence/src/commonMain/sqldelight/migrations/18.sqm @@ -0,0 +1,2 @@ +ALTER TABLE SettingsEntity +RENAME COLUMN sharePostOriginal TO replyColor; \ No newline at end of file diff --git a/feature/search/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/search/main/ExploreScreen.kt b/feature/search/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/search/main/ExploreScreen.kt index 5d550ce81..746669f0f 100644 --- a/feature/search/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/search/main/ExploreScreen.kt +++ b/feature/search/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/search/main/ExploreScreen.kt @@ -85,7 +85,6 @@ import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.SearchResult import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.SearchResultType import com.github.diegoberaldin.raccoonforlemmy.feature.search.di.getExploreViewModel import com.github.diegoberaldin.raccoonforlemmy.resources.MR -import com.github.diegoberaldin.raccoonforlemmy.unit.createcomment.CreateCommentScreen import com.github.diegoberaldin.raccoonforlemmy.unit.web.WebViewScreen import com.github.diegoberaldin.raccoonforlemmy.unit.zoomableimage.ZoomableImageScreen import dev.icerock.moko.resources.compose.stringResource @@ -421,13 +420,6 @@ class ExploreScreen : Screen { ) } }, - onReply = rememberCallback { - if (uiState.isLogged) { - detailOpener.openPostDetail( - result.model, - ) - } - }, onOpenImage = rememberCallbackArgs { url -> navigationCoordinator.pushScreen( ZoomableImageScreen(url), @@ -561,18 +553,6 @@ class ExploreScreen : Screen { ) } }, - onReply = rememberCallback { - if (uiState.isLogged) { - with(navigationCoordinator) { - setBottomSheetGesturesEnabled(false) - val screen = CreateCommentScreen( - originalPost = PostModel(id = result.model.postId), - originalComment = result.model, - ) - showBottomSheet(screen) - } - } - }, onOpenCommunity = rememberCallbackArgs { community, instance -> detailOpener.openCommunityDetail( community, diff --git a/feature/settings/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/settings/main/SettingsMviModel.kt b/feature/settings/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/settings/main/SettingsMviModel.kt index a52805017..b366d20d2 100644 --- a/feature/settings/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/settings/main/SettingsMviModel.kt +++ b/feature/settings/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/settings/main/SettingsMviModel.kt @@ -39,6 +39,7 @@ interface SettingsMviModel : data class ChangeCustomSeedColor(val value: Color?) : Intent data class ChangeUpvoteColor(val value: Color?) : Intent data class ChangeDownvoteColor(val value: Color?) : Intent + data class ChangeReplyColor(val value: Color?) : Intent data class ChangeCrashReportEnabled(val value: Boolean) : Intent data class ChangeVoteFormat(val value: VoteFormat) : Intent data class ChangeAutoLoadImages(val value: Boolean) : Intent @@ -59,6 +60,7 @@ interface SettingsMviModel : val customSeedColor: Color? = null, val upvoteColor: Color? = null, val downvoteColor: Color? = null, + val replyColor: Color? = null, val uiFontScale: FontScale = FontScale.Normal, val contentFontScale: FontScale = FontScale.Normal, val contentFontFamily: UiFontFamily = UiFontFamily.Poppins, diff --git a/feature/settings/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/settings/main/SettingsScreen.kt b/feature/settings/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/settings/main/SettingsScreen.kt index 324e97db3..2b13300ad 100644 --- a/feature/settings/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/settings/main/SettingsScreen.kt +++ b/feature/settings/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/settings/main/SettingsScreen.kt @@ -253,7 +253,7 @@ class SettingsScreen : Screen { value = uiState.upvoteColor ?: MaterialTheme.colorScheme.primary, onTap = rememberCallback { val screen = VoteThemeBottomSheet( - downvote = false, + actionType = 0, ) navigationCoordinator.showBottomSheet(screen) }, @@ -263,7 +263,17 @@ class SettingsScreen : Screen { value = uiState.downvoteColor ?: MaterialTheme.colorScheme.tertiary, onTap = rememberCallback { val screen = VoteThemeBottomSheet( - downvote = true, + actionType = 1, + ) + navigationCoordinator.showBottomSheet(screen) + }, + ) + SettingsColorRow( + title = stringResource(MR.strings.settings_reply_color), + value = uiState.replyColor ?: MaterialTheme.colorScheme.secondary, + onTap = rememberCallback { + val screen = VoteThemeBottomSheet( + actionType = 2, ) navigationCoordinator.showBottomSheet(screen) }, diff --git a/feature/settings/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/settings/main/SettingsViewModel.kt b/feature/settings/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/settings/main/SettingsViewModel.kt index 27b6a2d95..f68e9f83b 100644 --- a/feature/settings/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/settings/main/SettingsViewModel.kt +++ b/feature/settings/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/settings/main/SettingsViewModel.kt @@ -90,6 +90,9 @@ class SettingsViewModel( themeRepository.downvoteColor.onEach { value -> mvi.updateState { it.copy(downvoteColor = value) } }.launchIn(this) + themeRepository.replyColor.onEach { value -> + mvi.updateState { it.copy(replyColor = value) } + }.launchIn(this) themeRepository.commentBarTheme.onEach { value -> mvi.updateState { it.copy(commentBarTheme = value) } }.launchIn(this) @@ -167,12 +170,12 @@ class SettingsViewModel( .onEach { evt -> changeCommentBarTheme(evt.value) }.launchIn(this) - notificationCenter.subscribe(NotificationCenterEvent.ChangeVoteColor::class) + notificationCenter.subscribe(NotificationCenterEvent.ChangeActionColor::class) .onEach { evt -> - if (evt.downvote) { - changeDownvoteColor(evt.color) - } else { - changeUpvoteColor(evt.color) + when (evt.actionType) { + 2 -> changeReplyColor(evt.color) + 1 -> changeDownvoteColor(evt.color) + else -> changeUpvoteColor(evt.color) } }.launchIn(this) @@ -315,6 +318,10 @@ class SettingsViewModel( changeDownvoteColor(intent.value) } + is SettingsMviModel.Intent.ChangeReplyColor -> { + changeReplyColor(intent.value) + } + is SettingsMviModel.Intent.ChangeHideNavigationBarWhileScrolling -> { changeHideNavigationBarWhileScrolling(intent.value) } @@ -505,6 +512,16 @@ class SettingsViewModel( } } + private fun changeReplyColor(value: Color?) { + themeRepository.changeReplyColor(value) + mvi.scope?.launch(Dispatchers.IO) { + val settings = settingsRepository.currentSettings.value.copy( + replyColor = value?.toArgb() + ) + saveSettings(settings) + } + } + private fun changeOpenUrlsInExternalBrowser(value: Boolean) { mvi.updateState { it.copy(openUrlsInExternalBrowser = value) } mvi.scope?.launch(Dispatchers.IO) { diff --git a/resources/src/commonMain/resources/MR/ar/strings.xml b/resources/src/commonMain/resources/MR/ar/strings.xml index 6343cd847..4f2777510 100644 --- a/resources/src/commonMain/resources/MR/ar/strings.xml +++ b/resources/src/commonMain/resources/MR/ar/strings.xml @@ -283,4 +283,5 @@ مشرف مدير الدردشة على Matrix + لون عمل الرد \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/base/strings.xml b/resources/src/commonMain/resources/MR/base/strings.xml index 959fb07cd..6512530e1 100755 --- a/resources/src/commonMain/resources/MR/base/strings.xml +++ b/resources/src/commonMain/resources/MR/base/strings.xml @@ -314,4 +314,5 @@ Moderator of administrator Chat on Matrix + Reply action color \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/bg/strings.xml b/resources/src/commonMain/resources/MR/bg/strings.xml index e0a96a676..9ef61940d 100644 --- a/resources/src/commonMain/resources/MR/bg/strings.xml +++ b/resources/src/commonMain/resources/MR/bg/strings.xml @@ -293,4 +293,5 @@ Модератор на администратор Чат в Matrix + цвят на отговора \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/cs/strings.xml b/resources/src/commonMain/resources/MR/cs/strings.xml index e87e42168..9d0f9ae4d 100644 --- a/resources/src/commonMain/resources/MR/cs/strings.xml +++ b/resources/src/commonMain/resources/MR/cs/strings.xml @@ -285,4 +285,5 @@ Moderátor správce Chat na Matrixu + Barva akce odpovědi \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/da/strings.xml b/resources/src/commonMain/resources/MR/da/strings.xml index 21bfb9979..f4b3b8131 100644 --- a/resources/src/commonMain/resources/MR/da/strings.xml +++ b/resources/src/commonMain/resources/MR/da/strings.xml @@ -285,4 +285,5 @@ Moderator af administrator Chat på Matrix + Farve på svarhandling \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/de/strings.xml b/resources/src/commonMain/resources/MR/de/strings.xml index b9984bd50..5e7c64da9 100755 --- a/resources/src/commonMain/resources/MR/de/strings.xml +++ b/resources/src/commonMain/resources/MR/de/strings.xml @@ -293,4 +293,5 @@ Moderator von Administrator Chatten Sie auf Matrix + Farbe der Antwortaktion \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/el/strings.xml b/resources/src/commonMain/resources/MR/el/strings.xml index c7bd726d1..845dcc100 100644 --- a/resources/src/commonMain/resources/MR/el/strings.xml +++ b/resources/src/commonMain/resources/MR/el/strings.xml @@ -294,4 +294,5 @@ Συντονιστής των διαχειριστής Συνομιλία στο Matrix + Χρώμα της ενέργειας απάντησης \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/eo/strings.xml b/resources/src/commonMain/resources/MR/eo/strings.xml index d29436957..4494ac450 100644 --- a/resources/src/commonMain/resources/MR/eo/strings.xml +++ b/resources/src/commonMain/resources/MR/eo/strings.xml @@ -284,4 +284,5 @@ Moderatoro de administranto Babilu sur Matrix + Koloro de responda ago \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/es/strings.xml b/resources/src/commonMain/resources/MR/es/strings.xml index de416a3a9..443c0b66b 100755 --- a/resources/src/commonMain/resources/MR/es/strings.xml +++ b/resources/src/commonMain/resources/MR/es/strings.xml @@ -289,4 +289,5 @@ Moderador de administrador Chat en Matrix + Color de la acción de respuesta \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/et/strings.xml b/resources/src/commonMain/resources/MR/et/strings.xml index 1feb37aff..86a22962d 100644 --- a/resources/src/commonMain/resources/MR/et/strings.xml +++ b/resources/src/commonMain/resources/MR/et/strings.xml @@ -285,4 +285,5 @@ Moderaator administraator Vestelge Matrixis + Vastuse toimingu värv \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/fi/strings.xml b/resources/src/commonMain/resources/MR/fi/strings.xml index 45b2ef308..00742f6f6 100644 --- a/resources/src/commonMain/resources/MR/fi/strings.xml +++ b/resources/src/commonMain/resources/MR/fi/strings.xml @@ -285,4 +285,5 @@ Moderaattori järjestelmänvalvoja Chat Matrixissa + Vastaustoiminnon väri \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/fr/strings.xml b/resources/src/commonMain/resources/MR/fr/strings.xml index b15a35e03..f1bd9803b 100755 --- a/resources/src/commonMain/resources/MR/fr/strings.xml +++ b/resources/src/commonMain/resources/MR/fr/strings.xml @@ -290,4 +290,5 @@ Modérateur de administrateur Discutez sur Matrix + Couleur de l\'action de réponse \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/ga/strings.xml b/resources/src/commonMain/resources/MR/ga/strings.xml index 1caa1d44c..ac9c4f7c3 100644 --- a/resources/src/commonMain/resources/MR/ga/strings.xml +++ b/resources/src/commonMain/resources/MR/ga/strings.xml @@ -294,4 +294,5 @@ Modhnóir na riarthóir Comhrá ar Matrix + Dath an ghnímh freagartha \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/hr/strings.xml b/resources/src/commonMain/resources/MR/hr/strings.xml index 8183589f0..7c0866fa5 100644 --- a/resources/src/commonMain/resources/MR/hr/strings.xml +++ b/resources/src/commonMain/resources/MR/hr/strings.xml @@ -290,4 +290,5 @@ Moderator od administrator Chat na Matrixu + Boja radnje odgovora \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/hu/strings.xml b/resources/src/commonMain/resources/MR/hu/strings.xml index bf84aa93a..f626b52ed 100644 --- a/resources/src/commonMain/resources/MR/hu/strings.xml +++ b/resources/src/commonMain/resources/MR/hu/strings.xml @@ -289,4 +289,5 @@ Moderátora adminisztrátor Chat a Matrixon + Válaszművelet színe \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/it/strings.xml b/resources/src/commonMain/resources/MR/it/strings.xml index 2116dbc80..6074fbd0b 100755 --- a/resources/src/commonMain/resources/MR/it/strings.xml +++ b/resources/src/commonMain/resources/MR/it/strings.xml @@ -289,4 +289,5 @@ Moderatore di amministratore Chat su Matrix + Colore azione di risposta \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/lt/strings.xml b/resources/src/commonMain/resources/MR/lt/strings.xml index 0ba90f895..c5aa8d8a6 100644 --- a/resources/src/commonMain/resources/MR/lt/strings.xml +++ b/resources/src/commonMain/resources/MR/lt/strings.xml @@ -287,4 +287,5 @@ Moderatorius administratorius Pokalbis Matrix + Atsakymo veiksmo spalva \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/lv/strings.xml b/resources/src/commonMain/resources/MR/lv/strings.xml index 43493d9aa..e94f1f9d1 100644 --- a/resources/src/commonMain/resources/MR/lv/strings.xml +++ b/resources/src/commonMain/resources/MR/lv/strings.xml @@ -289,4 +289,5 @@ Moderators no administrators Tērzējiet Matrix + Atbildes darbības krāsa \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/mt/strings.xml b/resources/src/commonMain/resources/MR/mt/strings.xml index 73f3aa9b4..76ff3af87 100644 --- a/resources/src/commonMain/resources/MR/mt/strings.xml +++ b/resources/src/commonMain/resources/MR/mt/strings.xml @@ -290,4 +290,5 @@ Moderatur ta\' amministratur Chat fuq Matrix + Kulur ta\' azzjoni ta\' risposta \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/nl/strings.xml b/resources/src/commonMain/resources/MR/nl/strings.xml index 9cd4156c4..2f5ef7149 100644 --- a/resources/src/commonMain/resources/MR/nl/strings.xml +++ b/resources/src/commonMain/resources/MR/nl/strings.xml @@ -288,4 +288,5 @@ Moderator van beheerder Chatten op Matrix + Kleur van antwoordactie \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/no/strings.xml b/resources/src/commonMain/resources/MR/no/strings.xml index 5fdce7c69..94967d6a7 100644 --- a/resources/src/commonMain/resources/MR/no/strings.xml +++ b/resources/src/commonMain/resources/MR/no/strings.xml @@ -287,4 +287,5 @@ Moderator for administrator Chat på Matrix + Fargen på svarhandlingen \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/pl/strings.xml b/resources/src/commonMain/resources/MR/pl/strings.xml index 9bb1a7673..ef9b5c689 100644 --- a/resources/src/commonMain/resources/MR/pl/strings.xml +++ b/resources/src/commonMain/resources/MR/pl/strings.xml @@ -288,4 +288,5 @@ Moderator administrator Czat na Matrixie + Kolor akcji odpowiedzi \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/pt/strings.xml b/resources/src/commonMain/resources/MR/pt/strings.xml index e72e48081..356b7c2eb 100755 --- a/resources/src/commonMain/resources/MR/pt/strings.xml +++ b/resources/src/commonMain/resources/MR/pt/strings.xml @@ -287,4 +287,5 @@ Moderador de administrador Conversar no Matrix + Cor da ação de resposta \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/ro/strings.xml b/resources/src/commonMain/resources/MR/ro/strings.xml index 202bf5434..2c367e8d7 100755 --- a/resources/src/commonMain/resources/MR/ro/strings.xml +++ b/resources/src/commonMain/resources/MR/ro/strings.xml @@ -286,4 +286,5 @@ Moderator al administrator Chat pe Matrix + Culoare acțiunii de răspuns \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/ru/strings.xml b/resources/src/commonMain/resources/MR/ru/strings.xml index a58babdd8..a5a3fe2ed 100644 --- a/resources/src/commonMain/resources/MR/ru/strings.xml +++ b/resources/src/commonMain/resources/MR/ru/strings.xml @@ -288,4 +288,5 @@ Модератор администратор чат в Matrix + Цвет действия ответа \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/se/strings.xml b/resources/src/commonMain/resources/MR/se/strings.xml index 03ff2eeed..1c23e538d 100644 --- a/resources/src/commonMain/resources/MR/se/strings.xml +++ b/resources/src/commonMain/resources/MR/se/strings.xml @@ -286,4 +286,5 @@ Moderator för administratör Chatta på Matrix + Färg på svarsåtgärd \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/sk/strings.xml b/resources/src/commonMain/resources/MR/sk/strings.xml index 08d76d1f7..3cdefa5b6 100644 --- a/resources/src/commonMain/resources/MR/sk/strings.xml +++ b/resources/src/commonMain/resources/MR/sk/strings.xml @@ -287,4 +287,5 @@ Moderátorka správca Chat na Matrixe + Farba akcie odpovede \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/sl/strings.xml b/resources/src/commonMain/resources/MR/sl/strings.xml index c8e751ffc..ebf119513 100644 --- a/resources/src/commonMain/resources/MR/sl/strings.xml +++ b/resources/src/commonMain/resources/MR/sl/strings.xml @@ -285,4 +285,5 @@ Moderator od skrbnik Klepet na Matrixu + Barva dejanja odgovora \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/sq/strings.xml b/resources/src/commonMain/resources/MR/sq/strings.xml index 389d164d6..9595c1172 100644 --- a/resources/src/commonMain/resources/MR/sq/strings.xml +++ b/resources/src/commonMain/resources/MR/sq/strings.xml @@ -291,4 +291,5 @@ Moderator i administratori Bisedoni në Matrix + Ngjyra e veprimit të përgjigjes \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/tr/strings.xml b/resources/src/commonMain/resources/MR/tr/strings.xml index a43d28a7b..cbb1497ce 100644 --- a/resources/src/commonMain/resources/MR/tr/strings.xml +++ b/resources/src/commonMain/resources/MR/tr/strings.xml @@ -288,4 +288,5 @@ Moderatörü yönetici Matrix\'te sohbet + yanıt eyleminin rengi \ No newline at end of file diff --git a/resources/src/commonMain/resources/MR/uk/strings.xml b/resources/src/commonMain/resources/MR/uk/strings.xml index 9cb5bc2d0..caa72374a 100644 --- a/resources/src/commonMain/resources/MR/uk/strings.xml +++ b/resources/src/commonMain/resources/MR/uk/strings.xml @@ -287,4 +287,5 @@ Модератор адміністратор чат на Matrix + колір дії відповіді \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/App.kt b/shared/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/App.kt index e79db54ef..8617f4b29 100644 --- a/shared/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/App.kt +++ b/shared/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/App.kt @@ -120,6 +120,7 @@ fun App(onLoadingFinished: () -> Unit = {}) { with(themeRepository) { changeUpvoteColor(currentSettings.upvoteColor?.let { Color(it) }) changeDownvoteColor(currentSettings.downvoteColor?.let { Color(it) }) + changeReplyColor(currentSettings.replyColor?.let { Color(it) }) } } @@ -153,6 +154,7 @@ fun App(onLoadingFinished: () -> Unit = {}) { with(themeRepository) { changeUpvoteColor(settings.upvoteColor?.let { Color(it) }) changeDownvoteColor(settings.downvoteColor?.let { Color(it) }) + changeReplyColor(settings.replyColor?.let { Color(it) }) } } } diff --git a/unit/communitydetail/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/communitydetail/CommunityDetailScreen.kt b/unit/communitydetail/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/communitydetail/CommunityDetailScreen.kt index 6965d7688..9f5533b3c 100644 --- a/unit/communitydetail/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/communitydetail/CommunityDetailScreen.kt +++ b/unit/communitydetail/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/communitydetail/CommunityDetailScreen.kt @@ -28,6 +28,7 @@ import androidx.compose.material.icons.filled.ClearAll import androidx.compose.material.icons.filled.Create import androidx.compose.material.icons.filled.ExpandLess import androidx.compose.material.icons.filled.MoreVert +import androidx.compose.material.icons.filled.Reply import androidx.compose.material.icons.filled.Sync import androidx.compose.material.icons.filled.SyncDisabled import androidx.compose.material.icons.outlined.AddCircleOutline @@ -155,7 +156,9 @@ class CommunityDetailScreen( val themeRepository = remember { getThemeRepository() } val upvoteColor by themeRepository.upvoteColor.collectAsState() val downvoteColor by themeRepository.downvoteColor.collectAsState() + val replyColor by themeRepository.replyColor.collectAsState() val defaultUpvoteColor = MaterialTheme.colorScheme.primary + val defaultReplyColor = MaterialTheme.colorScheme.secondary val defaultDownVoteColor = MaterialTheme.colorScheme.tertiary var rawContent by remember { mutableStateOf(null) } val settingsRepository = remember { getSettingsRepository() } @@ -540,6 +543,13 @@ class CommunityDetailScreen( DismissDirection.EndToStart, ) }, + enableSecondAction = rememberCallbackArgs { value -> + if (!uiState.isLogged) { + false + } else { + value == DismissValue.DismissedToStart + } + }, backgroundColor = rememberCallbackArgs { direction -> when (direction) { DismissValue.DismissedToStart -> upvoteColor @@ -551,6 +561,14 @@ class CommunityDetailScreen( else -> Color.Transparent } }, + secondBackgroundColor = rememberCallbackArgs { direction -> + when (direction) { + DismissValue.DismissedToStart -> replyColor + ?: defaultReplyColor + + else -> Color.Transparent + } + }, swipeContent = { direction -> val icon = when (direction) { DismissDirection.StartToEnd -> Icons.Default.ArrowCircleDown @@ -562,6 +580,17 @@ class CommunityDetailScreen( tint = Color.White, ) }, + secondSwipeContent = { direction -> + val icon = when (direction) { + DismissDirection.StartToEnd -> Icons.Default.ArrowCircleDown + DismissDirection.EndToStart -> Icons.Default.Reply + } + Icon( + imageVector = icon, + contentDescription = null, + tint = Color.White, + ) + }, onGestureBegin = rememberCallback(model) { model.reduce(CommunityDetailMviModel.Intent.HapticIndication) }, @@ -570,6 +599,15 @@ class CommunityDetailScreen( CommunityDetailMviModel.Intent.UpVotePost(post.id), ) }, + onSecondDismissToStart = rememberCallback(model) { + with(navigationCoordinator) { + setBottomSheetGesturesEnabled(false) + val screen = CreateCommentScreen( + originalPost = post, + ) + showBottomSheet(screen) + } + }, onDismissToEnd = rememberCallback(model) { model.reduce( CommunityDetailMviModel.Intent.DownVotePost(post.id), diff --git a/unit/multicommunity/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/multicommunity/detail/MultiCommunityScreen.kt b/unit/multicommunity/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/multicommunity/detail/MultiCommunityScreen.kt index f476ac00e..ef7a4a953 100644 --- a/unit/multicommunity/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/multicommunity/detail/MultiCommunityScreen.kt +++ b/unit/multicommunity/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/multicommunity/detail/MultiCommunityScreen.kt @@ -23,6 +23,7 @@ import androidx.compose.material.icons.filled.ArrowCircleDown import androidx.compose.material.icons.filled.ArrowCircleUp import androidx.compose.material.icons.filled.ClearAll import androidx.compose.material.icons.filled.ExpandLess +import androidx.compose.material.icons.filled.Reply import androidx.compose.material.pullrefresh.PullRefreshIndicator import androidx.compose.material.pullrefresh.pullRefresh import androidx.compose.material.pullrefresh.rememberPullRefreshState @@ -77,6 +78,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.rememberCallb import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.getAdditionalLabel import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.toIcon import com.github.diegoberaldin.raccoonforlemmy.resources.MR +import com.github.diegoberaldin.raccoonforlemmy.unit.createcomment.CreateCommentScreen import com.github.diegoberaldin.raccoonforlemmy.unit.createreport.CreateReportScreen import com.github.diegoberaldin.raccoonforlemmy.unit.multicommunity.di.getMultiCommunityViewModel import com.github.diegoberaldin.raccoonforlemmy.unit.web.WebViewScreen @@ -100,7 +102,9 @@ class MultiCommunityScreen( val themeRepository = remember { getThemeRepository() } val upvoteColor by themeRepository.upvoteColor.collectAsState() val downvoteColor by themeRepository.downvoteColor.collectAsState() + val replyColor by themeRepository.replyColor.collectAsState() val defaultUpvoteColor = MaterialTheme.colorScheme.primary + val defaultReplyColor = MaterialTheme.colorScheme.secondary val defaultDownVoteColor = MaterialTheme.colorScheme.tertiary val lazyListState = rememberLazyListState() val scope = rememberCoroutineScope() @@ -251,6 +255,13 @@ class MultiCommunityScreen( SwipeableCard( modifier = Modifier.fillMaxWidth(), enabled = uiState.swipeActionsEnabled, + enableSecondAction = rememberCallbackArgs { value -> + if (!uiState.isLogged) { + false + } else { + value == DismissValue.DismissedToStart + } + }, backgroundColor = { when (it) { DismissValue.DismissedToStart -> upvoteColor @@ -262,12 +273,27 @@ class MultiCommunityScreen( DismissValue.Default -> Color.Transparent } }, + secondBackgroundColor = rememberCallbackArgs { direction -> + when (direction) { + DismissValue.DismissedToStart -> replyColor ?: defaultReplyColor + else -> Color.Transparent + } + }, onGestureBegin = rememberCallback(model) { model.reduce(MultiCommunityMviModel.Intent.HapticIndication) }, onDismissToStart = { model.reduce(MultiCommunityMviModel.Intent.UpVotePost(post.id)) }, + onSecondDismissToStart = rememberCallback(model) { + with(navigationCoordinator) { + setBottomSheetGesturesEnabled(false) + val screen = CreateCommentScreen( + originalPost = post, + ) + showBottomSheet(screen) + } + }, onDismissToEnd = { model.reduce(MultiCommunityMviModel.Intent.DownVotePost(post.id)) }, @@ -282,6 +308,17 @@ class MultiCommunityScreen( tint = Color.White, ) }, + secondSwipeContent = { direction -> + val icon = when (direction) { + DismissDirection.StartToEnd -> Icons.Default.ArrowCircleDown + DismissDirection.EndToStart -> Icons.Default.Reply + } + Icon( + imageVector = icon, + contentDescription = null, + tint = Color.White, + ) + }, content = { PostCard( post = post, diff --git a/unit/myaccount/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/myaccount/ProfileLoggedScreen.kt b/unit/myaccount/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/myaccount/ProfileLoggedScreen.kt index b768c905d..3a9621ea3 100644 --- a/unit/myaccount/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/myaccount/ProfileLoggedScreen.kt +++ b/unit/myaccount/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/myaccount/ProfileLoggedScreen.kt @@ -230,9 +230,6 @@ object ProfileLoggedScreen : Tab { ) ) }, - onReply = rememberCallback { - detailOpener.openPostDetail(post) - }, options = buildList { add( Option( @@ -375,12 +372,6 @@ object ProfileLoggedScreen : Tab { ) ) }, - onReply = rememberCallback { - detailOpener.openPostDetail( - post = PostModel(id = comment.postId), - highlightCommentId = comment.id, - ) - }, options = buildList { add( Option( diff --git a/unit/postlist/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/postlist/PostListScreen.kt b/unit/postlist/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/postlist/PostListScreen.kt index 2b19ce48d..56e9a967d 100644 --- a/unit/postlist/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/postlist/PostListScreen.kt +++ b/unit/postlist/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/postlist/PostListScreen.kt @@ -22,6 +22,7 @@ import androidx.compose.material.icons.filled.ArrowCircleDown import androidx.compose.material.icons.filled.ArrowCircleUp import androidx.compose.material.icons.filled.ClearAll import androidx.compose.material.icons.filled.ExpandLess +import androidx.compose.material.icons.filled.Reply import androidx.compose.material.icons.filled.Sync import androidx.compose.material.icons.filled.SyncDisabled import androidx.compose.material.pullrefresh.PullRefreshIndicator @@ -107,7 +108,9 @@ class PostListScreen : Screen { val themeRepository = remember { getThemeRepository() } val upvoteColor by themeRepository.upvoteColor.collectAsState() val downvoteColor by themeRepository.downvoteColor.collectAsState() + val replyColor by themeRepository.replyColor.collectAsState() val defaultUpvoteColor = MaterialTheme.colorScheme.primary + val defaultReplyColor = MaterialTheme.colorScheme.secondary val defaultDownVoteColor = MaterialTheme.colorScheme.tertiary val lazyListState = rememberLazyListState() val drawerCoordinator = remember { getDrawerCoordinator() } @@ -308,6 +311,13 @@ class PostListScreen : Screen { DismissDirection.EndToStart, ) }, + enableSecondAction = rememberCallbackArgs { value -> + if (!uiState.isLogged) { + false + } else { + value == DismissValue.DismissedToStart + } + }, backgroundColor = rememberCallbackArgs { direction -> when (direction) { DismissValue.DismissedToStart -> upvoteColor @@ -319,12 +329,29 @@ class PostListScreen : Screen { DismissValue.Default -> Color.Transparent } }, + secondBackgroundColor = rememberCallbackArgs { direction -> + when (direction) { + DismissValue.DismissedToStart -> replyColor + ?: defaultReplyColor + + else -> Color.Transparent + } + }, onGestureBegin = rememberCallback(model) { model.reduce(PostListMviModel.Intent.HapticIndication) }, onDismissToStart = rememberCallback(model) { model.reduce(PostListMviModel.Intent.UpVotePost(post.id)) }, + onSecondDismissToStart = rememberCallback(model) { + with(navigationCoordinator) { + setBottomSheetGesturesEnabled(false) + val screen = CreateCommentScreen( + originalPost = post, + ) + showBottomSheet(screen) + } + }, onDismissToEnd = rememberCallback(model) { model.reduce(PostListMviModel.Intent.DownVotePost(post.id)) }, @@ -339,6 +366,17 @@ class PostListScreen : Screen { tint = Color.White, ) }, + secondSwipeContent = { direction -> + val icon = when (direction) { + DismissDirection.StartToEnd -> Icons.Default.ArrowCircleDown + DismissDirection.EndToStart -> Icons.Default.Reply + } + Icon( + imageVector = icon, + contentDescription = null, + tint = Color.White, + ) + }, content = { PostCard( post = post, diff --git a/unit/userdetail/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/userdetail/UserDetailScreen.kt b/unit/userdetail/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/userdetail/UserDetailScreen.kt index df71f1f3c..a977113d6 100644 --- a/unit/userdetail/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/userdetail/UserDetailScreen.kt +++ b/unit/userdetail/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/unit/userdetail/UserDetailScreen.kt @@ -25,6 +25,7 @@ import androidx.compose.material.icons.filled.ArrowCircleUp import androidx.compose.material.icons.filled.Chat import androidx.compose.material.icons.filled.ExpandLess import androidx.compose.material.icons.filled.MoreVert +import androidx.compose.material.icons.filled.Reply import androidx.compose.material.pullrefresh.PullRefreshIndicator import androidx.compose.material.pullrefresh.pullRefresh import androidx.compose.material.pullrefresh.rememberPullRefreshState @@ -143,7 +144,9 @@ class UserDetailScreen( val themeRepository = remember { getThemeRepository() } val upvoteColor by themeRepository.upvoteColor.collectAsState() val downvoteColor by themeRepository.downvoteColor.collectAsState() + val replyColor by themeRepository.replyColor.collectAsState() val defaultUpvoteColor = MaterialTheme.colorScheme.primary + val defaultReplyColor = MaterialTheme.colorScheme.secondary val defaultDownVoteColor = MaterialTheme.colorScheme.tertiary val navigationCoordinator = remember { getNavigationCoordinator() } var rawContent by remember { mutableStateOf(null) } @@ -430,6 +433,13 @@ class UserDetailScreen( DismissDirection.EndToStart, ) }, + enableSecondAction = rememberCallbackArgs { value -> + if (!uiState.isLogged) { + false + } else { + value == DismissValue.DismissedToStart + } + }, backgroundColor = rememberCallbackArgs { direction -> when (direction) { DismissValue.DismissedToStart -> upvoteColor @@ -441,6 +451,14 @@ class UserDetailScreen( else -> Color.Transparent } }, + secondBackgroundColor = rememberCallbackArgs { direction -> + when (direction) { + DismissValue.DismissedToStart -> replyColor + ?: defaultReplyColor + + else -> Color.Transparent + } + }, swipeContent = { direction -> val icon = when (direction) { DismissDirection.StartToEnd -> Icons.Default.ArrowCircleDown @@ -453,6 +471,17 @@ class UserDetailScreen( tint = Color.White, ) }, + secondSwipeContent = { direction -> + val icon = when (direction) { + DismissDirection.StartToEnd -> Icons.Default.ArrowCircleDown + DismissDirection.EndToStart -> Icons.Default.Reply + } + Icon( + imageVector = icon, + contentDescription = null, + tint = Color.White, + ) + }, onGestureBegin = rememberCallback(model) { model.reduce(UserDetailMviModel.Intent.HapticIndication) }, @@ -461,6 +490,15 @@ class UserDetailScreen( UserDetailMviModel.Intent.UpVotePost(post.id), ) }, + onSecondDismissToStart = rememberCallback(model) { + with(navigationCoordinator) { + setBottomSheetGesturesEnabled(false) + val screen = CreateCommentScreen( + originalPost = post, + ) + showBottomSheet(screen) + } + }, onDismissToEnd = rememberCallback(model) { model.reduce( UserDetailMviModel.Intent.DownVotePost(post.id), @@ -666,6 +704,13 @@ class UserDetailScreen( DismissDirection.EndToStart, ) }, + enableSecondAction = rememberCallbackArgs { value -> + if (!uiState.isLogged) { + false + } else { + value == DismissValue.DismissedToStart + } + }, backgroundColor = rememberCallbackArgs { direction -> when (direction) { DismissValue.DismissedToStart -> upvoteColor @@ -677,6 +722,14 @@ class UserDetailScreen( else -> Color.Transparent } }, + secondBackgroundColor = rememberCallbackArgs { direction -> + when (direction) { + DismissValue.DismissedToStart -> replyColor + ?: defaultReplyColor + + else -> Color.Transparent + } + }, swipeContent = { direction -> val icon = when (direction) { DismissDirection.StartToEnd -> Icons.Default.ArrowCircleDown @@ -688,6 +741,17 @@ class UserDetailScreen( tint = Color.White, ) }, + secondSwipeContent = { direction -> + val icon = when (direction) { + DismissDirection.StartToEnd -> Icons.Default.ArrowCircleDown + DismissDirection.EndToStart -> Icons.Default.Reply + } + Icon( + imageVector = icon, + contentDescription = null, + tint = Color.White, + ) + }, onGestureBegin = rememberCallback(model) { model.reduce(UserDetailMviModel.Intent.HapticIndication) }, @@ -696,6 +760,16 @@ class UserDetailScreen( UserDetailMviModel.Intent.UpVoteComment(comment.id), ) }, + onSecondDismissToStart = rememberCallback(model) { + with(navigationCoordinator) { + setBottomSheetGesturesEnabled(false) + val screen = CreateCommentScreen( + originalPost = PostModel(id = comment.postId), + originalComment = comment, + ) + showBottomSheet(screen) + } + }, onDismissToEnd = rememberCallback(model) { model.reduce( UserDetailMviModel.Intent.DownVoteComment(comment.id),