mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-03 16:47:40 +01:00
feat: allow swipe actions on both sides (#783)
This commit is contained in:
parent
6ff4005a6d
commit
c2106efdd5
@ -50,7 +50,6 @@ import com.github.diegoberaldin.raccoonforlemmy.core.persistence.data.ActionOnSw
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.data.ActionOnSwipeTarget
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.di.getSettingsRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.onClick
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.rememberCallback
|
||||
import com.github.diegoberaldin.raccoonforlemmy.unit.configureswipeactions.ui.components.ConfigureActionItem
|
||||
import com.github.diegoberaldin.raccoonforlemmy.unit.configureswipeactions.ui.components.ConfigureAddAction
|
||||
import com.github.diegoberaldin.raccoonforlemmy.unit.configureswipeactions.ui.modals.SelectActionOnSwipeBottomSheet
|
||||
@ -183,7 +182,9 @@ class ConfigureSwipeActionsScreen : Screen {
|
||||
item {
|
||||
ConfigureAddAction {
|
||||
val sheet = SelectActionOnSwipeBottomSheet(
|
||||
values = uiState.availableOptionsPosts,
|
||||
values = uiState.availableOptionsPosts.filterNot { a ->
|
||||
uiState.actionsOnSwipeToStartPosts.contains(a)
|
||||
},
|
||||
direction = ActionOnSwipeDirection.ToStart,
|
||||
target = ActionOnSwipeTarget.Posts,
|
||||
)
|
||||
@ -239,7 +240,9 @@ class ConfigureSwipeActionsScreen : Screen {
|
||||
item {
|
||||
ConfigureAddAction {
|
||||
val sheet = SelectActionOnSwipeBottomSheet(
|
||||
values = uiState.availableOptionsPosts,
|
||||
values = uiState.availableOptionsPosts.filterNot { a ->
|
||||
uiState.actionsOnSwipeToEndPosts.contains(a)
|
||||
},
|
||||
direction = ActionOnSwipeDirection.ToEnd,
|
||||
target = ActionOnSwipeTarget.Posts,
|
||||
)
|
||||
@ -322,7 +325,9 @@ class ConfigureSwipeActionsScreen : Screen {
|
||||
item {
|
||||
ConfigureAddAction {
|
||||
val sheet = SelectActionOnSwipeBottomSheet(
|
||||
values = uiState.availableOptionsComments,
|
||||
values = uiState.availableOptionsComments.filterNot { a ->
|
||||
uiState.actionsOnSwipeToStartComments.contains(a)
|
||||
},
|
||||
direction = ActionOnSwipeDirection.ToStart,
|
||||
target = ActionOnSwipeTarget.Comments,
|
||||
)
|
||||
@ -378,7 +383,9 @@ class ConfigureSwipeActionsScreen : Screen {
|
||||
item {
|
||||
ConfigureAddAction {
|
||||
val sheet = SelectActionOnSwipeBottomSheet(
|
||||
values = uiState.availableOptionsComments,
|
||||
values = uiState.availableOptionsComments.filterNot { a ->
|
||||
uiState.actionsOnSwipeToEndComments.contains(a)
|
||||
},
|
||||
direction = ActionOnSwipeDirection.ToEnd,
|
||||
target = ActionOnSwipeTarget.Comments,
|
||||
)
|
||||
@ -461,7 +468,9 @@ class ConfigureSwipeActionsScreen : Screen {
|
||||
item {
|
||||
ConfigureAddAction {
|
||||
val sheet = SelectActionOnSwipeBottomSheet(
|
||||
values = uiState.availableOptionsInbox,
|
||||
values = uiState.availableOptionsInbox.filterNot { a ->
|
||||
uiState.actionsOnSwipeToStartInbox.contains(a)
|
||||
},
|
||||
direction = ActionOnSwipeDirection.ToStart,
|
||||
target = ActionOnSwipeTarget.Inbox,
|
||||
)
|
||||
@ -517,7 +526,9 @@ class ConfigureSwipeActionsScreen : Screen {
|
||||
item {
|
||||
ConfigureAddAction {
|
||||
val sheet = SelectActionOnSwipeBottomSheet(
|
||||
values = uiState.availableOptionsInbox,
|
||||
values = uiState.availableOptionsInbox.filterNot { a ->
|
||||
uiState.actionsOnSwipeToEndInbox.contains(a)
|
||||
},
|
||||
direction = ActionOnSwipeDirection.ToEnd,
|
||||
target = ActionOnSwipeTarget.Inbox,
|
||||
)
|
||||
|
@ -127,7 +127,6 @@ class ConfigureSwipeActionsViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
updateAvailableOptions()
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,7 +170,6 @@ class ConfigureSwipeActionsViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
updateAvailableOptions()
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,7 +213,6 @@ class ConfigureSwipeActionsViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
updateAvailableOptions()
|
||||
}
|
||||
}
|
||||
|
||||
@ -259,7 +256,6 @@ class ConfigureSwipeActionsViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
updateAvailableOptions()
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,7 +299,6 @@ class ConfigureSwipeActionsViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
updateAvailableOptions()
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,7 +342,6 @@ class ConfigureSwipeActionsViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
updateAvailableOptions()
|
||||
}
|
||||
}
|
||||
|
||||
@ -396,25 +390,33 @@ class ConfigureSwipeActionsViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateAvailableOptions() {
|
||||
private fun updateAvailableOptions(
|
||||
preventActionsOnBothSides: Boolean = false,
|
||||
) {
|
||||
val currentState = uiState.value
|
||||
val actionsPosts: Set<ActionOnSwipe> = buildSet {
|
||||
this += ActionOnSwipe.DEFAULT_SWIPE_TO_START_POSTS
|
||||
this += ActionOnSwipe.DEFAULT_SWIPE_TO_END_POSTS
|
||||
this -= currentState.actionsOnSwipeToStartPosts.toSet()
|
||||
this -= currentState.actionsOnSwipeToEndPosts.toSet()
|
||||
if (preventActionsOnBothSides) {
|
||||
this -= currentState.actionsOnSwipeToStartPosts.toSet()
|
||||
this -= currentState.actionsOnSwipeToEndPosts.toSet()
|
||||
}
|
||||
}
|
||||
val actionsComments: Set<ActionOnSwipe> = buildSet {
|
||||
this += ActionOnSwipe.DEFAULT_SWIPE_TO_START_COMMENTS
|
||||
this += ActionOnSwipe.DEFAULT_SWIPE_TO_END_COMMENTS
|
||||
this -= currentState.actionsOnSwipeToStartComments.toSet()
|
||||
this -= currentState.actionsOnSwipeToEndComments.toSet()
|
||||
if (preventActionsOnBothSides) {
|
||||
this -= currentState.actionsOnSwipeToStartComments.toSet()
|
||||
this -= currentState.actionsOnSwipeToEndComments.toSet()
|
||||
}
|
||||
}
|
||||
val actionsInbox: Set<ActionOnSwipe> = buildSet {
|
||||
this += ActionOnSwipe.DEFAULT_SWIPE_TO_START_INBOX
|
||||
this += ActionOnSwipe.DEFAULT_SWIPE_TO_END_INBOX
|
||||
this -= currentState.actionsOnSwipeToStartInbox.toSet()
|
||||
this -= currentState.actionsOnSwipeToEndInbox.toSet()
|
||||
if (preventActionsOnBothSides) {
|
||||
this -= currentState.actionsOnSwipeToStartInbox.toSet()
|
||||
this -= currentState.actionsOnSwipeToEndInbox.toSet()
|
||||
}
|
||||
}
|
||||
updateState {
|
||||
it.copy(
|
||||
|
Loading…
x
Reference in New Issue
Block a user