Skip to content

Commit 3bbf755

Browse files
authored
Merge pull request #69 from swingmx/search
`:search` Add View More on Search Results
2 parents 007e306 + fc63f52 commit 3bbf755

File tree

22 files changed

+820
-143
lines changed

22 files changed

+820
-143
lines changed

app/src/main/java/com/android/swingmusic/presentation/activity/MainActivity.kt

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import androidx.navigation.compose.currentBackStackEntryAsState
5151
import androidx.navigation.compose.rememberNavController
5252
import com.android.swingmusic.album.presentation.screen.destinations.AllAlbumScreenDestination
5353
import com.android.swingmusic.artist.presentation.screen.destinations.AllArtistsScreenDestination
54-
import com.android.swingmusic.artist.presentation.screen.destinations.ViewAllScreenDestination
54+
import com.android.swingmusic.artist.presentation.screen.destinations.ViewAllScreenOnArtistDestination
5555
import com.android.swingmusic.artist.presentation.viewmodel.ArtistInfoViewModel
5656
import com.android.swingmusic.auth.data.workmanager.scheduleTokenRefreshWork
5757
import com.android.swingmusic.auth.presentation.screen.destinations.LoginWithQrCodeDestination
@@ -64,8 +64,15 @@ import com.android.swingmusic.player.presentation.screen.MiniPlayer
6464
import com.android.swingmusic.player.presentation.screen.destinations.NowPlayingScreenDestination
6565
import com.android.swingmusic.player.presentation.screen.destinations.QueueScreenDestination
6666
import com.android.swingmusic.player.presentation.viewmodel.MediaControllerViewModel
67-
import com.android.swingmusic.presentation.navigator.*
67+
import com.android.swingmusic.presentation.navigator.BottomNavItem
68+
import com.android.swingmusic.presentation.navigator.CoreNavigator
69+
import com.android.swingmusic.presentation.navigator.NavGraphs
70+
import com.android.swingmusic.presentation.navigator.scaleInEnterTransition
71+
import com.android.swingmusic.presentation.navigator.scaleInPopEnterTransition
72+
import com.android.swingmusic.presentation.navigator.scaleOutExitTransition
73+
import com.android.swingmusic.presentation.navigator.scaleOutPopExitTransition
6874
import com.android.swingmusic.search.presentation.screen.destinations.SearchScreenDestination
75+
import com.android.swingmusic.search.presentation.screen.destinations.ViewAllSearchResultsDestination
6976
import com.android.swingmusic.service.PlaybackService
7077
import com.android.swingmusic.service.SessionTokenManager
7178
import com.android.swingmusic.uicomponent.presentation.theme.SwingMusicTheme
@@ -176,10 +183,18 @@ class MainActivity : ComponentActivity() {
176183
"player/${QueueScreenDestination.route}",
177184

178185
// Hide mini player in view all screen
179-
"player/${ViewAllScreenDestination.route}",
180-
"folder/${ViewAllScreenDestination.route}",
181-
"album/${ViewAllScreenDestination.route}",
182-
"artist/${ViewAllScreenDestination.route}",
186+
"player/${ViewAllScreenOnArtistDestination.route}",
187+
"folder/${ViewAllScreenOnArtistDestination.route}",
188+
"album/${ViewAllScreenOnArtistDestination.route}",
189+
"artist/${ViewAllScreenOnArtistDestination.route}",
190+
"search/${ViewAllScreenOnArtistDestination.route}",
191+
192+
"player/${ViewAllSearchResultsDestination.route}",
193+
"folder/${ViewAllSearchResultsDestination.route}",
194+
"album/${ViewAllSearchResultsDestination.route}",
195+
"artist/${ViewAllSearchResultsDestination.route}",
196+
"search/${ViewAllSearchResultsDestination.route}",
197+
"search/${ViewAllSearchResultsDestination.route}",
183198

184199
// Hide mini player in queue screen
185200
"folder/${QueueScreenDestination.route}",

app/src/main/java/com/android/swingmusic/presentation/navigator/CoreNavigator.kt

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import androidx.navigation.NavController
44
import androidx.navigation.NavOptionsBuilder
55
import com.android.swingmusic.album.presentation.screen.destinations.AlbumWithInfoScreenDestination
66
import com.android.swingmusic.artist.presentation.screen.destinations.ArtistInfoScreenDestination
7-
import com.android.swingmusic.artist.presentation.screen.destinations.ViewAllScreenDestination
7+
import com.android.swingmusic.artist.presentation.screen.destinations.ViewAllScreenOnArtistDestination
88
import com.android.swingmusic.auth.presentation.screen.destinations.LoginWithQrCodeDestination
99
import com.android.swingmusic.auth.presentation.screen.destinations.LoginWithUsernameScreenDestination
1010
import com.android.swingmusic.auth.presentation.viewmodel.AuthViewModel
1111
import com.android.swingmusic.common.presentation.navigator.CommonNavigator
1212
import com.android.swingmusic.folder.presentation.screen.destinations.FoldersAndTracksScreenDestination
1313
import com.android.swingmusic.player.presentation.screen.destinations.QueueScreenDestination
1414
import com.android.swingmusic.player.presentation.viewmodel.MediaControllerViewModel
15+
import com.android.swingmusic.search.presentation.screen.destinations.ViewAllSearchResultsDestination
1516
import com.ramcosta.composedestinations.dynamic.within
1617
import com.ramcosta.composedestinations.navigation.navigate
1718
import com.ramcosta.composedestinations.spec.NavGraphSpec
@@ -157,14 +158,36 @@ class CoreNavigator(
157158
}
158159
}
159160

