@@ -54,10 +54,12 @@ import com.example.harmonyhub.ui.account.NewPasswordScreen
54
54
import com.example.harmonyhub.ui.account.RegisterScreen
55
55
import com.example.harmonyhub.ui.account.VerificationScreen
56
56
import com.example.harmonyhub.ui.components.Friend
57
+ import com.example.harmonyhub.ui.components.Song
57
58
import com.example.harmonyhub.ui.library.AddSongToPlaylistScreen
58
59
import com.example.harmonyhub.ui.library.AddToPlaylistFromSongScreen
59
60
import com.example.harmonyhub.ui.library.AlbumScreen
60
61
import com.example.harmonyhub.ui.library.ArtistScreen
62
+ import com.example.harmonyhub.ui.library.ChartsScreen
61
63
import com.example.harmonyhub.ui.library.PlaylistSongListScreen
62
64
import com.example.harmonyhub.ui.play.NowPlayingBar
63
65
import com.example.harmonyhub.ui.play.PlayScreen
@@ -93,7 +95,16 @@ enum class HarmonyHubScreen(@StringRes val title: Int, val icon: ImageVector) {
93
95
Friends (title = R .string.friends, icon = Icons .Default .AccountBox ),
94
96
Album (title = R .string.album, icon = Icons .Default .AccountBox )
95
97
}
98
+ object CurrentSong{
99
+ var currentSong : Song ? = null
100
+ fun get (): Song ? {
101
+ return currentSong
102
+ }
103
+ fun set (tmp : Song ? ) {
104
+ currentSong = tmp
105
+ }
96
106
107
+ }
97
108
private val gradientBackground = Brush .verticalGradient(
98
109
colors = listOf (
99
110
Color (0xFF252525 ),
@@ -128,16 +139,17 @@ fun HarmonyHubApp(
128
139
)
129
140
) {
130
141
Column {
131
- if (currentScreen != HarmonyHubScreen .AddToPlaylistFromSong )
142
+ // Kiểm tra nếu CurrentSong.currentSong không null
143
+ CurrentSong .currentSong?.let { currentSong ->
132
144
NowPlayingBar (
133
- songName = " Closer" ,
134
- artistName = " The Chainsmokers, Halsey" ,
145
+ song = currentSong,
135
146
isPlaying = true ,
136
147
onPlayPauseClick = { /* Handle play/pause logic */ },
137
148
onNextClick = { /* Handle next song logic */ },
138
149
onPreviousClick = { /* Handle previous song logic */ },
139
- onBarClick = { navController.navigate( HarmonyHubScreen . Play .name) }
150
+ onBarClick = { /* Handle bar click logic */ }
140
151
)
152
+ }
141
153
BottomNavigationBar (navController = navController)
142
154
}
143
155
}
@@ -213,17 +225,17 @@ fun HarmonyHubApp(
213
225
)
214
226
}
215
227
composable(
216
- route = " Play?index={SongRepository.currentPLaylist.indexOf(song )}" ,
228
+ route = " Play?index={SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong )}" ,
217
229
arguments = listOf (
218
- navArgument(name = " SongRepository.currentPLaylist.indexOf(song )" ) {
230
+ navArgument(name = " SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong )" ) {
219
231
type = NavType .IntType
220
232
defaultValue= 0
221
233
}
222
234
)
223
235
) { backStackEntry ->
224
236
PlayScreen (
225
- index = backStackEntry.arguments?.getInt(" SongRepository.currentPLaylist.indexOf(song )" ),
226
- onBackButtonClicked = { navController .popBackStack() }
237
+ index = backStackEntry.arguments?.getInt(" SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong )" ),
238
+ onBackButtonClicked = { searchNavController .popBackStack() }
227
239
)
228
240
}
229
241
}
@@ -275,16 +287,16 @@ fun HarmonyHubApp(
275
287
)
276
288
}
277
289
composable(
278
- route = " Play?index={SongRepository.currentPLaylist.indexOf(song )}" ,
290
+ route = " Play?index={SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong )}" ,
279
291
arguments = listOf (
280
- navArgument(name = " SongRepository.currentPLaylist.indexOf(song )" ) {
292
+ navArgument(name = " SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong )" ) {
281
293
type = NavType .IntType
282
294
defaultValue= 0
283
295
}
284
296
)
285
297
) { backStackEntry ->
286
298
PlayScreen (
287
- index = backStackEntry.arguments?.getInt(" SongRepository.currentPLaylist.indexOf(song )" ),
299
+ index = backStackEntry.arguments?.getInt(" SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong )" ),
288
300
onBackButtonClicked = { navController.popBackStack() }
289
301
)
290
302
}
@@ -463,18 +475,19 @@ fun HarmonyHubApp(
463
475
)
464
476
465
477
}
466
- composable(route = HarmonyHubScreen .Album .name) {
467
- AlbumScreen (
468
- onShareClicked = {},
469
- onDownloadClicked = {},
470
- onSongClick = {
471
- },
472
- onBackButtonClicked = {},
473
- onAddToPlaylistClicked = {},
474
- onAddToFavoriteClicked = {}
475
- )
476
-
477
- }
478
+ // composable(route = HarmonyHubScreen.Album.name) {
479
+ // AlbumScreen(
480
+ // idAlbum ="",
481
+ // onShareClicked = {},
482
+ // onDownloadClicked = {},
483
+ // onSongClick = {
484
+ // },
485
+ // onBackButtonClicked = {},
486
+ // onAddToPlaylistClicked = {},
487
+ // onAddToFavoriteClicked = {}
488
+ // )
489
+ //
490
+ // }
478
491
479
492
480
493
}
@@ -619,16 +632,16 @@ fun Nav3(
619
632
)
620
633
}
621
634
composable(
622
- route = " Artist?name={artist.name }" ,
635
+ route = " Artist?name={artist.id }" ,
623
636
arguments = listOf (
624
- navArgument(name = " artist.name " ) {
637
+ navArgument(name = " artist.id " ) {
625
638
type = NavType .StringType
626
639
nullable = true
627
640
}
628
641
)
629
642
) { backStackEntry ->
630
643
ArtistScreen (
631
- myArtist = backStackEntry.arguments?.getString(" artist.name " ),
644
+ myArtist = backStackEntry.arguments?.getString(" artist.id " ),
632
645
onSongClick = {},
633
646
onBackButtonClicked = {
634
647
navController.popBackStack() // Quay lại ArtistsFollowing
@@ -650,71 +663,64 @@ fun Nav3(
650
663
}
651
664
)
652
665
}
653
- }
654
- }
655
- @Composable
656
- fun Nav4 (
657
- parentNavController : NavHostController ,
658
- authenticationMainViewModel : AuthenticationViewModel = hiltViewModel()
659
- ) {
660
- val navController = rememberNavController()
661
- NavHost (navController = navController, startDestination = " Library" ) {
662
- composable(route = " Library" ) {
663
- LibraryScreen (
664
- onProfileButtonClicked = {
665
- parentNavController.navigate(HarmonyHubScreen .Profile .name)
666
- },
667
- onViewAllRecentCLicked = {
668
- parentNavController.navigate(HarmonyHubScreen .History .name)
669
- },
670
- onFavoriteButtonClicked = {
671
- parentNavController.navigate(HarmonyHubScreen .Favorite .name)
672
- },
673
- onDownloadButtonClicked = {
674
- parentNavController.navigate(HarmonyHubScreen .Download .name)
675
- },
676
- onPlaylistButtonClicked = {
677
- parentNavController.navigate(HarmonyHubScreen .Playlist .name)
678
- },
679
- onArtistsFollowingButtonClicked = {
680
- parentNavController.navigate(HarmonyHubScreen .ArtistsFollowing .name)
681
- },
682
- onLogoutButtonClicked = {
683
- authenticationMainViewModel.signOut()
684
- parentNavController.navigate(HarmonyHubScreen .Login .name)
685
- },
686
- onSettingsButtonClicked = {
687
- parentNavController.navigate(HarmonyHubScreen .Settings .name)
688
- },
689
- onPlaySongClicked = {
690
- parentNavController.navigate(HarmonyHubScreen .Play .name)
691
- },
692
- onAddToPlaylistClicked = {
693
- parentNavController.navigate(HarmonyHubScreen .AddToPlaylistFromSong .name)
694
- },
695
- onAddToFavoriteClicked = { /* Handle add to favorite logic */ },
696
- onShareClicked = { /* Handle share logic */ },
697
- onDownloadClicked = { /* Handle download logic */ },
698
- onDeleteClicked = { /* Handle delete logic */ },
699
- navController = navController
666
+ composable(
667
+ route = " Album?name={album.id}" ,
668
+ arguments = listOf (
669
+ navArgument(name = " album.id" ) {
670
+ type = NavType .StringType
671
+ nullable = true
672
+ }
673
+ )
674
+ ) { backStackEntry ->
675
+ AlbumScreen (
676
+ idAlbum = backStackEntry.arguments?.getString(" album.id" ),
677
+ onShareClicked = {},
678
+ onDownloadClicked = {},
679
+ onSongClick = {
680
+ },
681
+ onBackButtonClicked = {navController.popBackStack()},
682
+ onAddToPlaylistClicked = {},
683
+ onAddToFavoriteClicked = {}
700
684
)
701
685
}
702
686
composable(
703
- route = " Play?index={SongRepository.currentPLaylist.indexOf(song)}&tmpPlaylist={SongRepository.currentPLaylist }" ,
687
+ route = " Charts?name={chart.id }" ,
704
688
arguments = listOf (
705
- navArgument(name = " SongRepository.currentPLaylist.indexOf(song)" ) {
689
+ navArgument(name = " chart.id" ) {
690
+ type = NavType .StringType
691
+ nullable = true
692
+ }
693
+ )
694
+ ) { backStackEntry ->
695
+ ChartsScreen (
696
+ idCharts = backStackEntry.arguments?.getString(" chart.id" ),
697
+ onShareClicked = {},
698
+ onDownloadClicked = {},
699
+ onSongClick = {
700
+ },
701
+ onBackButtonClicked = {navController.popBackStack()},
702
+ onAddToPlaylistClicked = {},
703
+ onAddToFavoriteClicked = {}
704
+ )
705
+ }
706
+
707
+ composable(
708
+ route = " Play?index={SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong)}" ,
709
+ arguments = listOf (
710
+ navArgument(name = " SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong)" ) {
706
711
type = NavType .IntType
707
712
defaultValue= 0
708
713
}
709
714
)
710
715
) { backStackEntry ->
711
716
PlayScreen (
712
- index = backStackEntry.arguments?.getInt(" SongRepository.currentPLaylist.indexOf(song )" ),
717
+ index = backStackEntry.arguments?.getInt(" SongRepository.currentPLaylist.indexOf(CurrentSong.currentSong )" ),
713
718
onBackButtonClicked = { navController.popBackStack() }
714
719
)
715
720
}
716
721
}
717
722
}
723
+
718
724
// @OptIn(ExperimentalMaterial3Api::class)
719
725
// @Composable
720
726
// fun HarmonyHubAppbar(
0 commit comments