Skip to content

Commit

Permalink
Merge pull request #627 from RounakDadsena/jetpack_compose
Browse files Browse the repository at this point in the history
added swipe in player right and left
  • Loading branch information
maxrave-dev authored Dec 31, 2024
2 parents 7c78761 + ae6b8b8 commit c902b76
Showing 1 changed file with 47 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ import androidx.compose.ui.unit.dp
import androidx.core.os.bundleOf
import androidx.media3.common.util.UnstableApi
import androidx.navigation.NavController
import androidx.compose.foundation.gestures.detectHorizontalDragGestures
import androidx.compose.ui.input.pointer.pointerInput
import coil3.compose.AsyncImage
import coil3.request.CachePolicy
import coil3.request.ImageRequest
Expand Down Expand Up @@ -375,29 +377,52 @@ fun NowPlayingScreen(
}
}

Column(
Modifier
.verticalScroll(
mainScrollState,
).then(
if (showHideMiddleLayout) {
Modifier.background(
Brush.linearGradient(
colors =
listOf(
startColor.value,
endColor
.value,
),
start = gradientOffset.start,
end = gradientOffset.end,
Column(
Modifier
.verticalScroll(mainScrollState)
.pointerInput(Unit) {
var isSwipeHandled = false
detectHorizontalDragGestures(
onDragEnd = { isSwipeHandled = false }
) { change, dragAmount ->
change.consume()
if (!isSwipeHandled) {
when {
// Swipe left (negative dragAmount)
dragAmount < -50 -> {
if (controllerState.isNextAvailable) {
sharedViewModel.onUIEvent(UIEvent.Next)
isSwipeHandled = true
}
}
// Swipe right (positive dragAmount)
dragAmount > 50 -> {
if (controllerState.isPreviousAvailable) {
sharedViewModel.onUIEvent(UIEvent.Previous)
isSwipeHandled = true
}
}
}
}
}
}
.then(
if (showHideMiddleLayout) {
Modifier.background(
Brush.linearGradient(
colors = listOf(
startColor.value,
endColor.value,
),
)
} else {
Modifier.background(md_theme_dark_background)
},
),
) {
start = gradientOffset.start,
end = gradientOffset.end,
),
)
} else {
Modifier.background(md_theme_dark_background)
},
)
) {
Box(modifier = Modifier.fillMaxWidth()) {
// Canvas Layout
Box(
Expand Down

0 comments on commit c902b76

Please sign in to comment.