From ce0c47c4af0212661c224f7f105252bf356d6197 Mon Sep 17 00:00:00 2001 From: zhujiang2 Date: Fri, 18 Jun 2021 16:35:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7Compose=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=88=B01.0.0-beta09?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/compiler.xml | 2 +- app/build.gradle | 8 ++++---- banner/build.gradle | 2 +- .../main/java/com/zj/banner/BannerPager.kt | 4 ++-- .../zj/banner/ui/indicator/NumberIndicator.kt | 20 +++++++++++-------- build.gradle | 4 ++-- 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 7e7ee62..fb7f4a8 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d016b3d..20449e9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -43,13 +43,13 @@ android { dependencies { - implementation 'androidx.core:core-ktx:1.3.2' - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.5.0' + implementation 'androidx.appcompat:appcompat:1.3.0' implementation 'com.google.android.material:material:1.3.0' implementation "androidx.compose.ui:ui:$compose_version" implementation "androidx.compose.material:material:$compose_version" - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0' - implementation 'androidx.activity:activity-compose:1.3.0-alpha04' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' + implementation 'androidx.activity:activity-compose:1.3.0-beta01' //implementation 'com.github.zhujiang521:Banner:1.3.3' implementation project(path: ':banner') testImplementation 'junit:junit:4.13.2' diff --git a/banner/build.gradle b/banner/build.gradle index 9133d73..3e42e41 100644 --- a/banner/build.gradle +++ b/banner/build.gradle @@ -69,7 +69,7 @@ android { dependencies { implementation "androidx.compose.material:material:$compose_version" - def accompanist_version = "0.10.0" + def accompanist_version = "0.12.0" api "com.google.accompanist:accompanist-pager:$accompanist_version" api "com.google.accompanist:accompanist-coil:$accompanist_version" api "com.google.accompanist:accompanist-insets:$accompanist_version" diff --git a/banner/src/main/java/com/zj/banner/BannerPager.kt b/banner/src/main/java/com/zj/banner/BannerPager.kt index dcd8e32..1577bc7 100644 --- a/banner/src/main/java/com/zj/banner/BannerPager.kt +++ b/banner/src/main/java/com/zj/banner/BannerPager.kt @@ -49,7 +49,7 @@ fun BannerPager( val pagerState = rememberPagerState(pageCount = items.size) if (config.repeat) { - startBanner(pagerState, config.intervalTime) + StartBanner(pagerState, config.intervalTime) } Box(modifier = modifier.height(config.bannerHeight)) { @@ -76,7 +76,7 @@ var mTimerTask: TimerTask? = null @OptIn(ExperimentalPagerApi::class) @Composable -fun startBanner(pagerState: PagerState, intervalTime: Long) { +fun StartBanner(pagerState: PagerState, intervalTime: Long) { val coroutineScope = rememberCoroutineScope() mTimer?.cancel() mTimerTask?.cancel() diff --git a/banner/src/main/java/com/zj/banner/ui/indicator/NumberIndicator.kt b/banner/src/main/java/com/zj/banner/ui/indicator/NumberIndicator.kt index b9ec3da..d8e4901 100644 --- a/banner/src/main/java/com/zj/banner/ui/indicator/NumberIndicator.kt +++ b/banner/src/main/java/com/zj/banner/ui/indicator/NumberIndicator.kt @@ -30,14 +30,14 @@ import com.zj.banner.ui.indicator.BannerGravity.BottomRight * @param gravity 指示器位置 */ class NumberIndicator( - var backgroundColor: Color = Color(30, 30, 33, 90), - var numberColor: Color = Color.White, - var circleSize: Dp = 35.dp, - var fontSize: TextUnit = 15.sp, + private var backgroundColor: Color = Color(30, 30, 33, 90), + private var numberColor: Color = Color.White, + private var circleSize: Dp = 35.dp, + private var fontSize: TextUnit = 15.sp, override var gravity: Int = BottomRight, ) : Indicator() { - @ExperimentalPagerApi + @OptIn(ExperimentalPagerApi::class) @Composable override fun DrawIndicator(pagerState: PagerState) { val alignment: Alignment = when (gravity) { @@ -52,14 +52,18 @@ class NumberIndicator( } else -> Alignment.BottomEnd } - Box(modifier = Modifier.fillMaxSize().padding(10.dp), contentAlignment = alignment) { + Box(modifier = Modifier + .fillMaxSize() + .padding(10.dp), contentAlignment = alignment) { Box( - modifier = Modifier.size(circleSize).clip(CircleShape) + modifier = Modifier + .size(circleSize) + .clip(CircleShape) .background(color = backgroundColor), contentAlignment = Alignment.Center ) { Text( - "${pagerState.currentPage + 1}/${pagerState.pageCount}", + text = "${pagerState.currentPage + 1}/${pagerState.pageCount}", color = numberColor, fontSize = fontSize ) diff --git a/build.gradle b/build.gradle index a19be6c..073c95b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { - compose_version = '1.0.0-beta07' + compose_version = '1.0.0-beta09' } repositories { google() @@ -11,7 +11,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:7.0.0-beta03' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files