mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-23 19:26:50 +00:00
refactor(player): replace PurefinTextButton with SkipSegmentButton for improved UI consistency
This commit is contained in:
@@ -32,16 +32,13 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
|
||||||
import androidx.compose.ui.viewinterop.AndroidView
|
import androidx.compose.ui.viewinterop.AndroidView
|
||||||
import androidx.media3.common.util.UnstableApi
|
import androidx.media3.common.util.UnstableApi
|
||||||
import androidx.media3.ui.AspectRatioFrameLayout
|
import androidx.media3.ui.AspectRatioFrameLayout
|
||||||
import androidx.media3.ui.PlayerView
|
import androidx.media3.ui.PlayerView
|
||||||
import androidx.media3.ui.SubtitleView
|
import androidx.media3.ui.SubtitleView
|
||||||
import hu.bbara.purefin.player.viewmodel.PlayerViewModel
|
import hu.bbara.purefin.player.viewmodel.PlayerViewModel
|
||||||
import hu.bbara.purefin.ui.common.button.PurefinTextButton
|
|
||||||
import hu.bbara.purefin.ui.common.visual.EmptyValueTimedVisibility
|
import hu.bbara.purefin.ui.common.visual.EmptyValueTimedVisibility
|
||||||
import hu.bbara.purefin.ui.common.visual.ValueChangeTimedVisibility
|
import hu.bbara.purefin.ui.common.visual.ValueChangeTimedVisibility
|
||||||
import hu.bbara.purefin.ui.screen.player.components.PersistentOverlayContainer
|
import hu.bbara.purefin.ui.screen.player.components.PersistentOverlayContainer
|
||||||
@@ -50,6 +47,7 @@ import hu.bbara.purefin.ui.screen.player.components.PlayerControlsOverlay
|
|||||||
import hu.bbara.purefin.ui.screen.player.components.PlayerGesturesLayer
|
import hu.bbara.purefin.ui.screen.player.components.PlayerGesturesLayer
|
||||||
import hu.bbara.purefin.ui.screen.player.components.PlayerLoadingErrorEndCard
|
import hu.bbara.purefin.ui.screen.player.components.PlayerLoadingErrorEndCard
|
||||||
import hu.bbara.purefin.ui.screen.player.components.PlayerQueuePanel
|
import hu.bbara.purefin.ui.screen.player.components.PlayerQueuePanel
|
||||||
|
import hu.bbara.purefin.ui.screen.player.components.SkipSegmentButton
|
||||||
import hu.bbara.purefin.ui.screen.player.components.rememberPersistentOverlayController
|
import hu.bbara.purefin.ui.screen.player.components.rememberPersistentOverlayController
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
@@ -216,16 +214,7 @@ fun PlayerScreen(
|
|||||||
.align(Alignment.BottomEnd)
|
.align(Alignment.BottomEnd)
|
||||||
.padding(end = 24.dp, bottom = 24.dp)
|
.padding(end = 24.dp, bottom = 24.dp)
|
||||||
) {
|
) {
|
||||||
PurefinTextButton(
|
SkipSegmentButton(onClick = { viewModel.skipActiveSegment() })
|
||||||
onClick = { viewModel.skipActiveSegment() },
|
|
||||||
modifier = Modifier.padding(8.dp)
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = "Skip",
|
|
||||||
fontSize = 20.sp,
|
|
||||||
fontWeight = FontWeight.ExtraBold
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerLoadingErrorEndCard(
|
PlayerLoadingErrorEndCard(
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ import androidx.compose.foundation.layout.Spacer
|
|||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.heightIn
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.ArrowBack
|
import androidx.compose.material.icons.outlined.ArrowBack
|
||||||
import androidx.compose.material.icons.outlined.Cast
|
import androidx.compose.material.icons.outlined.Cast
|
||||||
@@ -22,6 +26,9 @@ import androidx.compose.material.icons.outlined.PlaylistPlay
|
|||||||
import androidx.compose.material.icons.outlined.Replay10
|
import androidx.compose.material.icons.outlined.Replay10
|
||||||
import androidx.compose.material.icons.outlined.SkipNext
|
import androidx.compose.material.icons.outlined.SkipNext
|
||||||
import androidx.compose.material.icons.outlined.SkipPrevious
|
import androidx.compose.material.icons.outlined.SkipPrevious
|
||||||
|
import androidx.compose.material3.ButtonDefaults
|
||||||
|
import androidx.compose.material3.FilledTonalButton
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -35,12 +42,10 @@ import androidx.compose.ui.graphics.Brush
|
|||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
|
||||||
import hu.bbara.purefin.player.model.PlayerUiState
|
import hu.bbara.purefin.player.model.PlayerUiState
|
||||||
import hu.bbara.purefin.player.model.TrackOption
|
import hu.bbara.purefin.player.model.TrackOption
|
||||||
import hu.bbara.purefin.ui.common.button.GhostIconButton
|
import hu.bbara.purefin.ui.common.button.GhostIconButton
|
||||||
import hu.bbara.purefin.ui.common.button.PurefinIconButton
|
import hu.bbara.purefin.ui.common.button.PurefinIconButton
|
||||||
import hu.bbara.purefin.ui.common.button.PurefinTextButton
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PlayerControlsOverlay(
|
fun PlayerControlsOverlay(
|
||||||
@@ -283,28 +288,47 @@ private fun BottomSection(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (uiState.activeSkippableSegmentEndMs != null) {
|
if (uiState.activeSkippableSegmentEndMs != null) {
|
||||||
Row(
|
SkipSegmentButton(
|
||||||
modifier = Modifier.align(Alignment.CenterEnd),
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically
|
|
||||||
) {
|
|
||||||
PurefinTextButton(
|
|
||||||
onClick = onSkipSegment,
|
onClick = onSkipSegment,
|
||||||
modifier = Modifier.padding(8.dp)
|
modifier = Modifier.align(Alignment.CenterEnd)
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = "Skip",
|
|
||||||
fontSize = 20.sp,
|
|
||||||
fontWeight = FontWeight.ExtraBold
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
Spacer(modifier = Modifier.height(12.dp))
|
Spacer(modifier = Modifier.height(12.dp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun SkipSegmentButton(
|
||||||
|
onClick: () -> Unit,
|
||||||
|
modifier: Modifier = Modifier
|
||||||
|
) {
|
||||||
|
val scheme = MaterialTheme.colorScheme
|
||||||
|
|
||||||
|
FilledTonalButton(
|
||||||
|
onClick = onClick,
|
||||||
|
modifier = modifier.heightIn(min = 44.dp),
|
||||||
|
shape = RoundedCornerShape(50),
|
||||||
|
colors = ButtonDefaults.filledTonalButtonColors(
|
||||||
|
containerColor = scheme.secondary.copy(alpha = 0.92f),
|
||||||
|
contentColor = scheme.onSecondary
|
||||||
|
),
|
||||||
|
contentPadding = ButtonDefaults.ButtonWithIconContentPadding
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "Skip",
|
||||||
|
style = MaterialTheme.typography.labelLarge,
|
||||||
|
fontWeight = FontWeight.Bold
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Outlined.SkipNext,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(18.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun formatTime(positionMs: Long): String {
|
private fun formatTime(positionMs: Long): String {
|
||||||
val totalSeconds = positionMs / 1000
|
val totalSeconds = positionMs / 1000
|
||||||
val seconds = (totalSeconds % 60).toInt()
|
val seconds = (totalSeconds % 60).toInt()
|
||||||
|
|||||||
Reference in New Issue
Block a user