Skip to content

Commit 1b06198

Browse files
committed
feat: raising selected profile picture to home screen
1 parent 5a259b4 commit 1b06198

File tree

8 files changed

+46
-16
lines changed

8 files changed

+46
-16
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
package com.codandotv.streamplayerapp.core_navigation.routes
22

3+
import com.codandotv.streamplayerapp.core_navigation.routes.BottomNavRoutes.PARAM.PROFILE_ID
4+
35
object BottomNavRoutes {
46
const val HOME = "bottomHome"
7+
const val HOME_COMPLETE = "$HOME?$PROFILE_ID={$PROFILE_ID}"
58
const val GAMES = "bottomGames"
69
const val NEWS = "bottomNews"
710
const val SCENES = "bottomScenes"
811
const val DOWNLOADS = "bottomDownloads"
12+
13+
object PARAM {
14+
const val PROFILE_ID = "userId"
15+
}
916
}

core-shared-ui/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ dependencies {
1010
implementation(libs.bundles.kotlin)
1111
implementation(libs.bundles.androidSupport)
1212
testImplementation(libs.bundles.test)
13+
implementation(libs.coil)
1314
}

core-shared-ui/src/main/java/com/codandotv/streamplayerapp/core_shared_ui/widget/StreamPlayerTopBar.kt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import androidx.compose.ui.graphics.Color
2727
import androidx.compose.ui.res.painterResource
2828
import androidx.compose.ui.res.stringResource
2929
import androidx.compose.ui.unit.dp
30+
import coil.compose.AsyncImage
3031
import com.codandotv.streamplayerapp.core.shared.ui.R
3132
import com.codandotv.streamplayerapp.core_shared_ui.resources.Colors
3233
import com.codandotv.streamplayerapp.core_shared_ui.theme.ThemePreview
@@ -36,18 +37,23 @@ import com.codandotv.streamplayerapp.core_shared_ui.theme.ThemePreviews
3637
@Composable
3738
fun StreamPlayerTopBar(
3839
scrollBehavior: TopAppBarScrollBehavior,
39-
onNavigateProfilePicker: () -> Unit = {}
40+
onNavigateProfilePicker: () -> Unit = {},
41+
onSelectedProfilePicture: String
4042
) {
4143
Box(modifier = Modifier.background(color = Colors.Dark10)) {
4244
StreamPlayerTopBar(
4345
onNavigateProfilePicker = { onNavigateProfilePicker() },
46+
profilePicture = onSelectedProfilePicture
4447
)
4548
StreamPlayerOptionsTopBar(modifier = Modifier.padding(top = 50.dp), scrollBehavior)
4649
}
4750
}
4851

4952
@Composable
50-
private fun StreamPlayerTopBar(onNavigateProfilePicker: () -> Unit = {}) {
53+
private fun StreamPlayerTopBar(
54+
onNavigateProfilePicker: () -> Unit = {},
55+
profilePicture: String
56+
) {
5157
Row(
5258
modifier = Modifier
5359
.height(50.dp)
@@ -82,13 +88,14 @@ private fun StreamPlayerTopBar(onNavigateProfilePicker: () -> Unit = {}) {
8288
modifier = Modifier.fillMaxHeight(),
8389
onClick = { onNavigateProfilePicker() }
8490
) {
85-
Icon(
91+
AsyncImage(
8692
modifier = Modifier
8793
.height(24.dp)
8894
.clip(RoundedCornerShape(4.dp)),
89-
painter = painterResource(R.drawable.perfil_fake),
90-
contentDescription = stringResource(id = R.string.icon_profile),
91-
tint = Color.Unspecified,
95+
model = profilePicture,
96+
error = painterResource(id = R.drawable.perfil_fake),
97+
placeholder = painterResource(id = R.drawable.perfil_fake),
98+
contentDescription = stringResource(id = R.string.icon_profile)
9299
)
93100
}
94101
}
@@ -135,7 +142,9 @@ fun StreamPlayerTopBarPreview() {
135142
StreamPlayerTopBar(
136143
scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(
137144
rememberTopAppBarState()
138-
)
145+
),
146+
onNavigateProfilePicker = {},
147+
onSelectedProfilePicture = ""
139148
)
140149
}
141150
}

feature-list-streams/src/main/java/com/codandotv/streamplayerapp/feature_list_streams/list/presentation/navigation/ListStreamsNavigation.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ import androidx.navigation.NavGraphBuilder
66
import androidx.navigation.NavHostController
77
import androidx.navigation.compose.composable
88
import com.codandotv.streamplayerapp.core_navigation.routes.BottomNavRoutes
9+
import com.codandotv.streamplayerapp.core_navigation.routes.BottomNavRoutes.PARAM.PROFILE_ID
910
import com.codandotv.streamplayerapp.core_navigation.routes.Routes.DETAIL
1011
import com.codandotv.streamplayerapp.core_navigation.routes.Routes.PROFILE_PICKER
1112
import com.codandotv.streamplayerapp.feature_list_streams.list.di.ListStreamModule
1213
import com.codandotv.streamplayerapp.feature_list_streams.list.presentation.screens.ListStreamsScreen
1314
import org.koin.core.context.loadKoinModules
1415
import org.koin.core.context.unloadKoinModules
1516

17+
internal const val DEFAULT_ID = ""
18+
1619
fun NavGraphBuilder.listStreamsNavGraph(navController: NavHostController) {
17-
composable(BottomNavRoutes.HOME) { nav ->
20+
composable(BottomNavRoutes.HOME_COMPLETE) { nav ->
1821
BackHandler(true) {}
1922
if (nav.getLifecycle().currentState == Lifecycle.State.STARTED) {
2023
loadKoinModules(ListStreamModule.module)
@@ -28,6 +31,8 @@ fun NavGraphBuilder.listStreamsNavGraph(navController: NavHostController) {
2831
},
2932
disposable = {
3033
unloadKoinModules(ListStreamModule.module)
31-
})
34+
},
35+
profilePicture = nav.arguments?.getString(PROFILE_ID) ?: DEFAULT_ID
36+
)
3237
}
3338
}

