Skip to content

Commit

Permalink
Merge pull request #36 from musicorum-app/dev
Browse files Browse the repository at this point in the history
update to 1.24 (89)
  • Loading branch information
MysteryMS authored Dec 26, 2023
2 parents 2776b48 + 7692d27 commit 44f596d
Show file tree
Hide file tree
Showing 24 changed files with 701 additions and 292 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ android {
applicationId "io.musicorum.mobile"
minSdk 28
targetSdk 34
versionCode 68
versionName "1.23-release"
versionCode 69
versionName "1.24"
//compileSdkPreview = "UpsideDownCake"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -79,6 +79,7 @@ android {
ndk {
debugSymbolLevel = "SYMBOL_TABLE"
}
versionNameSuffix = "-release"
}
debug {
versionNameSuffix '-debug'
Expand Down
54 changes: 35 additions & 19 deletions app/src/main/java/io/musicorum/mobile/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutHorizontally
Expand Down Expand Up @@ -74,13 +76,12 @@ import io.musicorum.mobile.utils.LocalSnackbar
import io.musicorum.mobile.utils.LocalSnackbarContext
import io.musicorum.mobile.utils.MessagingService
import io.musicorum.mobile.views.Account
import io.musicorum.mobile.views.Collage
import io.musicorum.mobile.views.Discover
import io.musicorum.mobile.views.Home
import io.musicorum.mobile.views.RecentScrobbles
import io.musicorum.mobile.views.Scrobbling
import io.musicorum.mobile.views.charts.BaseChartDetail
import io.musicorum.mobile.views.charts.Charts
import io.musicorum.mobile.views.collage.Collage
import io.musicorum.mobile.views.home.Home
import io.musicorum.mobile.views.individual.Album
import io.musicorum.mobile.views.individual.AlbumTracklist
import io.musicorum.mobile.views.individual.Artist
Expand All @@ -90,6 +91,7 @@ import io.musicorum.mobile.views.individual.Track
import io.musicorum.mobile.views.individual.User
import io.musicorum.mobile.views.login.loginGraph
import io.musicorum.mobile.views.mostListened.MostListened
import io.musicorum.mobile.views.scrobbling.Scrobbling
import io.musicorum.mobile.views.settings.PendingScrobbles
import io.musicorum.mobile.views.settings.ScrobbleSettings
import io.musicorum.mobile.views.settings.Settings
Expand Down Expand Up @@ -240,15 +242,11 @@ class MainActivity : ComponentActivity() {
onDispose { }
}

val bottomBarDestinations =
listOf("home", "scrobbling", "profile", "charts", "discover")
val showNav =
when (navController.currentBackStackEntryAsState().value?.destination?.route) {
"home" -> true
"scrobbling" -> true
"profile" -> true
"charts" -> true
"discover" -> true
else -> false
}
navController.currentBackStackEntryAsState().value?.destination?.route in bottomBarDestinations


CompositionLocalProvider(
LocalSnackbar provides LocalSnackbarContext(snackHostState),
Expand All @@ -274,26 +272,44 @@ class MainActivity : ComponentActivity() {
.padding(pv)
) {
val animationCurve = CubicBezierEasing(0.76f, 0f, 0.24f, 1f)
val newRoute = navController.currentBackStackEntry?.destination?.route
NavHost(
navController = navController,
startDestination = "home",
enterTransition = { slideInHorizontally(tween(350)) { fullWidth -> fullWidth } },
exitTransition = { slideOutHorizontally(tween(350)) { fullWidth -> -fullWidth / 2 } },
enterTransition = {
if (newRoute in bottomBarDestinations) {
fadeIn(tween(200))
} else {
slideInHorizontally(tween(350)) { fullWidth -> fullWidth }
}
},
exitTransition = {
if (newRoute in bottomBarDestinations) {
fadeOut(tween(200))
} else {
slideOutHorizontally(tween(350)) { fullWidth -> -fullWidth / 2 }
}
},
popExitTransition = {
slideOutHorizontally(
tween(
500,
easing = animationCurve
)
) { fullWidth -> fullWidth }

},
popEnterTransition = {
slideInHorizontally(
tween(
500,
easing = animationCurve
if (newRoute in bottomBarDestinations) {
fadeIn(tween(200))
} else {
slideInHorizontally(
tween(
500,
easing = animationCurve
)
)
)
}
}
) {
/* WIP val views =
Expand Down Expand Up @@ -325,7 +341,7 @@ class MainActivity : ComponentActivity() {
}
)
) {
Collage(args = it.arguments!!)
Collage()
}

composable(
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/io/musicorum/mobile/router/BottomNavbar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fun BottomNavBar(nav: NavHostController) {
Icons.Rounded.Person
)
val navItemColors = NavigationBarItemDefaults.colors(
indicatorColor = MostlyRed.copy(alpha = 0.5f),
indicatorColor = MostlyRed,
selectedIconColor = Color.White,
selectedTextColor = Color.White
)
Expand All @@ -49,7 +49,7 @@ fun BottomNavBar(nav: NavHostController) {
items.forEachIndexed { index, s ->
NavigationBarItem(
selected = currentDestination?.hierarchy?.any { it.route?.lowercase() == s.lowercase() } == true,
label = { Text(text = s) },
label = { Text(text = s, maxLines = 1) },
onClick = {
nav.navigate(s.lowercase(Locale.ROOT))
{
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/io/musicorum/mobile/router/Controller.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import io.musicorum.mobile.views.Account
import io.musicorum.mobile.views.Discover
import io.musicorum.mobile.views.Home
import io.musicorum.mobile.views.RecentScrobbles
import io.musicorum.mobile.views.Scrobbling
import io.musicorum.mobile.views.charts.Charts
import io.musicorum.mobile.views.home.Home
import io.musicorum.mobile.views.individual.Album
import io.musicorum.mobile.views.individual.Track
import io.musicorum.mobile.views.individual.User
import io.musicorum.mobile.views.login.loginGraph
import io.musicorum.mobile.views.scrobbling.Scrobbling

private val startTransition = slideInHorizontally(tween(800)) { fullWidth -> fullWidth }
private val exitTransition = slideOutHorizontally(tween(800)) { fullWidth -> -fullWidth / 2 }
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/io/musicorum/mobile/viewmodels/DiscoverVm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import androidx.lifecycle.viewModelScope
import io.musicorum.mobile.ktor.endpoints.AlbumEndpoint
import io.musicorum.mobile.ktor.endpoints.ArtistEndpoint
import io.musicorum.mobile.ktor.endpoints.TrackEndpoint
import io.musicorum.mobile.ktor.endpoints.UserEndpoint
import io.musicorum.mobile.ktor.endpoints.musicorum.MusicorumAlbumEndpoint
import io.musicorum.mobile.ktor.endpoints.musicorum.MusicorumArtistEndpoint
import io.musicorum.mobile.ktor.endpoints.musicorum.MusicorumTrackEndpoint
import io.musicorum.mobile.serialization.SearchTrack
import io.musicorum.mobile.serialization.User
import io.musicorum.mobile.serialization.entities.Album
import io.musicorum.mobile.serialization.entities.Artist
import kotlinx.coroutines.async
Expand All @@ -26,7 +28,7 @@ class DiscoverVm : ViewModel() {
val trackResults = MutableLiveData<List<SearchTrack>>(emptyList())
val albumResults = MutableLiveData<List<Album>>(emptyList())
val artistResults = MutableLiveData<List<Artist>>(emptyList())

val userResult = MutableLiveData<List<User>>(null)

fun updateQuery(value: String) {
query.value = value
Expand Down Expand Up @@ -99,6 +101,13 @@ class DiscoverVm : ViewModel() {
artistResults.value = list
}
}
},

async {
val res = UserEndpoint.getUser(query.value!!)
res?.let {
userResult.value = listOf(it)
}
}
)
busy.value = false
Expand Down
53 changes: 44 additions & 9 deletions app/src/main/java/io/musicorum/mobile/views/Discover.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package io.musicorum.mobile.views

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Album
import androidx.compose.material.icons.rounded.Audiotrack
import androidx.compose.material.icons.rounded.Person
import androidx.compose.material.icons.rounded.Search
import androidx.compose.material.icons.rounded.Star
import androidx.compose.material3.DockedSearchBar
Expand All @@ -18,22 +22,29 @@ import androidx.compose.material3.ListItem
import androidx.compose.material3.SearchBarDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import coil.compose.AsyncImage
import io.musicorum.mobile.LocalNavigation
import io.musicorum.mobile.R
import io.musicorum.mobile.coil.PlaceholderType
import io.musicorum.mobile.coil.defaultImageRequestBuilder
import io.musicorum.mobile.components.AlbumListItem
import io.musicorum.mobile.components.ArtistListItem
import io.musicorum.mobile.components.CenteredLoadingSpinner
import io.musicorum.mobile.components.TrackListItem
import io.musicorum.mobile.router.Routes
import io.musicorum.mobile.ui.theme.ContentSecondary
import io.musicorum.mobile.ui.theme.KindaBlack
import io.musicorum.mobile.ui.theme.LighterGray
Expand All @@ -48,10 +59,12 @@ fun Discover(viewModel: DiscoverVm = viewModel()) {
val artists = viewModel.artistResults.observeAsState(emptyList()).value
val tracks = viewModel.trackResults.observeAsState(emptyList()).value
val albums = viewModel.albumResults.observeAsState(emptyList()).value
val users by viewModel.userResult.observeAsState(emptyList())
val searchBarColors = SearchBarDefaults.colors(
containerColor = LighterGray
)
val busy = viewModel.busy.observeAsState(false).value
val nav = LocalNavigation.current


Column(
Expand Down Expand Up @@ -96,9 +109,8 @@ fun Discover(viewModel: DiscoverVm = viewModel()) {
results = tracks.size,
icon = Icons.Rounded.Audiotrack
)
if (tracks.isEmpty()) {
Text(stringResource(R.string.no_results))
} else {

if (tracks.isNotEmpty()) {
tracks.take(4).forEach {
TrackListItem(track = it)
}
Expand All @@ -109,9 +121,7 @@ fun Discover(viewModel: DiscoverVm = viewModel()) {
results = albums.size,
icon = Icons.Outlined.Album
)
if (albums.isEmpty()) {
Text(stringResource(R.string.no_results))
} else {
if (albums.isNotEmpty()) {
albums.take(4).forEach {
AlbumListItem(it)
}
Expand All @@ -122,13 +132,38 @@ fun Discover(viewModel: DiscoverVm = viewModel()) {
results = artists.size,
icon = Icons.Rounded.Star
)
if (artists.isEmpty()) {
Text(stringResource(R.string.no_results))
} else {
if (artists.isNotEmpty()) {
artists.take(4).forEach {
ArtistListItem(artist = it)
}
}

Header(
title = "Users",
results = users.size,
icon = Icons.Rounded.Person
)
if (users.isNotEmpty()) {
val model = defaultImageRequestBuilder(
url = users.first().user.bestImageUrl,
PlaceholderType.USER
)
ListItem(
headlineContent = { Text(users.first().user.name) },
leadingContent = {
AsyncImage(
model = model,
contentDescription = null,
modifier = Modifier
.size(50.dp)
.clip(CircleShape)
)
},
modifier = Modifier.clickable {
nav?.navigate(Routes.user(users.first().user.name))
}
)
}
}
}

Expand Down
Loading

0 comments on commit 44f596d

Please sign in to comment.