mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 22:03:55 +01:00
Make "File usages" items clickable with correct URLs #6307 (#6405)
Some checks failed
Android CI / Run tests and generate APK (push) Has been cancelled
Some checks failed
Android CI / Run tests and generate APK (push) Has been cancelled
* Fix: URL generation for GlobalFileUsage in FileUsagesUiModel.kt for issue #6307 * Add clickable functionality to 'Usages on Other Wikis' in FileUsagesContainer for issue #6307 --------- Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
parent
dd96c64182
commit
e2c8f85a5b
2 changed files with 47 additions and 31 deletions
|
|
@ -2128,22 +2128,17 @@ fun FileUsagesContainer(
|
|||
val uriHandle = LocalUriHandler.current
|
||||
|
||||
Column(modifier = modifier) {
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.usages_on_commons_heading),
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
|
||||
IconButton(onClick = {
|
||||
isCommonsListExpanded = !isCommonsListExpanded
|
||||
}) {
|
||||
IconButton(onClick = { isCommonsListExpanded = !isCommonsListExpanded }) {
|
||||
Icon(
|
||||
imageVector = if (isCommonsListExpanded) Icons.Default.KeyboardArrowUp
|
||||
else Icons.Default.KeyboardArrowDown,
|
||||
|
|
@ -2157,11 +2152,8 @@ fun FileUsagesContainer(
|
|||
MediaDetailViewModel.FileUsagesContainerState.Loading -> {
|
||||
LinearProgressIndicator()
|
||||
}
|
||||
|
||||
is MediaDetailViewModel.FileUsagesContainerState.Success -> {
|
||||
|
||||
val data = commonsContainerState.data
|
||||
|
||||
if (data.isNullOrEmpty()) {
|
||||
ListItem(headlineContent = {
|
||||
Text(
|
||||
|
|
@ -2181,7 +2173,7 @@ fun FileUsagesContainer(
|
|||
headlineContent = {
|
||||
Text(
|
||||
modifier = Modifier.clickable {
|
||||
uriHandle.openUri(usage.link!!)
|
||||
usage.link?.let { uriHandle.openUri(it) }
|
||||
},
|
||||
text = usage.title,
|
||||
style = MaterialTheme.typography.titleSmall.copy(
|
||||
|
|
@ -2189,11 +2181,11 @@ fun FileUsagesContainer(
|
|||
textDecoration = TextDecoration.Underline
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is MediaDetailViewModel.FileUsagesContainerState.Error -> {
|
||||
ListItem(headlineContent = {
|
||||
Text(
|
||||
|
|
@ -2203,12 +2195,10 @@ fun FileUsagesContainer(
|
|||
)
|
||||
})
|
||||
}
|
||||
|
||||
MediaDetailViewModel.FileUsagesContainerState.Initial -> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
|
|
@ -2219,10 +2209,7 @@ fun FileUsagesContainer(
|
|||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
|
||||
IconButton(onClick = {
|
||||
isOtherWikisListExpanded = !isOtherWikisListExpanded
|
||||
}) {
|
||||
IconButton(onClick = { isOtherWikisListExpanded = !isOtherWikisListExpanded }) {
|
||||
Icon(
|
||||
imageVector = if (isOtherWikisListExpanded) Icons.Default.KeyboardArrowUp
|
||||
else Icons.Default.KeyboardArrowDown,
|
||||
|
|
@ -2236,11 +2223,8 @@ fun FileUsagesContainer(
|
|||
MediaDetailViewModel.FileUsagesContainerState.Loading -> {
|
||||
LinearProgressIndicator()
|
||||
}
|
||||
|
||||
is MediaDetailViewModel.FileUsagesContainerState.Success -> {
|
||||
|
||||
val data = globalContainerState.data
|
||||
|
||||
if (data.isNullOrEmpty()) {
|
||||
ListItem(headlineContent = {
|
||||
Text(
|
||||
|
|
@ -2259,16 +2243,20 @@ fun FileUsagesContainer(
|
|||
},
|
||||
headlineContent = {
|
||||
Text(
|
||||
modifier = Modifier.clickable {
|
||||
usage.link?.let { uriHandle.openUri(it) }
|
||||
},
|
||||
text = usage.title,
|
||||
style = MaterialTheme.typography.titleSmall.copy(
|
||||
color = Color(0xFF5A6AEC),
|
||||
textDecoration = TextDecoration.Underline
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is MediaDetailViewModel.FileUsagesContainerState.Error -> {
|
||||
ListItem(headlineContent = {
|
||||
Text(
|
||||
|
|
@ -2278,10 +2266,8 @@ fun FileUsagesContainer(
|
|||
)
|
||||
})
|
||||
}
|
||||
|
||||
MediaDetailViewModel.FileUsagesContainerState.Initial -> {}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue