Skip to content

Commit

Permalink
Merge pull request #52 from swingmx/artist-info
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericgacoki authored Nov 15, 2024
2 parents e9b5b87 + c7f223b commit 343a7bc
Show file tree
Hide file tree
Showing 22 changed files with 259 additions and 121 deletions.
20 changes: 10 additions & 10 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ plugins {

android {
namespace = "com.android.swingmusic"
compileSdk = 34
compileSdk = 35

defaultConfig {
applicationId = "com.android.swingmusic"
minSdk = 26
targetSdk = 34
targetSdk = 35
versionCode = 1
versionName = "1.0.0"

Expand Down Expand Up @@ -67,11 +67,11 @@ dependencies {

// Core
// implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.activity:activity-ktx:1.9.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.4")
implementation("androidx.activity:activity-ktx:1.9.3")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")

// Compose
implementation(platform("androidx.compose:compose-bom:2023.08.00"))
implementation(platform("androidx.compose:compose-bom:2024.10.01"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
Expand Down Expand Up @@ -101,7 +101,7 @@ dependencies {
implementation("com.jakewharton.timber:timber:5.0.1")

// WorkManger
implementation("androidx.work:work-runtime-ktx:2.9.0")
implementation("androidx.work:work-runtime-ktx:2.10.0")
implementation("androidx.hilt:hilt-work:1.2.0")

// Navigation
Expand All @@ -110,8 +110,8 @@ dependencies {
ksp("io.github.raamcosta.compose-destinations:ksp:1.9.63")

// Media3-Player
implementation("androidx.media3:media3-exoplayer:1.4.0")
implementation("androidx.media3:media3-session:1.4.0")
implementation("androidx.media3:media3-exoplayer:1.4.1")
implementation("androidx.media3:media3-session:1.4.1")
// implementation("androidx.media3:media3-exoplayer-hls:1.3.1")
// implementation("androidx.media3:media3-exoplayer-dash:1.3.1")

Expand All @@ -121,8 +121,8 @@ dependencies {
// Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.4")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.4")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.7")
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.android.swingmusic.album.presentation.screen.destinations.AllAlbumScreenDestination
import com.android.swingmusic.artist.presentation.screen.destinations.ArtistsScreenDestination
import com.android.swingmusic.artist.presentation.screen.destinations.ViewAllScreenDestination
import com.android.swingmusic.artist.presentation.viewmodel.ArtistInfoViewModel
import com.android.swingmusic.auth.data.workmanager.scheduleTokenRefreshWork
import com.android.swingmusic.auth.presentation.screen.destinations.LoginWithQrCodeDestination
Expand Down Expand Up @@ -166,17 +167,40 @@ class MainActivity : ComponentActivity() {
"auth/${LoginWithQrCodeDestination.route}",
"auth/${LoginWithUsernameScreenDestination.route}",
"player/${NowPlayingScreenDestination.route}",
"player/${QueueScreenDestination.route}"
"player/${QueueScreenDestination.route}",

// Hide mini player in view all screen
"player/${ViewAllScreenDestination.route}",
"folder/${ViewAllScreenDestination.route}",
"album/${ViewAllScreenDestination.route}",
"artist/${ViewAllScreenDestination.route}"
))
) {
MiniPlayer(
mediaControllerViewModel = mediaControllerViewModel,
onClickPlayerItem = {
/*if (route !in listOf<String>(
// make mini player un-clickable in view all screen
"player/${ViewAllScreenDestination.route}",
"folder/${ViewAllScreenDestination.route}",
"album/${ViewAllScreenDestination.route}",
"artist/${ViewAllScreenDestination.route}"
)
) {
navController.navigate(
"player/${NowPlayingScreenDestination.route}",
fun NavOptionsBuilder.() {
launchSingleTop = true
restoreState = false
}
)
}*/

navController.navigate(
"player/${NowPlayingScreenDestination.route}",
fun NavOptionsBuilder.() {
launchSingleTop = false
restoreState = true
launchSingleTop = true
restoreState = false
}
)
}
Expand All @@ -196,7 +220,7 @@ class MainActivity : ComponentActivity() {
val currentSelectedItem by navController.currentScreenAsState(
isUserLoggedIn
)

if (showBottomNav) {
NavigationBar(
modifier = Modifier.fillMaxWidth(),
Expand All @@ -219,7 +243,7 @@ class MainActivity : ComponentActivity() {
label = { Text(text = item.title) },
onClick = {
navController.navigate(
item.navGraph!!,
item.navGraph,
fun NavOptionsBuilder.() {
launchSingleTop = true
restoreState = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import com.android.swingmusic.uicomponent.R as UiComponent
sealed class BottomNavItem(
var title: String,
@DrawableRes var icon: Int,
var navGraph: NavGraphSpec?
var navGraph: NavGraphSpec
) {
data object Home : BottomNavItem(
/*data object Home : BottomNavItem(
title = "Home",
icon = UiComponent.drawable.ic_home,
navGraph = null
)
)*/

data object Folder : BottomNavItem(
title = "Folders",
Expand All @@ -27,11 +27,11 @@ sealed class BottomNavItem(
navGraph = NavGraphs.album
)

data object Playlist : BottomNavItem(
/*data object Playlist : BottomNavItem(
title = "Playlists",
icon = UiComponent.drawable.play_list,
navGraph = null
)
)*/

data object Artist : BottomNavItem(
title = "Artists",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.android.swingmusic.auth.presentation.screen.destinations.LoginWithQrC
import com.android.swingmusic.auth.presentation.screen.destinations.LoginWithUsernameScreenDestination
import com.android.swingmusic.auth.presentation.viewmodel.AuthViewModel
import com.android.swingmusic.common.presentation.navigator.CommonNavigator
import com.android.swingmusic.folder.presentation.screen.destinations.FoldersAndTracksScreenDestination
import com.android.swingmusic.player.presentation.screen.destinations.QueueScreenDestination
import com.android.swingmusic.player.presentation.viewmodel.MediaControllerViewModel
import com.ramcosta.composedestinations.dynamic.within
Expand Down Expand Up @@ -140,7 +141,10 @@ class CoreNavigator(

override fun gotoArtistInfo(artistHash: String) {
val currentDestination = navController.currentDestination?.route
val targetDestination = ArtistInfoScreenDestination(artistHash)
val targetDestination = ArtistInfoScreenDestination(
artistHash = artistHash,
loadNewArtist = true
)

if (currentDestination != targetDestination.route) {
navController.navigate(
Expand Down Expand Up @@ -172,4 +176,20 @@ class CoreNavigator(
)
}
}

override fun gotoSourceFolder(name: String, path: String) {
val currentDestination = navController.currentDestination?.route
val targetDestination =
FoldersAndTracksScreenDestination(gotoFolderName = name, gotoFolderPath = path)

if (currentDestination != targetDestination.route) {
navController.navigate(
targetDestination within navGraph,
fun NavOptionsBuilder.() {
launchSingleTop = true
restoreState = true
}
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ object NavGraphs {
QueueScreenDestination,
ArtistInfoScreenDestination,
ViewAllScreenDestination,
AlbumWithInfoScreenDestination
AlbumWithInfoScreenDestination,
FoldersAndTracksScreenDestination
).routedIn(this).associateBy { it.route }
}

Expand All @@ -81,7 +82,8 @@ object NavGraphs {
ArtistInfoScreenDestination,
AlbumWithInfoScreenDestination,
ViewAllScreenDestination,
NowPlayingScreenDestination
NowPlayingScreenDestination,
FoldersAndTracksScreenDestination
).routedIn(this).associateBy { it.route }
}

Expand All @@ -96,7 +98,8 @@ object NavGraphs {
AlbumWithInfoScreenDestination,
ArtistInfoScreenDestination,
ViewAllScreenDestination,
NowPlayingScreenDestination
NowPlayingScreenDestination,
FoldersAndTracksScreenDestination
).routedIn(this).associateBy { it.route }
}

Expand Down
16 changes: 8 additions & 8 deletions auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

android {
namespace = "com.android.swingmusic.auth"
compileSdk = 34
compileSdk = 35

defaultConfig {
minSdk = 26
Expand Down Expand Up @@ -51,11 +51,11 @@ dependencies {
implementation(project(":feature:common"))

// Core
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.3")
implementation("androidx.core:core-ktx:1.15.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")

// Compose
implementation(platform("androidx.compose:compose-bom:2023.08.00"))
implementation(platform("androidx.compose:compose-bom:2024.10.01"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
Expand All @@ -82,7 +82,7 @@ dependencies {
implementation("androidx.datastore:datastore-preferences:1.1.1")

// WorkManger
implementation("androidx.work:work-runtime-ktx:2.9.0")
implementation("androidx.work:work-runtime-ktx:2.10.0")
implementation("androidx.hilt:hilt-work:1.2.0")

// Timber
Expand All @@ -94,9 +94,9 @@ dependencies {

// Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.3")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.7")
}

kotlin {
Expand Down
3 changes: 1 addition & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ android {
}

dependencies {
implementation("androidx.core:core-ktx:1.13.1")
// implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.core:core-ktx:1.15.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
Expand Down
4 changes: 2 additions & 2 deletions feature/album/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ dependencies {
implementation(project(":feature:common"))

// Core
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.4")
implementation("androidx.core:core-ktx:1.15.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")

// Jetpack Compose
implementation(platform("androidx.compose:compose-bom:2024.10.01"))
Expand Down
4 changes: 2 additions & 2 deletions feature/artist/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ dependencies {
implementation(project(":feature:common"))

// Core
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.3")
implementation("androidx.core:core-ktx:1.15.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")

// Compose
implementation(platform("androidx.compose:compose-bom:2024.10.01"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import com.android.swingmusic.uicomponent.presentation.theme.SwingMusicTheme_Pre
import com.android.swingmusic.uicomponent.presentation.util.Screen
import com.android.swingmusic.uicomponent.presentation.util.formattedAlbumDuration
import com.ramcosta.composedestinations.annotation.Destination
import timber.log.Timber

@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
@Composable
Expand Down Expand Up @@ -752,6 +753,7 @@ fun ArtistInfoScreen(
mediaControllerViewModel: MediaControllerViewModel,
artistInfoViewModel: ArtistInfoViewModel,
artistHash: String,
loadNewArtist: Boolean,
commonNavigator: CommonNavigator
) {
val baseUrl = mediaControllerViewModel.baseUrl
Expand All @@ -764,14 +766,12 @@ fun ArtistInfoScreen(
var showOnRefreshIndicator by remember { mutableStateOf(false) }

LaunchedEffect(key1 = Unit) {
if (artistInfoState.value.requiresReload) {
artistInfoViewModel.onArtistInfoUiEvent(
ArtistInfoUiEvent.OnLoadArtistInfo(artistHash)
)
} else if (currentArtistHash != artistHash) {
artistInfoViewModel.onArtistInfoUiEvent(
ArtistInfoUiEvent.OnUpdateArtistHash(artistHash)
)
if (artistInfoState.value.requiresReload || loadNewArtist) {
if (currentArtistHash != artistHash) {
artistInfoViewModel.onArtistInfoUiEvent(
ArtistInfoUiEvent.OnLoadArtistInfo(artistHash)
)
}
}
}

Expand All @@ -788,6 +788,9 @@ fun ArtistInfoScreen(
?: artistHash
)
)

Timber.e("Artist Hash VM: ${artistInfoState.value.infoResource.data?.artist?.artistHash}")
Timber.e("Artist Hash Nav: $artistHash")
},
) {
when (val res = artistInfoState.value.infoResource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.android.swingmusic.artist.presentation.viewmodel.ArtistInfoViewModel
import com.android.swingmusic.common.presentation.navigator.CommonNavigator
import com.android.swingmusic.core.domain.model.Album
Expand All @@ -33,6 +34,7 @@ import com.android.swingmusic.uicomponent.presentation.component.TrackItem
import com.android.swingmusic.uicomponent.presentation.theme.SwingMusicTheme
import com.android.swingmusic.uicomponent.presentation.theme.SwingMusicTheme_Preview
import com.ramcosta.composedestinations.annotation.Destination
import timber.log.Timber

@Composable
private fun ViewAll(
Expand Down Expand Up @@ -131,6 +133,7 @@ private fun ViewAll(
@Destination
@Composable
fun ViewAllScreen(
navController: NavController,
commonNavigator: CommonNavigator,
mediaControllerViewModel: MediaControllerViewModel,
artistInfoViewModel: ArtistInfoViewModel,
Expand All @@ -152,6 +155,8 @@ fun ViewAllScreen(
else -> null
}

Timber.e("View All Route: ${navController.currentDestination?.route}")

SwingMusicTheme {
ViewAll(
title = viewAllType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ interface CommonNavigator {
fun gotoArtistInfo(artistHash: String)

fun gotoViewAllScreen(viewAllType: String, artistName: String, baseUrl: String)

fun gotoSourceFolder(name: String, path: String)
}
Loading

0 comments on commit 343a7bc

Please sign in to comment.