Skip to content

Commit

Permalink
为Banner新增Pager的contentPadding功能
Browse files Browse the repository at this point in the history
更新依赖版本
  • Loading branch information
zhujiang2 committed Feb 23, 2022
1 parent 6c92658 commit 7621bc9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ android {

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.core:core-ktx:1.8.0-alpha04'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.4.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
implementation 'androidx.activity:activity-compose:1.4.0'
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
//implementation 'com.github.zhujiang521:Banner:1.3.3'
Expand Down
2 changes: 1 addition & 1 deletion banner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ afterEvaluate {
// You can then customize attributes of the publication as shown below.
groupId = 'com.zj.banner'
artifactId = 'banner'
version = '2.0.0'
version = '2.0.2'
}
// // Creates a Maven publication called “debug”.
// debug(MavenPublication) {
Expand Down
9 changes: 6 additions & 3 deletions banner/src/main/java/com/zj/banner/BannerPager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ fun <T : BaseBannerBean> BannerPager(
}

Box(modifier = modifier.height(config.bannerHeight)) {
HorizontalPager(count = items.size, state = pagerState) { page ->
HorizontalPager(
count = items.size,
state = pagerState,
itemSpacing = config.itemSpacing,
contentPadding = config.contentPadding
) { page ->
val item = items[page]
BannerCard(
bean = item,
Expand Down Expand Up @@ -111,8 +116,6 @@ fun <T : BaseBannerBean> BannerPager(
}




@ExperimentalPagerApi
@Composable
fun StartBanner(pagerState: PagerState, intervalTime: Long) {
Expand Down
5 changes: 5 additions & 0 deletions banner/src/main/java/com/zj/banner/ui/config/BannerConfig.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.zj.banner.ui.config

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.layout.ContentScale
Expand All @@ -19,4 +20,8 @@ data class BannerConfig(
var contentScale: ContentScale = ContentScale.Crop,
// 是否循环播放
var repeat: Boolean = true,
// 添加项目之间的水平间距
var itemSpacing: Dp = 0.dp,
// 将水平填充添加到“居中”页面
var contentPadding: PaddingValues = PaddingValues(0.dp),
)

0 comments on commit 7621bc9

Please sign in to comment.