Skip to content

Commit

Permalink
Merge pull request #920 from Paschmid/fix/919
Browse files Browse the repository at this point in the history
- always display header of Libraries composable
  • Loading branch information
mikepenz authored Sep 22, 2023
2 parents e2074fa + 94d43e5 commit 43d7ac0
Showing 1 changed file with 31 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.mikepenz.aboutlibraries.ui.compose.util.StableLibrary
import com.mikepenz.aboutlibraries.ui.compose.util.StableLibs
import com.mikepenz.aboutlibraries.ui.compose.util.author
import com.mikepenz.aboutlibraries.ui.compose.util.htmlReadyLicenseContent
import com.mikepenz.aboutlibraries.ui.compose.util.stable
import kotlinx.collections.immutable.ImmutableList


Expand All @@ -49,40 +50,38 @@ fun LibrariesContainer(
) {
val uriHandler = LocalUriHandler.current

val libs = libraries?.libraries
if (libs != null) {
val openDialog = remember { mutableStateOf<StableLibrary?>(null) }
val libs = libraries?.libraries ?: emptyList<Library>().stable
val openDialog = remember { mutableStateOf<StableLibrary?>(null) }

Libraries(
libraries = libs,
modifier = modifier,
lazyListState = lazyListState,
contentPadding = contentPadding,
showAuthor = showAuthor,
showVersion = showVersion,
showLicenseBadges = showLicenseBadges,
colors = colors,
padding = padding,
itemContentPadding = itemContentPadding,
itemSpacing = itemSpacing,
header = header,
onLibraryClick = { library ->
val license = library.library.licenses.firstOrNull()
if (onLibraryClick != null) {
onLibraryClick(library)
} else if (!license?.htmlReadyLicenseContent.isNullOrBlank()) {
openDialog.value = library
} else if (!license?.url.isNullOrBlank()) {
license?.url?.also { uriHandler.openUri(it) }
}
},
)

val library = openDialog.value
if (library != null && licenseDialogBody != null) {
LicenseDialog(library, colors, licenseDialogConfirmText, body = licenseDialogBody) {
openDialog.value = null
Libraries(
libraries = libs,
modifier = modifier,
lazyListState = lazyListState,
contentPadding = contentPadding,
showAuthor = showAuthor,
showVersion = showVersion,
showLicenseBadges = showLicenseBadges,
colors = colors,
padding = padding,
itemContentPadding = itemContentPadding,
itemSpacing = itemSpacing,
header = header,
onLibraryClick = { library ->
val license = library.library.licenses.firstOrNull()
if (onLibraryClick != null) {
onLibraryClick(library)
} else if (!license?.htmlReadyLicenseContent.isNullOrBlank()) {
openDialog.value = library
} else if (!license?.url.isNullOrBlank()) {
license?.url?.also { uriHandler.openUri(it) }
}
},
)

val library = openDialog.value
if (library != null && licenseDialogBody != null) {
LicenseDialog(library, colors, licenseDialogConfirmText, body = licenseDialogBody) {
openDialog.value = null
}
}
}
Expand Down

0 comments on commit 43d7ac0

Please sign in to comment.