Skip to content

Commit

Permalink
open profile on list navigation if not logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed May 26, 2024
1 parent 6559e51 commit 9e60f2d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ fun HidingNavigationBar(
visible: Boolean,
selected: NavigationBarState,
loggedIn: Flow<Boolean>,
listClickable: Boolean = false,
onDiscover: () -> Unit,
onHome: () -> Unit,
onFavorites: () -> Unit
onList: (isLoggedIn: Boolean) -> Unit
) {
val density = LocalDensity.current

Expand Down Expand Up @@ -83,7 +84,7 @@ fun HidingNavigationBar(
val isHome = remember(selected) {
selected is NavigationBarState.Home
}
val isFavorites = remember(selected) {
val isList = remember(selected) {
selected is NavigationBarState.Favorite
}
val isLoggedIn by loggedIn.collectAsStateWithLifecycle(false)
Expand Down Expand Up @@ -124,12 +125,12 @@ fun HidingNavigationBar(
)
NavigationBarItem(
onClick = {
if (!isFavorites) {
onFavorites()
if (!isList) {
onList(isLoggedIn)
}
},
selected = isFavorites,
enabled = isLoggedIn,
selected = isList,
enabled = isLoggedIn || listClickable,
icon = {
Icon(
imageVector = selected.favoriteIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ fun DiscoverScreen(component: DiscoverComponent) {
loggedIn = component.loggedIn,
onDiscover = { },
onHome = component::viewHome,
onFavorites = component::viewList
onList = {
component.viewList()
}
)
}
) { targetPadding ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fun FavoritesScreen(component: FavoritesComponent) {
loggedIn = flowOf(true),
onDiscover = component::viewDiscover,
onHome = component::viewHome,
onFavorites = { }
onList = { }
)
}
) { padding ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,16 @@ fun HomeScreen(component: HomeComponent) {
visible = listState.scrollUpVisible(),
selected = NavigationBarState.Home,
loggedIn = component.loggedIn,
listClickable = true,
onDiscover = component::viewDiscover,
onHome = { },
onFavorites = component::viewFavorites
onList = { loggedIn ->
if (loggedIn) {
component.viewFavorites()
} else {
component.viewProfile()
}
},
)
}
) { targetPadding ->
Expand Down

0 comments on commit 9e60f2d

Please sign in to comment.