Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API to configure itemSpacing for compose #844

Merged
merged 1 commit into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.text.HtmlCompat
Expand Down Expand Up @@ -48,6 +49,7 @@ fun LibrariesContainer(
colors: LibraryColors = LibraryDefaults.libraryColors(),
padding: LibraryPadding = LibraryDefaults.libraryPadding(),
itemContentPadding: PaddingValues = LibraryDefaults.ContentPadding,
itemSpacing: Dp = LibraryDefaults.LibraryItemSpacing,
header: (LazyListScope.() -> Unit)? = null,
onLibraryClick: ((Library) -> Unit)? = null,
) {
Expand All @@ -73,6 +75,7 @@ fun LibrariesContainer(
colors = colors,
padding = padding,
itemContentPadding = itemContentPadding,
itemSpacing = itemSpacing,
header = header,
onLibraryClick = { library ->
if (onLibraryClick != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.mikepenz.aboutlibraries.entity.Library
import com.mikepenz.aboutlibraries.ui.compose.util.author
Expand All @@ -32,10 +33,16 @@ fun Libraries(
colors: LibraryColors = LibraryDefaults.libraryColors(),
padding: LibraryPadding = LibraryDefaults.libraryPadding(),
itemContentPadding: PaddingValues = LibraryDefaults.ContentPadding,
itemSpacing: Dp = LibraryDefaults.LibraryItemSpacing,
header: (LazyListScope.() -> Unit)? = null,
onLibraryClick: ((Library) -> Unit)? = null,
) {
LazyColumn(modifier, state = lazyListState, contentPadding = contentPadding) {
LazyColumn(
modifier,
verticalArrangement = Arrangement.spacedBy(itemSpacing),
state = lazyListState,
contentPadding = contentPadding
) {
header?.invoke(this)
libraryItems(
libraries,
Expand Down Expand Up @@ -157,6 +164,7 @@ object LibraryDefaults {
private val LibraryVersionPaddingStart = 8.dp
private val LibraryBadgePaddingTop = 8.dp
private val LibraryBadgePaddingEnd = 4.dp
internal val LibraryItemSpacing = 0.dp

/**
* The default content padding used by [Library]
Expand Down Expand Up @@ -206,7 +214,7 @@ object LibraryDefaults {
namePadding = namePadding,
versionPadding = versionPadding,
badgePadding = badgePadding,
badgeContentPadding = badgeContentPadding
badgeContentPadding = badgeContentPadding,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.produceState
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.mikepenz.aboutlibraries.Libs
import com.mikepenz.aboutlibraries.entity.Library
Expand All @@ -28,22 +29,24 @@ fun LibrariesContainer(
colors: LibraryColors = LibraryDefaults.libraryColors(),
padding: LibraryPadding = LibraryDefaults.libraryPadding(),
itemContentPadding: PaddingValues = LibraryDefaults.ContentPadding,
itemSpacing: Dp = LibraryDefaults.LibraryItemSpacing,
header: (LazyListScope.() -> Unit)? = null,
onLibraryClick: ((Library) -> Unit)? = null,
) {
LibrariesContainer(
{ Libs.Builder().withJson(aboutLibsJson).build() },
modifier,
lazyListState,
contentPadding,
showAuthor,
showVersion,
showLicenseBadges,
colors,
padding,
itemContentPadding,
header,
onLibraryClick
modifier = modifier,
lazyListState = lazyListState,
contentPadding = contentPadding,
showAuthor = showAuthor,
showVersion = showVersion,
showLicenseBadges = showLicenseBadges,
colors = colors,
padding = padding,
itemContentPadding = itemContentPadding,
itemSpacing = itemSpacing,
header = header,
onLibraryClick = onLibraryClick
)
}

Expand All @@ -62,6 +65,7 @@ fun LibrariesContainer(
colors: LibraryColors = LibraryDefaults.libraryColors(),
padding: LibraryPadding = LibraryDefaults.libraryPadding(),
itemContentPadding: PaddingValues = LibraryDefaults.ContentPadding,
itemSpacing: Dp = LibraryDefaults.LibraryItemSpacing,
header: (LazyListScope.() -> Unit)? = null,
onLibraryClick: ((Library) -> Unit)? = null,
) {
Expand All @@ -75,17 +79,18 @@ fun LibrariesContainer(
if (libs != null) {
Libraries(
libraries = libs,
modifier,
lazyListState,
contentPadding,
showAuthor,
showVersion,
showLicenseBadges,
colors,
padding,
itemContentPadding,
header,
onLibraryClick
modifier = modifier,
lazyListState = lazyListState,
contentPadding = contentPadding,
showAuthor = showAuthor,
showVersion = showVersion,
showLicenseBadges = showLicenseBadges,
colors = colors,
padding = padding,
itemContentPadding = itemContentPadding,
itemSpacing = itemSpacing,
header = header,
onLibraryClick = onLibraryClick
)
}
}