feature-list-streams/src/main/java/com/codandotv/streamplayerapp/feature_list_streams/list/presentation/screens/ListStreamsScreen.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ fun ListStreamsScreen(
3535
navController: NavController,
3636
onNavigateDetailList: (String) -> Unit = {},
3737
onNavigateProfilePicker: () -> Unit = {},
38-
disposable: () -> Unit = {}
38+
disposable: () -> Unit = {},
39+
profilePicture: String
3940
) {
4041
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
4142
val lifecycleOwner = LocalLifecycleOwner.current
@@ -59,7 +60,8 @@ fun ListStreamsScreen(
5960
topBar = {
6061
StreamPlayerTopBar(
6162
scrollBehavior = scrollBehavior,
62-
onNavigateProfilePicker = onNavigateProfilePicker
63+
onNavigateProfilePicker = onNavigateProfilePicker,
64+
onSelectedProfilePicture = profilePicture
6365
)
6466
},
6567
bottomBar = {
@@ -103,5 +105,5 @@ fun ListStreamsScreen(
103105
@ThemePreviews
104106
@Composable
105107
fun ListStreamsScreenPreview() {
106-
ListStreamsScreen(navController = rememberNavController())
108+
ListStreamsScreen(navController = rememberNavController(), profilePicture = "")
107109
}

feature-list-streams/src/main/java/com/codandotv/streamplayerapp/feature_list_streams/profile/presentation/navigation/ProfilePickerStreamNavigation.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import androidx.lifecycle.Lifecycle
44
import androidx.navigation.NavGraphBuilder
55
import androidx.navigation.NavHostController
66
import androidx.navigation.compose.composable
7+
import com.codandotv.streamplayerapp.core_navigation.routes.BottomNavRoutes.PARAM.PROFILE_ID
8+
import com.codandotv.streamplayerapp.core_navigation.routes.BottomNavRoutes.HOME
79
import com.codandotv.streamplayerapp.core_navigation.routes.Routes
810
import com.codandotv.streamplayerapp.feature_list_streams.profile.di.ProfilePickerStreamModule
911
import com.codandotv.streamplayerapp.feature_list_streams.profile.presentation.screens.ProfilePickerStreamScreen
@@ -16,7 +18,10 @@ fun NavGraphBuilder.profilePickerStreamNavGraph(navController: NavHostController
1618
loadKoinModules(ProfilePickerStreamModule.module)
1719
}
1820
ProfilePickerStreamScreen(
19-
navController = navController
21+
navController = navController,
22+
onNavigateListStreams = { profilePic ->
23+
navController.navigate("$HOME?$PROFILE_ID=$profilePic")
24+
}
2025
) {
2126
unloadKoinModules(ProfilePickerStreamModule.module)
2227
}

feature-list-streams/src/main/java/com/codandotv/streamplayerapp/feature_list_streams/profile/presentation/screens/ProfilePickerStreamScreen.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import org.koin.androidx.compose.koinViewModel
5656
fun ProfilePickerStreamScreen(
5757
viewModel: ProfilePickerStreamViewModel = koinViewModel(),
5858
navController: NavController,
59+
onNavigateListStreams: (String) -> Unit = {},
5960
disposable: () -> Unit = {}
6061
) {
6162
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
@@ -76,6 +77,7 @@ fun ProfilePickerStreamScreen(
7677
onSetScreenSize = { width, height, widthPx, heightPx ->
7778
viewModel.setScreenSize(width, height, widthPx, heightPx)
7879
},
80+
onNavigateListStreams = onNavigateListStreams
7981
)
8082
}
8183
}
@@ -92,6 +94,7 @@ private fun SetupProfilePickerScreen(
9294
onSetHaltSizeImage: (Int) -> Unit = { },
9395
onSetHalfExpandedSizeImage: (Int) -> Unit = { },
9496
onClickSelectedProfile: (ProfileStream) -> Unit = {},
97+
onNavigateListStreams: (String) -> Unit = {}
9598
) {
9699
val profiles = uiState.profilesStream
97100

@@ -105,7 +108,7 @@ private fun SetupProfilePickerScreen(
105108
animationSpec = tween(durationMillis = 1000),
106109
finishedListener = {
107110
onSetCenterImageAlpha(0f)
108-
navController.navigateUp()
111+
onNavigateListStreams(uiState.selectedItem.imageUrl)
109112
}
110113
)
111114

gradle/libs.versions.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@ compose_pagging="1.0.0-alpha20"
4141

4242
coil = "2.3.0"
4343
lottie = "5.2.0"
44-
palette = "1.0.0"
4544

4645
[libraries]
4746
kotlin_gradle_plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
4847
android_gradle_plugin = { group = "com.android.tools.build", name = "gradle", version.ref = "android_gradle_plugin" }
4948

5049
#Coil
5150
coil = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" }
52-
palette = { group = "androidx.palette", name = "palette-ktx", version.ref = "palette" }
5351

5452
#Lottie
5553
lottie = { group = "com.airbnb.android", name = "lottie-compose", version.ref = "lottie" }

0 commit comments

Comments
 (0)