diff --git a/app/src/main/java/app/suhasdissa/vibeyou/MainActivity.kt b/app/src/main/java/app/suhasdissa/vibeyou/MainActivity.kt index 366295f..b7c1c72 100644 --- a/app/src/main/java/app/suhasdissa/vibeyou/MainActivity.kt +++ b/app/src/main/java/app/suhasdissa/vibeyou/MainActivity.kt @@ -10,7 +10,6 @@ import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.activity.viewModels import androidx.compose.animation.AnimatedVisibility -import androidx.compose.foundation.background import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -23,6 +22,7 @@ import androidx.compose.material3.DrawerValue import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ModalNavigationDrawer import androidx.compose.material3.PermanentNavigationDrawer +import androidx.compose.material3.Surface import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo import androidx.compose.material3.rememberDrawerState import androidx.compose.runtime.Composable @@ -34,6 +34,7 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import androidx.core.net.toUri import androidx.lifecycle.viewmodel.compose.viewModel @@ -49,6 +50,9 @@ import app.suhasdissa.vibeyou.presentation.components.MiniPlayerScaffold import app.suhasdissa.vibeyou.presentation.components.ModalNavDrawerContent import app.suhasdissa.vibeyou.presentation.components.PermanentNavDrawerContent import app.suhasdissa.vibeyou.presentation.screens.player.FullScreenPlayer +import app.suhasdissa.vibeyou.presentation.screens.player.components.EqualizerSheet +import app.suhasdissa.vibeyou.presentation.screens.player.components.QueueSheet +import app.suhasdissa.vibeyou.presentation.screens.player.components.SongOptionsSheet import app.suhasdissa.vibeyou.presentation.screens.player.model.PlayerViewModel import app.suhasdissa.vibeyou.presentation.screens.settings.model.SettingsModel import app.suhasdissa.vibeyou.ui.theme.VibeYouTheme @@ -86,9 +90,11 @@ class MainActivity : ComponentActivity() { LaunchedEffect(Unit) { (application as MellowMusicApplication).accentColor = primaryColor } - MainAppContent( - playerViewModel, settingsModel - ) + Surface { + MainAppContent( + playerViewModel, settingsModel + ) + } } } @@ -342,13 +348,36 @@ private fun PermanentNavDrawerWithPlayerLayout( Modifier .fillMaxHeight() .width(400.dp) - .background(MaterialTheme.colorScheme.surface) ) { + var showQueueSheet by remember { mutableStateOf(false) } + var showSongOptions by remember { mutableStateOf(false) } + var showEqualizerSheet by remember { + mutableStateOf(false) + } FullScreenPlayer( controller, onCollapse = null, - playerViewModel + playerViewModel, + onClickShowQueueSheet = { showQueueSheet = true }, + onClickShowSongOptions = { showSongOptions = true } ) + if (showQueueSheet) QueueSheet(onDismissRequest = { + showQueueSheet = false + }, playerViewModel) + if (showSongOptions) SongOptionsSheet( + onDismissRequest = { showSongOptions = false }, + playerViewModel, + onClickShowEqualizer = { showEqualizerSheet = true } + ) + if (showEqualizerSheet) { + val app = + LocalContext.current.applicationContext as MellowMusicApplication + EqualizerSheet( + equalizerData = app.supportedEqualizerData!!, + onDismissRequest = { showEqualizerSheet = false }, + playerViewModel = playerViewModel + ) + } } } } diff --git a/app/src/main/java/app/suhasdissa/vibeyou/presentation/components/MiniPlayerScaffold.kt b/app/src/main/java/app/suhasdissa/vibeyou/presentation/components/MiniPlayerScaffold.kt index c026a8d..1c92b6b 100644 --- a/app/src/main/java/app/suhasdissa/vibeyou/presentation/components/MiniPlayerScaffold.kt +++ b/app/src/main/java/app/suhasdissa/vibeyou/presentation/components/MiniPlayerScaffold.kt @@ -18,11 +18,16 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import app.suhasdissa.vibeyou.MellowMusicApplication import app.suhasdissa.vibeyou.presentation.screens.player.FullScreenPlayer import app.suhasdissa.vibeyou.presentation.screens.player.FullScreenPlayerHorizontal import app.suhasdissa.vibeyou.presentation.screens.player.MiniPlayer +import app.suhasdissa.vibeyou.presentation.screens.player.components.EqualizerSheet +import app.suhasdissa.vibeyou.presentation.screens.player.components.QueueSheet +import app.suhasdissa.vibeyou.presentation.screens.player.components.SongOptionsSheet import app.suhasdissa.vibeyou.presentation.screens.player.model.PlayerViewModel import app.suhasdissa.vibeyou.utils.mediaItemState import kotlinx.coroutines.launch @@ -35,6 +40,11 @@ fun MiniPlayerScaffold( content: @Composable (PaddingValues) -> Unit ) { var isPlayerSheetVisible by remember { mutableStateOf(false) } + var showQueueSheet by remember { mutableStateOf(false) } + var showSongOptions by remember { mutableStateOf(false) } + var showEqualizerSheet by remember { + mutableStateOf(false) + } val playerSheetState = rememberModalBottomSheetState( skipPartiallyExpanded = true ) @@ -58,14 +68,8 @@ fun MiniPlayerScaffold( Row(Modifier.fillMaxSize()) { FullScreenPlayerHorizontal( controller, - onCollapse = { - scope.launch { playerSheetState.hide() }.invokeOnCompletion { - if (!playerSheetState.isVisible) { - isPlayerSheetVisible = false - } - } - }, - playerViewModel + playerViewModel, + onClickShowQueueSheet = { showQueueSheet = true } ) } } else { @@ -78,12 +82,27 @@ fun MiniPlayerScaffold( } } }, - playerViewModel + playerViewModel, + onClickShowQueueSheet = { showQueueSheet = true }, + onClickShowSongOptions = { showSongOptions = true } ) } } } } + if (showQueueSheet) QueueSheet(onDismissRequest = { showQueueSheet = false }, playerViewModel) + if (showSongOptions) SongOptionsSheet( + onDismissRequest = { showSongOptions = false }, + playerViewModel, + onClickShowEqualizer = { showEqualizerSheet = true } + ) + if (showEqualizerSheet) { + val app = LocalContext.current.applicationContext as MellowMusicApplication + EqualizerSheet( + equalizerData = app.supportedEqualizerData!!, + onDismissRequest = { showEqualizerSheet = false }, playerViewModel = playerViewModel + ) + } Scaffold( modifier = Modifier.fillMaxSize(), bottomBar = { diff --git a/app/src/main/java/app/suhasdissa/vibeyou/presentation/screens/player/FullScreenPlayer.kt b/app/src/main/java/app/suhasdissa/vibeyou/presentation/screens/player/FullScreenPlayer.kt index 1b1f338..ecdba8f 100644 --- a/app/src/main/java/app/suhasdissa/vibeyou/presentation/screens/player/FullScreenPlayer.kt +++ b/app/src/main/java/app/suhasdissa/vibeyou/presentation/screens/player/FullScreenPlayer.kt @@ -61,8 +61,6 @@ import androidx.media3.session.MediaController import app.suhasdissa.vibeyou.R import app.suhasdissa.vibeyou.backend.models.PlayerRepeatMode import app.suhasdissa.vibeyou.backend.models.PlayerState -import app.suhasdissa.vibeyou.presentation.screens.player.components.QueueSheet -import app.suhasdissa.vibeyou.presentation.screens.player.components.SongOptionsSheet import app.suhasdissa.vibeyou.presentation.screens.player.model.PlayerViewModel import app.suhasdissa.vibeyou.utils.IS_LOCAL_KEY import app.suhasdissa.vibeyou.utils.isPlayingState @@ -77,11 +75,10 @@ import coil.compose.SubcomposeAsyncImageContent fun FullScreenPlayer( controller: MediaController, onCollapse: (() -> Unit)?, - playerViewModel: PlayerViewModel + playerViewModel: PlayerViewModel, + onClickShowSongOptions: () -> Unit, + onClickShowQueueSheet: () -> Unit ) { - var showQueueSheet by remember { mutableStateOf(false) } - var showSongOptions by remember { mutableStateOf(false) } - val view = LocalView.current CenterAlignedTopAppBar(navigationIcon = { onCollapse?.let { onCollapse -> @@ -96,7 +93,7 @@ fun FullScreenPlayer( } } }, title = { Text(stringResource(R.string.now_playing)) }, actions = { - IconButton(onClick = { showSongOptions = true }) { + IconButton(onClick = onClickShowSongOptions) { Icon(Icons.Rounded.MoreVert, contentDescription = stringResource(R.string.song_options)) } }) @@ -178,28 +175,20 @@ fun FullScreenPlayer( ) { IconButton(onClick = { view.playSoundEffect(SoundEffectConstants.CLICK) - showQueueSheet = true + onClickShowQueueSheet.invoke() }) { Icon(Icons.AutoMirrored.Rounded.QueueMusic, stringResource(R.string.show_queue)) } } } - if (showQueueSheet) QueueSheet(onDismissRequest = { showQueueSheet = false }, playerViewModel) - if (showSongOptions) SongOptionsSheet( - onDismissRequest = { showSongOptions = false }, - playerViewModel - ) } @Composable fun FullScreenPlayerHorizontal( controller: MediaController, - onCollapse: (() -> Unit)?, - playerViewModel: PlayerViewModel + playerViewModel: PlayerViewModel, + onClickShowQueueSheet: () -> Unit ) { - var showQueueSheet by remember { mutableStateOf(false) } - var showSongOptions by remember { mutableStateOf(false) } - val view = LocalView.current Row( Modifier @@ -279,7 +268,7 @@ fun FullScreenPlayerHorizontal( ) { IconButton(onClick = { view.playSoundEffect(SoundEffectConstants.CLICK) - showQueueSheet = true + onClickShowQueueSheet.invoke() }) { Icon( Icons.AutoMirrored.Rounded.QueueMusic, @@ -291,11 +280,6 @@ fun FullScreenPlayerHorizontal( } } - if (showQueueSheet) QueueSheet(onDismissRequest = { showQueueSheet = false }, playerViewModel) - if (showSongOptions) SongOptionsSheet( - onDismissRequest = { showSongOptions = false }, - playerViewModel - ) } @Composable diff --git a/app/src/main/java/app/suhasdissa/vibeyou/presentation/screens/player/components/SongOptionsSheet.kt b/app/src/main/java/app/suhasdissa/vibeyou/presentation/screens/player/components/SongOptionsSheet.kt index 53584f6..481bdcc 100644 --- a/app/src/main/java/app/suhasdissa/vibeyou/presentation/screens/player/components/SongOptionsSheet.kt +++ b/app/src/main/java/app/suhasdissa/vibeyou/presentation/screens/player/components/SongOptionsSheet.kt @@ -25,7 +25,6 @@ import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableFloatStateOf -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue @@ -45,7 +44,8 @@ import kotlinx.coroutines.launch @Composable fun SongOptionsSheet( onDismissRequest: () -> Unit, - playerViewModel: PlayerViewModel + playerViewModel: PlayerViewModel, + onClickShowEqualizer: () -> Unit ) { val playerSheetState = rememberModalBottomSheetState( skipPartiallyExpanded = true @@ -54,10 +54,6 @@ fun SongOptionsSheet( val view = LocalView.current val app = LocalContext.current.applicationContext as MellowMusicApplication - var showEqualizerSheet by remember { - mutableStateOf(false) - } - ModalBottomSheet( onDismissRequest = onDismissRequest, sheetState = playerSheetState, @@ -122,18 +118,11 @@ fun SongOptionsSheet( Spacer(modifier = Modifier.height(10.dp)) if (app.supportedEqualizerData != null) { Button(modifier = Modifier.padding(start = 10.dp), onClick = { - showEqualizerSheet = true + onClickShowEqualizer.invoke() }) { Text(text = stringResource(id = R.string.equalizer)) } } Spacer(modifier = Modifier.height(30.dp)) } - - if (showEqualizerSheet) { - EqualizerSheet( - equalizerData = app.supportedEqualizerData!!, - onDismissRequest = { showEqualizerSheet = false }, playerViewModel = playerViewModel - ) - } }