Skip to content

Commit 1a599ff

Browse files
committed
feat: Add navigation to developer profiles from repository lists
This adds the ability to navigate to a developer's profile screen by clicking on their avatar or username in the "Starred Repositories" and "Favorites" lists. Specific changes: - Implemented `OnDeveloperProfileClick` actions in the `StarredRepos` and `Favourites` features. - Updated the `StarredRepositoryItem` and `FavouriteRepositoryItem` to handle clicks on the owner's avatar and name, triggering navigation. - Wired the navigation logic in `AppNavigation` to handle opening the developer profile screen. - Renamed `OpenAuthorInApp` to `OpenDeveloperProfile` in the details screen for consistency. - Localized several strings in `StarredRepositoryItem` using string resources.
1 parent 0cd93bd commit 1a599ff

14 files changed

Lines changed: 94 additions & 23 deletions

File tree

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/AppNavigation.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ fun AppNavigation(
162162
onNavigateToDetails = {
163163
navBackStack.add(GithubStoreGraph.DetailsScreen(it))
164164
},
165+
onNavigateToDeveloperProfile = { username ->
166+
navBackStack.add(
167+
GithubStoreGraph.DeveloperProfileScreen(
168+
username = username
169+
)
170+
)
171+
},
165172
)
166173
}
167174

@@ -176,7 +183,14 @@ fun AppNavigation(
176183
repositoryId = repoId
177184
)
178185
)
179-
}
186+
},
187+
onNavigateToDeveloperProfile = { username ->
188+
navBackStack.add(
189+
GithubStoreGraph.DeveloperProfileScreen(
190+
username = username
191+
)
192+
)
193+
},
180194
)
181195
}
182196

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/feature/details/presentation/DetailsAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ sealed interface DetailsAction {
1515

1616
data object OpenRepoInBrowser : DetailsAction
1717
data object OpenAuthorInBrowser : DetailsAction
18-
data class OpenAuthorInApp(val authorLogin: String) : DetailsAction
18+
data class OpenDeveloperProfile(val username: String) : DetailsAction
1919

2020
data object OpenInObtainium : DetailsAction
2121
data object OpenInAppManager : DetailsAction

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/feature/details/presentation/DetailsRoot.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ fun DetailsRoot(
106106
onNavigateBack()
107107
}
108108

109-
is DetailsAction.OpenAuthorInApp -> {
110-
onNavigateToDeveloperProfile(action.authorLogin)
109+
is DetailsAction.OpenDeveloperProfile -> {
110+
onNavigateToDeveloperProfile(action.username)
111111
}
112112

113113
is DetailsAction.OnMessage -> {

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/feature/details/presentation/DetailsViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ class DetailsViewModel(
508508
// Handled in composable
509509
}
510510

511-
is DetailsAction.OpenAuthorInApp -> {
511+
is DetailsAction.OpenDeveloperProfile -> {
512512
// Handled in composable
513513
}
514514

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/feature/details/presentation/components/sections/Owner.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fun LazyListScope.author(
6969
onClick = {
7070
author?.login?.let { author ->
7171
onAction(
72-
DetailsAction.OpenAuthorInApp(
72+
DetailsAction.OpenDeveloperProfile(
7373
author
7474
)
7575
)
@@ -154,7 +154,7 @@ fun LazyListScope.author(
154154
author?.login?.let { author ->
155155
IconButton(
156156
onClick = {
157-
onAction(DetailsAction.OpenAuthorInApp(author))
157+
onAction(DetailsAction.OpenDeveloperProfile(author))
158158
},
159159
colors = IconButtonDefaults.iconButtonColors(
160160
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh,

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/feature/favourites/presentation/FavouritesAction.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ sealed interface FavouritesAction {
66
data object OnNavigateBackClick : FavouritesAction
77
data class OnToggleFavorite(val favouriteRepository: FavouriteRepository) : FavouritesAction
88
data class OnRepositoryClick(val favouriteRepository: FavouriteRepository) : FavouritesAction
9+
data class OnDeveloperProfileClick(val username: String) : FavouritesAction
910
}

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/feature/favourites/presentation/FavouritesRoot.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import zed.rainxch.githubstore.feature.favourites.presentation.components.Favour
4141
fun FavouritesRoot(
4242
onNavigateBack: () -> Unit,
4343
onNavigateToDetails: (repoId: Long) -> Unit,
44+
onNavigateToDeveloperProfile: (username: String) -> Unit,
4445
viewModel: FavouritesViewModel = koinViewModel()
4546
) {
4647
val state by viewModel.state.collectAsStateWithLifecycle()
@@ -57,6 +58,10 @@ fun FavouritesRoot(
5758
onNavigateToDetails(action.favouriteRepository.repoId)
5859
}
5960

61+
is FavouritesAction.OnDeveloperProfileClick -> {
62+
onNavigateToDeveloperProfile(action.username)
63+
}
64+
6065
else -> {
6166
viewModel.onAction(action)
6267
}
@@ -103,6 +108,9 @@ fun FavouritesScreen(
103108
onItemClick = {
104109
onAction(FavouritesAction.OnRepositoryClick(repo))
105110
},
111+
onDevProfileClick = {
112+
onAction(FavouritesAction.OnDeveloperProfileClick(repo.repoOwner))
113+
},
106114
modifier = Modifier.Companion.animateItem()
107115
)
108116
}

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/feature/favourites/presentation/FavouritesViewModel.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ class FavouritesViewModel(
6464
// Handled in composable
6565
}
6666

67+
is FavouritesAction.OnDeveloperProfileClick -> {
68+
// Handled in composable
69+
}
70+
6771
is FavouritesAction.OnToggleFavorite -> {
6872
viewModelScope.launch {
6973
val repo = action.favouriteRepository

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/feature/favourites/presentation/components/FavouriteRepositoryItem.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package zed.rainxch.githubstore.feature.favourites.presentation.components
22

33
import androidx.compose.foundation.background
4+
import androidx.compose.foundation.clickable
45
import androidx.compose.foundation.layout.Arrangement
56
import androidx.compose.foundation.layout.Box
67
import androidx.compose.foundation.layout.Column
@@ -45,6 +46,7 @@ fun FavouriteRepositoryItem(
4546
favouriteRepository: FavouriteRepository,
4647
onToggleFavouriteClick: () -> Unit,
4748
onItemClick: () -> Unit,
49+
onDevProfileClick: () -> Unit,
4850
modifier: Modifier = Modifier
4951
) {
5052
Card(
@@ -61,6 +63,10 @@ fun FavouriteRepositoryItem(
6163
.padding(16.dp)
6264
) {
6365
Row(
66+
modifier = Modifier
67+
.clickable(onClick = {
68+
onDevProfileClick()
69+
}),
6470
verticalAlignment = Alignment.CenterVertically,
6571
horizontalArrangement = Arrangement.spacedBy(8.dp)
6672
) {

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/feature/starred_repos/presentation/StarredReposAction.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ sealed interface StarredReposAction {
88
data object OnRetrySync : StarredReposAction
99
data object OnDismissError : StarredReposAction
1010
data class OnRepositoryClick(val repository: StarredRepositoryUi) : StarredReposAction
11+
data class OnDeveloperProfileClick(val username: String) : StarredReposAction
1112
data class OnToggleFavorite(val repository: StarredRepositoryUi) : StarredReposAction
1213
}

0 commit comments

Comments
 (0)