-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: Improved Miniplayer and Fullscreen player
refactor: Improved queue logic - Moved from ViewModel to Service Signed-off-by: Gabriel Fontán <[email protected]>
- Loading branch information
Showing
7 changed files
with
231 additions
and
99 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
app/mediaplayer/src/main/java/com/bobbyesp/mediaplayer/ext/MediaMetadata.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,10 @@ | ||
package com.bobbyesp.mediaplayer.ext | ||
|
||
import androidx.media3.common.MediaItem | ||
import androidx.media3.common.MediaMetadata | ||
|
||
fun MediaMetadata.toMediaItem(): MediaItem { | ||
return MediaItem.Builder() | ||
.setMediaMetadata(this) | ||
.build() | ||
} |
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
73 changes: 73 additions & 0 deletions
73
...in/java/com/bobbyesp/metadator/presentation/components/buttons/PlayPauseAnimatedButton.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,73 @@ | ||
package com.bobbyesp.metadator.presentation.components.buttons | ||
|
||
import androidx.compose.animation.core.animateDpAsState | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
import androidx.compose.foundation.interaction.collectIsPressedAsState | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.PlayArrow | ||
import androidx.compose.material.icons.rounded.Pause | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.material3.ripple | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun PlayPauseAnimatedButton( | ||
modifier: Modifier = Modifier, | ||
isPlaying: Boolean, | ||
onClick: () -> Unit | ||
) { | ||
val interactionSource = remember { MutableInteractionSource() } | ||
val isPressed = interactionSource.collectIsPressedAsState() | ||
val radius = if (isPlaying || isPressed.value) { | ||
40.dp | ||
} else { | ||
24.dp | ||
} | ||
val cornerRadius = animateDpAsState(targetValue = radius, label = "Animated button shape") | ||
|
||
Surface( | ||
tonalElevation = 10.dp, | ||
modifier = modifier | ||
.clip(RoundedCornerShape(cornerRadius.value)) | ||
) { | ||
Box( | ||
modifier = Modifier | ||
.background(MaterialTheme.colorScheme.onSecondary) | ||
.size(72.dp) | ||
.clip(RoundedCornerShape(cornerRadius.value)) | ||
.clickable( | ||
interactionSource = interactionSource, | ||
indication = ripple(bounded = false), | ||
) { onClick() }, | ||
contentAlignment = Alignment.Center | ||
) { | ||
if (isPlaying) { | ||
Icon( | ||
imageVector = Icons.Rounded.Pause, | ||
contentDescription = "Pause", | ||
tint = MaterialTheme.colorScheme.secondary, | ||
modifier = Modifier.size(32.dp) | ||
) | ||
} else { | ||
Icon( | ||
imageVector = Icons.Default.PlayArrow, | ||
contentDescription = "Play", | ||
tint = MaterialTheme.colorScheme.secondary, | ||
modifier = Modifier.size(32.dp) | ||
) | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.