Skip to content

Commit 24e66cf

Browse files
committed
feat: support "None" swipe action
1 parent c3d45ae commit 24e66cf

4 files changed

Lines changed: 12 additions & 5 deletions

File tree

core/designsystem/src/main/java/io/simplelogin/core/designsystem/ModelExtensions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import io.simplelogin.core.model.preferences.DefaultPrefix.RANDOM_CHARACTERS
3838
import io.simplelogin.core.model.preferences.DefaultPrefix.RANDOM_WORD
3939
import io.simplelogin.core.model.preferences.DeviceLockType
4040
import io.simplelogin.core.model.preferences.DeviceLockType.BIOMETRIC
41-
import io.simplelogin.core.model.preferences.DeviceLockType.NONE
4241
import io.simplelogin.core.model.preferences.DeviceLockType.PIN
4342
import io.simplelogin.core.model.preferences.LockTimeOut
4443
import io.simplelogin.core.model.preferences.LockTimeOut.FIVE_MINUTES
@@ -105,6 +104,7 @@ fun AliasOptionsDisplay.title(context: Context) = when (this) {
105104
}
106105

107106
fun SwipeAction.title(context: Context) = when (this) {
107+
SwipeAction.NONE -> context.getString(R.string.none)
108108
DISABLE_ENABLE -> context.getString(R.string.disable_enable)
109109
PIN_UNPIN -> context.getString(R.string.pin_unpin)
110110
DELETE -> context.getString(R.string.delete)
@@ -144,7 +144,7 @@ fun ContactCellSelection.title(context: Context) = when (this) {
144144
}
145145

146146
fun DeviceLockType.title(context: Context) = when (this) {
147-
NONE -> context.getString(R.string.none)
147+
DeviceLockType.NONE -> context.getString(R.string.none)
148148
BIOMETRIC -> context.getString(R.string.biometric)
149149
PIN -> context.getString(R.string.pin_code)
150150
}

core/model/src/main/java/io/simplelogin/core/model/preferences/DevicePreferences.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ enum class AliasOptionsDisplay {
4141
}
4242

4343
enum class SwipeAction {
44-
DISABLE_ENABLE, PIN_UNPIN, DELETE
44+
NONE, DISABLE_ENABLE, PIN_UNPIN, DELETE
4545
}
4646

4747
enum class AliasDisplayInfo {

feature/aliaslist/src/main/java/io/simplelogin/feature/aliaslist/AliasRow.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ fun AliasRow(
8686
}
8787

8888
when (action) {
89+
SwipeAction.NONE -> dismissState.reset()
90+
8991
SwipeAction.DISABLE_ENABLE -> {
9092
if (alias.enabled) {
9193
onAction?.invoke(AliasAction.Disable(alias))
@@ -116,6 +118,8 @@ fun AliasRow(
116118
SwipeToDismissBox(
117119
modifier = modifier,
118120
state = dismissState,
121+
enableDismissFromStartToEnd = swipeFromStartToEndAction != SwipeAction.NONE,
122+
enableDismissFromEndToStart = swipeFromEndToStartAction != SwipeAction.NONE,
119123
backgroundContent = {
120124
val direction = dismissState.dismissDirection
121125
val isSwiping = dismissState.progress > 0.01f
@@ -317,6 +321,7 @@ private fun AliasCellContent(
317321
@Composable
318322
private fun SwipeAction.color(alias: Alias): Color =
319323
when (this) {
324+
SwipeAction.NONE -> Color.Transparent
320325
SwipeAction.PIN_UNPIN -> if (alias.pinned) SlColor.Amber else MaterialTheme.colorScheme.primary
321326
SwipeAction.DISABLE_ENABLE -> if (alias.enabled) Color.Gray else SlColor.Green
322327
SwipeAction.DELETE -> Color.Red
@@ -325,6 +330,8 @@ private fun SwipeAction.color(alias: Alias): Color =
325330
@Composable
326331
private fun SwipeAction.Label(alias: Alias) {
327332
when (this) {
333+
SwipeAction.NONE -> {}
334+
328335
SwipeAction.DISABLE_ENABLE ->
329336
if (alias.enabled) {
330337
SwipeActionLabel(

feature/devicesettings/src/main/java/io/simplelogin/feature/devicesettings/DeviceSettingsViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class DeviceSettingsViewModel @Inject constructor(
6868
updateDeviceSettings.invoke {
6969
it.copy(swipeFromLeftToRightAction = action)
7070
}
71-
if (action == currentSettings.swipeFromRightToLeftAction) {
71+
if (action != SwipeAction.NONE && action == currentSettings.swipeFromRightToLeftAction) {
7272
updateDeviceSettings.invoke {
7373
it.copy(swipeFromRightToLeftAction = oldSwipeFromLeftToRight)
7474
}
@@ -82,7 +82,7 @@ class DeviceSettingsViewModel @Inject constructor(
8282
updateDeviceSettings.invoke {
8383
it.copy(swipeFromRightToLeftAction = action)
8484
}
85-
if (action == currentSettings.swipeFromLeftToRightAction) {
85+
if (action != SwipeAction.NONE && action == currentSettings.swipeFromLeftToRightAction) {
8686
updateDeviceSettings.invoke {
8787
it.copy(swipeFromLeftToRightAction = oldSwipeFromRightToLeft)
8888
}

0 commit comments

Comments
 (0)