160-
override fun gotoViewAllScreen(
161+
override fun gotoViewAllOnArtistScreen(
161162
viewAllType: String,
162163
artistName: String,
163164
baseUrl: String
164165
) {
165166
val currentDestination = navController.currentDestination?.route
166167
val targetDestination =
167-
ViewAllScreenDestination(viewAllType, artistName, baseUrl)
168+
ViewAllScreenOnArtistDestination(viewAllType, artistName, baseUrl)
169+
170+
if (currentDestination != targetDestination.route) {
171+
navController.navigate(
172+
targetDestination within navGraph,
173+
fun NavOptionsBuilder.() {
174+
launchSingleTop = true
175+
restoreState = true
176+
}
177+
)
178+
}
179+
}
180+
181+
override fun gotoViewAllSearchResultsScreen(
182+
viewAllType: String,
183+
searchParams: String
184+
) {
185+
val currentDestination = navController.currentDestination?.route
186+
val targetDestination =
187+
ViewAllSearchResultsDestination(
188+
searchParams = searchParams,
189+
viewAllType = viewAllType
190+
)
168191

169192
if (currentDestination != targetDestination.route) {
170193
navController.navigate(

app/src/main/java/com/android/swingmusic/presentation/navigator/NavGraphs.kt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import com.android.swingmusic.album.presentation.screen.destinations.AlbumWithIn
44
import com.android.swingmusic.album.presentation.screen.destinations.AllAlbumScreenDestination
55
import com.android.swingmusic.artist.presentation.screen.destinations.AllArtistsScreenDestination
66
import com.android.swingmusic.artist.presentation.screen.destinations.ArtistInfoScreenDestination
7-
import com.android.swingmusic.artist.presentation.screen.destinations.ViewAllScreenDestination
7+
import com.android.swingmusic.artist.presentation.screen.destinations.ViewAllScreenOnArtistDestination
88
import com.android.swingmusic.auth.presentation.screen.destinations.LoginWithQrCodeDestination
99
import com.android.swingmusic.auth.presentation.screen.destinations.LoginWithUsernameScreenDestination
1010
import com.android.swingmusic.folder.presentation.screen.destinations.FoldersAndTracksScreenDestination
1111
import com.android.swingmusic.home.presentation.destinations.HomeDestination
1212
import com.android.swingmusic.player.presentation.screen.destinations.NowPlayingScreenDestination
1313
import com.android.swingmusic.player.presentation.screen.destinations.QueueScreenDestination
1414
import com.android.swingmusic.search.presentation.screen.destinations.SearchScreenDestination
15+
import com.android.swingmusic.search.presentation.screen.destinations.ViewAllSearchResultsDestination
1516
import com.ramcosta.composedestinations.dynamic.routedIn
1617
import com.ramcosta.composedestinations.spec.DestinationSpec
1718
import com.ramcosta.composedestinations.spec.NavGraphSpec
@@ -53,8 +54,9 @@ object NavGraphs {
5354
ArtistInfoScreenDestination,
5455
QueueScreenDestination,
5556
NowPlayingScreenDestination,
56-
ViewAllScreenDestination,
57-
SearchScreenDestination
57+
ViewAllScreenOnArtistDestination,
58+
SearchScreenDestination,
59+
ViewAllSearchResultsDestination
5860
).routedIn(this).associateBy { it.route }
5961
}
6062

@@ -68,10 +70,11 @@ object NavGraphs {
6870
NowPlayingScreenDestination,
6971
QueueScreenDestination,
7072
ArtistInfoScreenDestination,
71-
ViewAllScreenDestination,
73+
ViewAllScreenOnArtistDestination,
7274
AlbumWithInfoScreenDestination,
7375
FoldersAndTracksScreenDestination,
74-
SearchScreenDestination
76+
SearchScreenDestination,
77+
ViewAllSearchResultsDestination
7578
).routedIn(this).associateBy { it.route }
7679
}
7780

@@ -85,11 +88,12 @@ object NavGraphs {
8588
AllArtistsScreenDestination,
8689
ArtistInfoScreenDestination,
8790
AlbumWithInfoScreenDestination,
88-
ViewAllScreenDestination,
91+
ViewAllScreenOnArtistDestination,
8992
NowPlayingScreenDestination,
9093
QueueScreenDestination,
9194
FoldersAndTracksScreenDestination,
92-
SearchScreenDestination
95+
SearchScreenDestination,
96+
ViewAllSearchResultsDestination
9397
).routedIn(this).associateBy { it.route }
9498
}
9599

@@ -103,11 +107,12 @@ object NavGraphs {
103107
AllAlbumScreenDestination,
104108
AlbumWithInfoScreenDestination,
105109
ArtistInfoScreenDestination,
106-
ViewAllScreenDestination,
110+
ViewAllScreenOnArtistDestination,
107111
NowPlayingScreenDestination,
108112
QueueScreenDestination,
109113
FoldersAndTracksScreenDestination,
110-
SearchScreenDestination
114+
SearchScreenDestination,
115+
ViewAllSearchResultsDestination
111116
).routedIn(this).associateBy { it.route }
112117
}
113118

