Skip to content

Commit 2571cb8

Browse files
authored
feat: Open contributor's GitHub profile when clicked (#2775)
1 parent c327857 commit 2571cb8

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

app/src/main/java/app/revanced/manager/ui/screen/settings/ContributorSettingsScreen.kt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package app.revanced.manager.ui.screen.settings
22

33
import androidx.compose.foundation.border
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.BoxWithConstraints
@@ -34,6 +35,8 @@ import androidx.compose.ui.Modifier
3435
import androidx.compose.ui.draw.clip
3536
import androidx.compose.ui.input.nestedscroll.nestedScroll
3637
import androidx.compose.ui.layout.ContentScale
38+
import androidx.compose.ui.platform.LocalUriHandler
39+
import androidx.compose.ui.platform.UriHandler
3740
import androidx.compose.ui.res.stringResource
3841
import androidx.compose.ui.text.font.FontWeight
3942
import androidx.compose.ui.text.style.TextOverflow
@@ -57,6 +60,7 @@ fun ContributorSettingsScreen(
5760
) {
5861
val repositories = viewModel.repositories
5962
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
63+
val uriHandler = LocalUriHandler.current
6064

6165
Scaffold(
6266
topBar = {
@@ -93,7 +97,8 @@ fun ContributorSettingsScreen(
9397
) {
9498
ContributorsCard(
9599
title = it.name,
96-
contributors = it.contributors
100+
contributors = it.contributors,
101+
uriHandler = uriHandler
97102
)
98103
}
99104
}
@@ -115,7 +120,8 @@ fun ContributorsCard(
115120
title: String,
116121
contributors: List<ReVancedContributor>,
117122
itemsPerPage: Int = 12,
118-
numberOfRows: Int = 2
123+
numberOfRows: Int = 2,
124+
uriHandler: UriHandler
119125
) {
120126
val itemsPerRow = (itemsPerPage / numberOfRows)
121127

@@ -172,7 +178,11 @@ fun ContributorsCard(
172178
contributorsByPage[page].forEach {
173179
if (itemSize > 100.dp) {
174180
Row(
175-
modifier = Modifier.width(itemSize - 1.dp), // we delete 1.dp to account for not-so divisible numbers
181+
modifier = Modifier
182+
.width(itemSize - 1.dp)
183+
.clickable {
184+
uriHandler.openUri("https://github.com/${it.username}")
185+
}, // we delete 1.dp to account for not-so divisible numbers
176186
verticalAlignment = Alignment.CenterVertically,
177187
horizontalArrangement = Arrangement.spacedBy(12.dp)
178188
) {
@@ -203,6 +213,9 @@ fun ContributorsCard(
203213
modifier = Modifier
204214
.size(size = (itemSize - 1.dp).coerceAtMost(50.dp)) // we delete 1.dp to account for not-so divisible numbers
205215
.clip(CircleShape)
216+
.clickable {
217+
uriHandler.openUri("https://github.com/${it.username}")
218+
}
206219
)
207220
}
208221
}

0 commit comments

Comments
 (0)