Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
style: fix dark theme issues and sheet order
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhasDissa committed May 8, 2024
1 parent 0c0f7fe commit 3943ad9
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 53 deletions.
41 changes: 35 additions & 6 deletions app/src/main/java/app/suhasdissa/vibeyou/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -86,9 +90,11 @@ class MainActivity : ComponentActivity() {
LaunchedEffect(Unit) {
(application as MellowMusicApplication).accentColor = primaryColor
}
MainAppContent(
playerViewModel, settingsModel
)
Surface {
MainAppContent(
playerViewModel, settingsModel
)
}
}
}

Expand Down Expand Up @@ -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
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
Expand All @@ -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 {
Expand All @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ->
Expand All @@ -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))
}
})
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -279,7 +268,7 @@ fun FullScreenPlayerHorizontal(
) {
IconButton(onClick = {
view.playSoundEffect(SoundEffectConstants.CLICK)
showQueueSheet = true
onClickShowQueueSheet.invoke()
}) {
Icon(
Icons.AutoMirrored.Rounded.QueueMusic,
Expand All @@ -291,11 +280,6 @@ fun FullScreenPlayerHorizontal(

}
}
if (showQueueSheet) QueueSheet(onDismissRequest = { showQueueSheet = false }, playerViewModel)
if (showSongOptions) SongOptionsSheet(
onDismissRequest = { showSongOptions = false },
playerViewModel
)
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,7 +44,8 @@ import kotlinx.coroutines.launch
@Composable
fun SongOptionsSheet(
onDismissRequest: () -> Unit,
playerViewModel: PlayerViewModel
playerViewModel: PlayerViewModel,
onClickShowEqualizer: () -> Unit
) {
val playerSheetState = rememberModalBottomSheetState(
skipPartiallyExpanded = true
Expand All @@ -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,
Expand Down Expand Up @@ -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
)
}
}

0 comments on commit 3943ad9

Please sign in to comment.