Move playing song menu button to the bottom
This commit is contained in:
@@ -20,8 +20,11 @@ import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance
|
|||||||
@Composable
|
@Composable
|
||||||
fun PlayerBottomSheet(
|
fun PlayerBottomSheet(
|
||||||
layoutState: BottomSheetState,
|
layoutState: BottomSheetState,
|
||||||
|
isShowingLyrics: Boolean,
|
||||||
onShowLyrics: () -> Unit,
|
onShowLyrics: () -> Unit,
|
||||||
|
isShowingStatsForNerds: Boolean,
|
||||||
onShowStatsForNerds: () -> Unit,
|
onShowStatsForNerds: () -> Unit,
|
||||||
|
onShowMenu: () -> Unit,
|
||||||
onGlobalRouteEmitted: () -> Unit,
|
onGlobalRouteEmitted: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
@@ -54,6 +57,12 @@ fun PlayerBottomSheet(
|
|||||||
.padding(all = 8.dp)
|
.padding(all = 8.dp)
|
||||||
.size(20.dp)
|
.size(20.dp)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Spacer(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(all = 8.dp)
|
||||||
|
.size(20.dp)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Image(
|
Image(
|
||||||
@@ -72,7 +81,7 @@ fun PlayerBottomSheet(
|
|||||||
Image(
|
Image(
|
||||||
painter = painterResource(R.drawable.text),
|
painter = painterResource(R.drawable.text),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
colorFilter = ColorFilter.tint(colorPalette.text),
|
colorFilter = ColorFilter.tint(if (isShowingLyrics) colorPalette.text else colorPalette.textDisabled),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clickable(onClick = onShowLyrics)
|
.clickable(onClick = onShowLyrics)
|
||||||
.padding(all = 8.dp)
|
.padding(all = 8.dp)
|
||||||
@@ -82,12 +91,22 @@ fun PlayerBottomSheet(
|
|||||||
Image(
|
Image(
|
||||||
painter = painterResource(R.drawable.information),
|
painter = painterResource(R.drawable.information),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
colorFilter = ColorFilter.tint(colorPalette.text),
|
colorFilter = ColorFilter.tint(if (isShowingStatsForNerds) colorPalette.text else colorPalette.textDisabled),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clickable(onClick = onShowStatsForNerds)
|
.clickable(onClick = onShowStatsForNerds)
|
||||||
.padding(all = 8.dp)
|
.padding(all = 8.dp)
|
||||||
.size(20.dp)
|
.size(20.dp)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Image(
|
||||||
|
painter = painterResource(R.drawable.ellipsis_horizontal),
|
||||||
|
contentDescription = null,
|
||||||
|
colorFilter = ColorFilter.tint(colorPalette.text),
|
||||||
|
modifier = Modifier
|
||||||
|
.clickable(onClick = onShowMenu)
|
||||||
|
.padding(all = 8.dp)
|
||||||
|
.size(20.dp)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,86 +255,71 @@ fun PlayerView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TopAppBar {
|
|
||||||
Spacer(
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
|
||||||
.size(24.dp)
|
|
||||||
)
|
|
||||||
|
|
||||||
Image(
|
|
||||||
painter = painterResource(R.drawable.ellipsis_horizontal),
|
|
||||||
contentDescription = null,
|
|
||||||
colorFilter = ColorFilter.tint(colorPalette.text),
|
|
||||||
modifier = Modifier
|
|
||||||
.clickable {
|
|
||||||
menuState.display {
|
|
||||||
val resultRegistryOwner = LocalActivityResultRegistryOwner.current
|
|
||||||
|
|
||||||
BaseMediaItemMenu(
|
|
||||||
mediaItem = mediaItem,
|
|
||||||
onStartRadio = {
|
|
||||||
binder.stopRadio()
|
|
||||||
binder.player.seamlessPlay(mediaItem)
|
|
||||||
binder.setupRadio(
|
|
||||||
NavigationEndpoint.Endpoint.Watch(videoId = mediaItem.mediaId)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
onGoToEqualizer = {
|
|
||||||
val intent =
|
|
||||||
Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL).apply {
|
|
||||||
putExtra(
|
|
||||||
AudioEffect.EXTRA_AUDIO_SESSION,
|
|
||||||
binder.player.audioSessionId
|
|
||||||
)
|
|
||||||
putExtra(
|
|
||||||
AudioEffect.EXTRA_PACKAGE_NAME,
|
|
||||||
context.packageName
|
|
||||||
)
|
|
||||||
putExtra(
|
|
||||||
AudioEffect.EXTRA_CONTENT_TYPE,
|
|
||||||
AudioEffect.CONTENT_TYPE_MUSIC
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (intent.resolveActivity(context.packageManager) != null) {
|
|
||||||
val contract =
|
|
||||||
ActivityResultContracts.StartActivityForResult()
|
|
||||||
|
|
||||||
resultRegistryOwner?.activityResultRegistry
|
|
||||||
?.register("", contract) {}
|
|
||||||
?.launch(intent)
|
|
||||||
} else {
|
|
||||||
Toast
|
|
||||||
.makeText(
|
|
||||||
context,
|
|
||||||
"No equalizer app found!",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
)
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onSetSleepTimer = {},
|
|
||||||
onDismiss = menuState::hide,
|
|
||||||
onGlobalRouteEmitted = layoutState::collapseSoft,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
|
||||||
.size(24.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerBottomSheet(
|
PlayerBottomSheet(
|
||||||
layoutState = rememberBottomSheetState(64.dp, layoutState.upperBound),
|
layoutState = rememberBottomSheetState(64.dp, layoutState.upperBound),
|
||||||
|
isShowingLyrics = isShowingLyrics,
|
||||||
onShowLyrics = {
|
onShowLyrics = {
|
||||||
isShowingStatsForNerds = false
|
isShowingStatsForNerds = false
|
||||||
isShowingLyrics = !isShowingLyrics
|
isShowingLyrics = !isShowingLyrics
|
||||||
},
|
},
|
||||||
|
isShowingStatsForNerds = isShowingStatsForNerds,
|
||||||
onShowStatsForNerds = {
|
onShowStatsForNerds = {
|
||||||
isShowingLyrics = false
|
isShowingLyrics = false
|
||||||
isShowingStatsForNerds = !isShowingStatsForNerds
|
isShowingStatsForNerds = !isShowingStatsForNerds
|
||||||
},
|
},
|
||||||
|
onShowMenu = {
|
||||||
|
menuState.display {
|
||||||
|
val resultRegistryOwner = LocalActivityResultRegistryOwner.current
|
||||||
|
|
||||||
|
BaseMediaItemMenu(
|
||||||
|
mediaItem = mediaItem,
|
||||||
|
onStartRadio = {
|
||||||
|
binder.stopRadio()
|
||||||
|
binder.player.seamlessPlay(mediaItem)
|
||||||
|
binder.setupRadio(
|
||||||
|
NavigationEndpoint.Endpoint.Watch(videoId = mediaItem.mediaId)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onGoToEqualizer = {
|
||||||
|
val intent =
|
||||||
|
Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL).apply {
|
||||||
|
putExtra(
|
||||||
|
AudioEffect.EXTRA_AUDIO_SESSION,
|
||||||
|
binder.player.audioSessionId
|
||||||
|
)
|
||||||
|
putExtra(
|
||||||
|
AudioEffect.EXTRA_PACKAGE_NAME,
|
||||||
|
context.packageName
|
||||||
|
)
|
||||||
|
putExtra(
|
||||||
|
AudioEffect.EXTRA_CONTENT_TYPE,
|
||||||
|
AudioEffect.CONTENT_TYPE_MUSIC
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (intent.resolveActivity(context.packageManager) != null) {
|
||||||
|
val contract =
|
||||||
|
ActivityResultContracts.StartActivityForResult()
|
||||||
|
|
||||||
|
resultRegistryOwner?.activityResultRegistry
|
||||||
|
?.register("", contract) {}
|
||||||
|
?.launch(intent)
|
||||||
|
} else {
|
||||||
|
Toast
|
||||||
|
.makeText(
|
||||||
|
context,
|
||||||
|
"No equalizer app found!",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSetSleepTimer = {},
|
||||||
|
onDismiss = menuState::hide,
|
||||||
|
onGlobalRouteEmitted = layoutState::collapseSoft,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
onGlobalRouteEmitted = layoutState::collapseSoft,
|
onGlobalRouteEmitted = layoutState::collapseSoft,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.BottomCenter)
|
.align(Alignment.BottomCenter)
|
||||||
|
|||||||
Reference in New Issue
Block a user