@@ -119,10 +124,11 @@ object NavGraphs {
119124
override val destinationsByRoute: Map<String, DestinationSpec<*>> =
120125
listOf<DestinationSpec<*>>(
121126
SearchScreenDestination,
127+
ViewAllSearchResultsDestination,
122128
AllAlbumScreenDestination,
123129
AlbumWithInfoScreenDestination,
124130
ArtistInfoScreenDestination,
125-
ViewAllScreenDestination,
131+
ViewAllScreenOnArtistDestination,
126132
NowPlayingScreenDestination,
127133
QueueScreenDestination,
128134
FoldersAndTracksScreenDestination

app/src/main/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3+
<color name="splash_background">#262626</color>
34
<color name="purple_200">#FFBB86FC</color>
45
<color name="purple_500">#FF6200EE</color>
56
<color name="purple_700">#FF3700B3</color>

app/src/main/res/values/themes.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33

4-
<style name="Theme.SwingMusic" parent="android:Theme.Material.Light.NoActionBar" />
4+
<style name="Theme.SwingMusic" parent="android:Theme.Material.Light.NoActionBar">
5+
<item name="android:windowBackground">@color/splash_background</item>
6+
<item name="android:statusBarColor">@android:color/transparent</item>
7+
</style>
58
</resources>

core/src/main/java/com/android/swingmusic/core/data/dto/ArtistResultDto.kt

Lines changed: 0 additions & 39 deletions
This file was deleted.

core/src/main/java/com/android/swingmusic/core/data/dto/ArtistsSearchResultDto.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ data class ArtistsSearchResultDto(
77
@SerializedName("more")
88
val more: Boolean?,
99
@SerializedName("results")
10-
val resultDto: List<ArtistResultDto>?
10+
val resultDto: List<ArtistDto>?
1111
)

core/src/main/java/com/android/swingmusic/core/data/mapper/Mapper.kt

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import com.android.swingmusic.core.data.dto.AllArtistsDto
1111
import com.android.swingmusic.core.data.dto.ArtistDto
1212
import com.android.swingmusic.core.data.dto.ArtistExpandedDto
1313
import com.android.swingmusic.core.data.dto.ArtistInfoDto
14-
import com.android.swingmusic.core.data.dto.ArtistResultDto
1514
import com.android.swingmusic.core.data.dto.ArtistsSearchResultDto
1615
import com.android.swingmusic.core.data.dto.DirDto
1716
import com.android.swingmusic.core.data.dto.DirListDto
@@ -313,21 +312,10 @@ object Map {
313312
)
314313
}
315314

316-
private fun ArtistResultDto.toArtist(): Artist {
317-
return Artist(
318-
artistHash = artisthash ?: "",
319-
colors = listOf(color ?: "#FFFFFF"),
320-
createdDate = createdDate?.toDouble() ?: 0.0,
321-
helpText = "",
322-
image = image ?: "",
323-
name = name ?: "Unknown Artist"
324-
)
325-
}
326-
327315
fun ArtistsSearchResultDto.toArtistsSearchResult(): ArtistsSearchResult {
328316
return ArtistsSearchResult(
329317
more = more ?: false,
330-
results = resultDto?.map { it.toArtist() } ?: emptyList()
318+
result = resultDto?.map { it.toArtist() } ?: emptyList()
331319
)
332320
}
333321

@@ -361,7 +349,7 @@ object Map {
361349
fun TracksSearchResultDto.toTracksSearchResult(): TracksSearchResult {
362350
return TracksSearchResult(
363351
more = more ?: false,
364-
results = results?.map { it.toTrackResults() } ?: emptyList()
352+
result = results?.map { it.toTrackResults() } ?: emptyList()
365353
)
366354
}
367355

core/src/main/java/com/android/swingmusic/core/domain/model/ArtistsSearchResult.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ package com.android.swingmusic.core.domain.model
22

33
data class ArtistsSearchResult(
44
val more: Boolean,
5-
val results: List<Artist>
5+
val result: List<Artist>
66
)

core/src/main/java/com/android/swingmusic/core/domain/model/TracksSearchResult.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ package com.android.swingmusic.core.domain.model
22

33
data class TracksSearchResult(
44
val more: Boolean,
5-
val results: List<Track>
5+
val result: List<Track>
66
)

0 commit comments

Comments
 (0)