From 7621bc93213324a2d97535371fdef3c79a765f40 Mon Sep 17 00:00:00 2001 From: zhujiang2 Date: Wed, 23 Feb 2022 21:51:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BABanner=E6=96=B0=E5=A2=9EPager=E7=9A=84?= =?UTF-8?q?contentPadding=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新依赖版本 --- app/build.gradle | 6 +++--- banner/build.gradle | 2 +- banner/src/main/java/com/zj/banner/BannerPager.kt | 9 ++++++--- .../main/java/com/zj/banner/ui/config/BannerConfig.kt | 5 +++++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index acbc519..9f02fd8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/banner/build.gradle b/banner/build.gradle index 71b5b37..800013f 100644 --- a/banner/build.gradle +++ b/banner/build.gradle @@ -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) { diff --git a/banner/src/main/java/com/zj/banner/BannerPager.kt b/banner/src/main/java/com/zj/banner/BannerPager.kt index f562ccc..76bed36 100644 --- a/banner/src/main/java/com/zj/banner/BannerPager.kt +++ b/banner/src/main/java/com/zj/banner/BannerPager.kt @@ -54,7 +54,12 @@ fun 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, @@ -111,8 +116,6 @@ fun BannerPager( } - - @ExperimentalPagerApi @Composable fun StartBanner(pagerState: PagerState, intervalTime: Long) { diff --git a/banner/src/main/java/com/zj/banner/ui/config/BannerConfig.kt b/banner/src/main/java/com/zj/banner/ui/config/BannerConfig.kt index a04ac39..0dc9193 100644 --- a/banner/src/main/java/com/zj/banner/ui/config/BannerConfig.kt +++ b/banner/src/main/java/com/zj/banner/ui/config/BannerConfig.kt @@ -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 @@ -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), ) \ No newline at end of file