Skip to content

Commit

Permalink
fix(ui): Fixed Spotify items page not showing correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbyESP committed Oct 2, 2024
1 parent 88571cb commit 4a2c4ff
Show file tree
Hide file tree
Showing 13 changed files with 489 additions and 516 deletions.
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

7 changes: 2 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,8 @@ dependencies {
ksp(libs.room.compiler)

//spotDL library
// implementation(libs.spotdl.android.library)
// implementation(libs.spotdl.android.ffmpeg)
implementation("com.github.BobbyESP.spotdl_android:library:3000")
implementation("com.github.BobbyESP.spotdl_android:ffmpeg:3000")
implementation("com.github.BobbyESP.spotdl_android:common:0.3.0-alpha.f51af0d")
implementation(libs.spotdl.android.library)
implementation(libs.spotdl.android.ffmpeg)

implementation(libs.spotify.api.android)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import androidx.navigation.navArgument
import androidx.navigation.navDeepLink
import androidx.navigation.navOptions
import androidx.navigation.navigation
import com.bobbyesp.library.SpotDL
import com.bobbyesp.library.domain.UpdateStatus
import com.bobbyesp.spowlo.App
import com.bobbyesp.spowlo.MainActivity
Expand All @@ -77,7 +76,7 @@ import com.bobbyesp.spowlo.ui.pages.download_tasks.FullscreenConsoleOutput
import com.bobbyesp.spowlo.ui.pages.downloader.DownloaderPage
import com.bobbyesp.spowlo.ui.pages.downloader.DownloaderViewModel
import com.bobbyesp.spowlo.ui.pages.history.DownloadsHistoryPage
import com.bobbyesp.spowlo.ui.pages.metadata_viewer.playlists.PlaylistPage
import com.bobbyesp.spowlo.ui.pages.metadata_viewer.playlists.SpotifyItemPage
import com.bobbyesp.spowlo.ui.pages.metadata_viewer.playlists.PlaylistPageViewModel
import com.bobbyesp.spowlo.ui.pages.mod_downloader.ModsDownloaderPage
import com.bobbyesp.spowlo.ui.pages.mod_downloader.ModsDownloaderViewModel
Expand Down Expand Up @@ -458,7 +457,7 @@ fun InitialEntry(
val type =
backStackEntry.arguments?.getString("type") ?: "SOMETHING WENT WRONG"

PlaylistPage(
SpotifyItemPage(
onBackPressed,
id = id,
type = type,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.bobbyesp.spowlo.ui.pages.metadata_viewer.pages
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
Expand All @@ -11,6 +12,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Download
Expand Down Expand Up @@ -44,66 +46,72 @@ fun AlbumPage(
) {
val localConfig = LocalConfiguration.current

Column(
LazyColumn(
modifier = modifier.fillMaxSize(),
contentPadding = PaddingValues(vertical = 8.dp, horizontal = 12.dp),
verticalArrangement = Arrangement.Top
) {
Box(
modifier = Modifier
.clip(MaterialTheme.shapes.extraSmall)
.fillMaxWidth()
.padding(bottom = 6.dp),
contentAlignment = Alignment.Center
) {
//calculate the image size based on the screen size and the aspect ratio as 1:1 (square) based on the height
val size = (localConfig.screenHeightDp / 3)
AsyncImageImpl(
item {
Box(
modifier = Modifier
.size(size.dp)
.aspectRatio(
1f, matchHeightConstraintsFirst = true
)
.clip(MaterialTheme.shapes.small),
model = data.images[0].url,
contentDescription = stringResource(id = R.string.track_artwork),
contentScale = ContentScale.Crop,
)
}

Column(
modifier = Modifier
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp, top = 8.dp)
) {
SelectionContainer {
MarqueeText(
text = data.name,
fontWeight = FontWeight.Bold,
style = MaterialTheme.typography.headlineMedium
)
}
Spacer(modifier = Modifier.height(6.dp))
SelectionContainer {
Text(
text = data.artists.joinToString(", ") { it.name },
style = MaterialTheme.typography.bodyMedium.copy(
fontWeight = FontWeight.Bold
),
modifier = Modifier.alpha(alpha = 0.8f)
.clip(MaterialTheme.shapes.extraSmall)
.fillMaxWidth()
.padding(bottom = 6.dp),
contentAlignment = Alignment.Center
) {
//calculate the image size based on the screen size and the aspect ratio as 1:1 (square) based on the height
val size = (localConfig.screenHeightDp / 3)
AsyncImageImpl(
modifier = Modifier
.size(size.dp)
.aspectRatio(
1f, matchHeightConstraintsFirst = true
)
.clip(MaterialTheme.shapes.small),
model = data.images[0].url,
contentDescription = stringResource(id = R.string.track_artwork),
contentScale = ContentScale.Crop,
)
}
Spacer(modifier = Modifier.height(6.dp))
SelectionContainer {
Text(
text = dataStringToString(
data = data.type, additional = data.releaseDate.year.toString(),
),
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.alpha(alpha = 0.8f)
)
}
item {
Column(
modifier = Modifier.padding(horizontal = 12.dp).padding(top = 6.dp),
) {
SelectionContainer {
MarqueeText(
text = data.name,
fontWeight = FontWeight.Bold,
style = MaterialTheme.typography.headlineMedium
)
}
Spacer(modifier = Modifier.height(6.dp))
SelectionContainer {
Text(
text = data.artists.joinToString(", ") { it.name },
style = MaterialTheme.typography.bodyMedium.copy(
fontWeight = FontWeight.Bold
),
modifier = Modifier.alpha(alpha = 0.8f)
)
}
Spacer(modifier = Modifier.height(6.dp))
SelectionContainer {
Text(
text = dataStringToString(
data = data.type, additional = data.releaseDate.year.toString(),
),
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.alpha(alpha = 0.8f)
)
}
}
}
item {
Spacer(modifier = Modifier.height(6.dp))
if (data.externalUrls.spotify != null) {
}
if (data.externalUrls.spotify != null) {
item {
Row(
modifier = Modifier
.fillMaxWidth()
Expand All @@ -127,30 +135,32 @@ fun AlbumPage(
}

}
HorizontalDivider(
modifier = Modifier.padding(
horizontal = 16.dp,
vertical = 12.dp
)
)
}
HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp))
if (data.tracks.size > 0) {
Column(
modifier = Modifier.fillMaxWidth()
) {
data.tracks.items.forEach { track ->
val taskName = StringBuilder().append(track.name).append(" - ").append(
track?.artists?.joinToString(", ") { it.name }).toString()
TrackComponent(
contentModifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp),
songName = track.name,
artists = track.artists.joinToString(", ") { it.name },
spotifyUrl = track.externalUrls.spotify ?: "",
isExplicit = track.explicit,
onClick = {
trackDownloadCallback(
track.externalUrls.spotify!!,
taskName
)
}
}
if (data.tracks.size > 0) {
items(data.tracks.items.size) { index ->
val track = data.tracks.items[index]
val taskName = StringBuilder().append(track.name).append(" - ").append(
track.artists.joinToString(", ") { it.name }).toString()
TrackComponent(
contentModifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp),
songName = track.name,
artists = track.artists.joinToString(", ") { it.name },
spotifyUrl = track.externalUrls.spotify ?: "",
isExplicit = track.explicit,
onClick = {
trackDownloadCallback(
track.externalUrls.spotify!!,
taskName
)
}
}
)
}
}
}
Expand Down
Loading

0 comments on commit 4a2c4ff

Please sign in to comment.