-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement forward/rewind clickable component
Closes #15
- Loading branch information
Thalys Matias Carrara
committed
Jun 7, 2023
1 parent
0a7cd07
commit 3c4e1b7
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
...va/com/profusion/androidenhancedvideoplayer/components/playerOverlay/SeekClickableArea.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.profusion.androidenhancedvideoplayer.components.playerOverlay | ||
|
||
import androidx.compose.foundation.gestures.detectTapGestures | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxHeight | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.scale | ||
import androidx.compose.ui.input.pointer.pointerInput | ||
import androidx.compose.ui.platform.testTag | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import com.profusion.androidenhancedvideoplayer.R | ||
|
||
@Composable | ||
fun SeekClickableArea( | ||
modifier: Modifier = Modifier, | ||
scaleAnimation: Float, | ||
seekState: Boolean, | ||
onSeekSingleTap: () -> Unit, | ||
onSeekDoubleTap: () -> Unit, | ||
toggleIsControlsVisible: () -> Unit, | ||
getSeekTime: () -> Int, | ||
seekIcon: @Composable (modifier: Modifier) -> Unit | ||
) { | ||
Box( | ||
modifier = modifier | ||
.fillMaxHeight() | ||
.pointerInput(seekState) { | ||
detectTapGestures( | ||
onTap = when (seekState) { | ||
true -> { _ -> onSeekSingleTap() } | ||
false -> { _ -> toggleIsControlsVisible() } | ||
}, | ||
onDoubleTap = when (seekState) { | ||
true -> null | ||
false -> { _ -> onSeekDoubleTap() } | ||
} | ||
) | ||
}.testTag("SeekClickableArea"), | ||
contentAlignment = Alignment.Center | ||
) { | ||
val timeLabel = getSeekTime() | ||
val timeUnit = stringResource(id = R.string.controls_time_unit) | ||
if (seekState) { | ||
Column(horizontalAlignment = Alignment.CenterHorizontally) { | ||
seekIcon(modifier = Modifier.scale(scaleAnimation)) | ||
Spacer(modifier = Modifier.height(20.dp)) | ||
Text( | ||
text = "$timeLabel $timeUnit", | ||
maxLines = 2 | ||
) | ||
} | ||
} | ||
} | ||
} |