Skip to content

Commit

Permalink
refactor: Clean code before review
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Nov 29, 2024
1 parent 72ae3a3 commit 3c335c8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.*
import androidx.compose.material3.Icon
import androidx.compose.material3.Surface
import androidx.compose.material3.SwipeToDismissBox
import androidx.compose.material3.SwipeToDismissBoxValue.EndToStart
import androidx.compose.material3.rememberSwipeToDismissBoxState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -61,22 +65,22 @@ fun SwipeToDismissComponent(
positionalThreshold = { totalDistance -> totalDistance * dismissThreshold },
)

if (state.currentValue == SwipeToDismissBoxValue.EndToStart) onSwiped()
if (state.currentValue == EndToStart) onSwiped()

val backgroundColor by animateColorAsState(
targetValue = if (state.targetValue == SwipeToDismissBoxValue.EndToStart) {
targetValue = if (state.targetValue == EndToStart) {
SwissTransferTheme.colors.swipeDelete
} else {
SwissTransferTheme.colors.swipeDefault
},
label = "Background color animation",
)
val iconScale by animateFloatAsState(
targetValue = if (state.targetValue == SwipeToDismissBoxValue.EndToStart) maxIconScale else minIconScale,
targetValue = if (state.targetValue == EndToStart) maxIconScale else minIconScale,
label = "Icon scale animation",
)
val contentElevation by animateDpAsState(
targetValue = if (state.dismissDirection == SwipeToDismissBoxValue.EndToStart) swipedElevation else 0.dp,
targetValue = if (state.dismissDirection == EndToStart) swipedElevation else 0.dp,
label = "Content elevation animation",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ fun TransferItemList(
) {

val selectedTransferUuid = getSelectedTransferUuid()
val itemShape = CustomShapes.SMALL
val titleRes = when (direction) {
TransferDirection.SENT -> R.string.sentFilesTitle
TransferDirection.RECEIVED -> R.string.receivedFilesTitle
}
val itemShape = CustomShapes.SMALL

LazyColumn(
modifier = modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fun ReceivedScreen(
navigateToDetails = navigateToDetails,
getSelectedTransferUuid = getSelectedTransferUuid,
getTransfers = { transfers!! },
onSwiped = transfersViewModel::deleteSwipedTransfer,
onSwiped = transfersViewModel::deleteTransfer,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fun SentScreen(
navigateToDetails = navigateToDetails,
getSelectedTransferUuid = getSelectedTransferUuid,
getTransfers = { transfers!! },
onSwiped = transfersViewModel::deleteSwipedTransfer,
onSwiped = transfersViewModel::deleteTransfer,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TransfersViewModel @Inject constructor(
}
}

fun deleteSwipedTransfer(transferUuid: String) {
fun deleteTransfer(transferUuid: String) {
viewModelScope.launch(ioDispatcher) {
runCatching {
transferManager.deleteTransfer(transferUuid)
Expand Down

0 comments on commit 3c335c8

Please sign in to comment.