Skip to content

Commit

Permalink
Merge pull request #6 from nalgnaohel/frontend
Browse files Browse the repository at this point in the history
Frontend
  • Loading branch information
nalgnaohel authored Dec 8, 2024
2 parents a1baab3 + fd54f20 commit 93af6ee
Show file tree
Hide file tree
Showing 13 changed files with 429 additions and 154 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/test_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@ jobs:
run: chmod +x ./gradlew

- name: Execute Gradle command - unitTest
run: ./gradlew testDebugUnitTest
run: ./gradlew testDebugUnitTest --continue

- name: Upload Test Reports
if: ${{ always() }}
uses: actions/[email protected]
with:
name: test-reports
path: '**/build/reports/tests/'
158 changes: 82 additions & 76 deletions app/src/main/java/com/example/harmonyhub/HarmonyHubApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ import com.example.harmonyhub.ui.account.NewPasswordScreen
import com.example.harmonyhub.ui.account.RegisterScreen
import com.example.harmonyhub.ui.account.VerificationScreen
import com.example.harmonyhub.ui.components.Friend
import com.example.harmonyhub.ui.components.Song
import com.example.harmonyhub.ui.library.AddSongToPlaylistScreen
import com.example.harmonyhub.ui.library.AddToPlaylistFromSongScreen
import com.example.harmonyhub.ui.library.AlbumScreen
import com.example.harmonyhub.ui.library.ArtistScreen
import com.example.harmonyhub.ui.library.ChartsScreen
import com.example.harmonyhub.ui.library.PlaylistSongListScreen
import com.example.harmonyhub.ui.play.NowPlayingBar
import com.example.harmonyhub.ui.play.PlayScreen
Expand Down Expand Up @@ -93,7 +95,16 @@ enum class HarmonyHubScreen(@StringRes val title: Int, val icon: ImageVector) {
Friends(title = R.string.friends, icon = Icons.Default.AccountBox),
Album(title = R.string.album, icon = Icons.Default.AccountBox)
}
object CurrentSong{
var currentSong : Song? = null
fun get(): Song? {
return currentSong
}
fun set(tmp : Song?) {
currentSong = tmp
}

}
private val gradientBackground = Brush.verticalGradient(
colors = listOf(
Color(0xFF252525),
Expand Down Expand Up @@ -128,16 +139,17 @@ fun HarmonyHubApp(
)
) {
Column {
if (currentScreen != HarmonyHubScreen.AddToPlaylistFromSong)
// Kiểm tra nếu CurrentSong.currentSong không null
CurrentSong.currentSong?.let { currentSong ->
NowPlayingBar(
songName = "Closer",
artistName = "The Chainsmokers, Halsey",
song = currentSong,
isPlaying = true,
onPlayPauseClick = { /* Handle play/pause logic */ },
onNextClick = { /* Handle next song logic */ },
onPreviousClick = { /* Handle previous song logic */ },
onBarClick = { navController.navigate(HarmonyHubScreen.Play.name) }
onBarClick = { /* Handle bar click logic */ }
)
}
BottomNavigationBar(navController = navController)
}
}
Expand Down Expand Up @@ -213,17 +225,17 @@ fun HarmonyHubApp(
)
}
composable(
route = "Play?index={SongRepository.currentPLaylist.indexOf(song)}",
route = "Play?index={SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong)}",
arguments = listOf(
navArgument(name = "SongRepository.currentPLaylist.indexOf(song)") {
navArgument(name = "SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong)") {
type = NavType.IntType
defaultValue= 0
}
)
) { backStackEntry ->
PlayScreen(
index = backStackEntry.arguments?.getInt("SongRepository.currentPLaylist.indexOf(song)"),
onBackButtonClicked = { navController.popBackStack() }
index = backStackEntry.arguments?.getInt("SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong)"),
onBackButtonClicked = { searchNavController.popBackStack() }
)
}
}
Expand Down Expand Up @@ -275,16 +287,16 @@ fun HarmonyHubApp(
)
}
composable(
route = "Play?index={SongRepository.currentPLaylist.indexOf(song)}",
route = "Play?index={SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong)}",
arguments = listOf(
navArgument(name = "SongRepository.currentPLaylist.indexOf(song)") {
navArgument(name = "SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong)") {
type = NavType.IntType
defaultValue= 0
}
)
) { backStackEntry ->
PlayScreen(
index = backStackEntry.arguments?.getInt("SongRepository.currentPLaylist.indexOf(song)"),
index = backStackEntry.arguments?.getInt("SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong)"),
onBackButtonClicked = { navController.popBackStack() }
)
}
Expand Down Expand Up @@ -463,18 +475,19 @@ fun HarmonyHubApp(
)

}
composable(route = HarmonyHubScreen.Album.name) {
AlbumScreen(
onShareClicked = {},
onDownloadClicked = {},
onSongClick = {
},
onBackButtonClicked = {},
onAddToPlaylistClicked = {},
onAddToFavoriteClicked = {}
)

}
// composable(route = HarmonyHubScreen.Album.name) {
// AlbumScreen(
// idAlbum ="",
// onShareClicked = {},
// onDownloadClicked = {},
// onSongClick = {
// },
// onBackButtonClicked = {},
// onAddToPlaylistClicked = {},
// onAddToFavoriteClicked = {}
// )
//
// }


}
Expand Down Expand Up @@ -619,16 +632,16 @@ fun Nav3(
)
}
composable(
route = "Artist?name={artist.name}",
route = "Artist?name={artist.id}",
arguments = listOf(
navArgument(name = "artist.name") {
navArgument(name = "artist.id") {
type = NavType.StringType
nullable = true
}
)
) { backStackEntry ->
ArtistScreen(
myArtist = backStackEntry.arguments?.getString("artist.name"),
myArtist = backStackEntry.arguments?.getString("artist.id"),
onSongClick = {},
onBackButtonClicked = {
navController.popBackStack() // Quay lại ArtistsFollowing
Expand All @@ -650,71 +663,64 @@ fun Nav3(
}
)
}
}
}
@Composable
fun Nav4(
parentNavController: NavHostController,
authenticationMainViewModel: AuthenticationViewModel = hiltViewModel()
) {
val navController = rememberNavController()
NavHost(navController = navController, startDestination = "Library") {
composable(route = "Library") {
LibraryScreen(
onProfileButtonClicked = {
parentNavController.navigate(HarmonyHubScreen.Profile.name)
},
onViewAllRecentCLicked = {
parentNavController.navigate(HarmonyHubScreen.History.name)
},
onFavoriteButtonClicked = {
parentNavController.navigate(HarmonyHubScreen.Favorite.name)
},
onDownloadButtonClicked = {
parentNavController.navigate(HarmonyHubScreen.Download.name)
},
onPlaylistButtonClicked = {
parentNavController.navigate(HarmonyHubScreen.Playlist.name)
},
onArtistsFollowingButtonClicked = {
parentNavController.navigate(HarmonyHubScreen.ArtistsFollowing.name)
},
onLogoutButtonClicked = {
authenticationMainViewModel.signOut()
parentNavController.navigate(HarmonyHubScreen.Login.name)
},
onSettingsButtonClicked = {
parentNavController.navigate(HarmonyHubScreen.Settings.name)
},
onPlaySongClicked = {
parentNavController.navigate(HarmonyHubScreen.Play.name)
},
onAddToPlaylistClicked = {
parentNavController.navigate(HarmonyHubScreen.AddToPlaylistFromSong.name)
},
onAddToFavoriteClicked = { /* Handle add to favorite logic */ },
onShareClicked = { /* Handle share logic */ },
onDownloadClicked = { /* Handle download logic */ },
onDeleteClicked = { /* Handle delete logic */ },
navController = navController
composable(
route = "Album?name={album.id}",
arguments = listOf(
navArgument(name = "album.id") {
type = NavType.StringType
nullable = true
}
)
) { backStackEntry ->
AlbumScreen(
idAlbum = backStackEntry.arguments?.getString("album.id"),
onShareClicked = {},
onDownloadClicked = {},
onSongClick = {
},
onBackButtonClicked = {navController.popBackStack()},
onAddToPlaylistClicked = {},
onAddToFavoriteClicked = {}
)
}
composable(
route = "Play?index={SongRepository.currentPLaylist.indexOf(song)}&tmpPlaylist={SongRepository.currentPLaylist}",
route = "Charts?name={chart.id}",
arguments = listOf(
navArgument(name = "SongRepository.currentPLaylist.indexOf(song)") {
navArgument(name = "chart.id") {
type = NavType.StringType
nullable = true
}
)
) { backStackEntry ->
ChartsScreen(
idCharts = backStackEntry.arguments?.getString("chart.id"),
onShareClicked = {},
onDownloadClicked = {},
onSongClick = {
},
onBackButtonClicked = {navController.popBackStack()},
onAddToPlaylistClicked = {},
onAddToFavoriteClicked = {}
)
}

composable(
route = "Play?index={SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong)}",
arguments = listOf(
navArgument(name = "SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong)") {
type = NavType.IntType
defaultValue= 0
}
)
) { backStackEntry ->
PlayScreen(
index = backStackEntry.arguments?.getInt("SongRepository.currentPLaylist.indexOf(song)"),
index = backStackEntry.arguments?.getInt("SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong)"),
onBackButtonClicked = { navController.popBackStack() }
)
}
}
}

//@OptIn(ExperimentalMaterial3Api::class)
//@Composable
//fun HarmonyHubAppbar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DefaultHomeScreenRepo : HomeScreenRepo {
val request = Request.Builder()
.url("https://spotify-scraper.p.rapidapi.com/v1/home")
.get()
.addHeader("x-rapidapi-key", "89644839e0mshcae86286ffb46fcp1e2f10jsn5dacb407fc3b")
.addHeader("x-rapidapi-key", "bc05c5534fmsh8fb5f0a628eb2c8p1262e2jsn9a210e841cc1")
.addHeader("x-rapidapi-host", "spotify-scraper.p.rapidapi.com")
.build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import coil.request.ImageRequest
import com.example.harmonyhub.ui.theme.NotoSans

@Composable
fun AlbumCard(songName: String, albumImg: String, id : String, listArtist: List<String>) {
fun AlbumCard(songName: String, albumImg: String, id : String, listArtist: List<String>, onAlbumCardClick: () -> Unit) {
Surface(
modifier = Modifier
.size(width = 125.dp, height = 180.dp)
.clickable { }
.clickable {onAlbumCardClick() }
.testTag("AlbumCard"),
color = Color.Transparent
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import coil.request.ImageRequest
import com.example.harmonyhub.ui.theme.NotoSans

@Composable
fun ChartCard(chartImg: String?, chartName: String, chartId: String) {
fun ChartCard(chartImg: String?, chartName: String, chartId: String, onChartClicked : () -> Unit) {
Surface(
modifier = Modifier
.size(width = 150.dp, height = 150.dp)
.clickable { },
.clickable {onChartClicked() },
color = Color.Transparent
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import com.example.harmonyhub.R
import com.example.harmonyhub.ui.theme.NotoSans

@Composable
fun SuggestionCard(songName: String, artistName: String, songId: String, songImg: String) {
fun SuggestionCard(songName: String, artistName: String, songId: String, songImg: String, onSongClicked: () ->Unit ) {
Surface(
modifier = Modifier
.size(width = 125.dp, height = 180.dp)
.clickable { },
.clickable { onSongClicked() },
color = Color.Transparent
) {
Column(modifier = Modifier.padding(4.dp))
Expand Down
Loading

0 comments on commit 93af6ee

Please sign in to comment.