Skip to content

Commit 19b7a1f

Browse files
authored
Develop to main (#54)
* 🐎 UNT-13932 Disabled button click when it's in loading state * 🐎 #38 Added shouldAutoMoveToIdleState parameter. * ⚡ Dependency version updated. * ⚡ jitpack yml updated * Readme updated ---------
1 parent 3a27c59 commit 19b7a1f

File tree

8 files changed

+74
-60
lines changed

8 files changed

+74
-60
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SSJetPackComposeProgressButton
44
### _SSJetPackComposeProgressButton is an elegant button with a different loading animations which makes your app attractive._
55

6-
[![Build Status](https://travis-ci.org/joemccann/dillinger.svg?branch=master)][git-repo-url] [![](https://jitpack.io/v/SimformSolutionsPvtLtd/SSJetPackComposeProgressButton.svg)](https://jitpack.io/#SimformSolutionsPvtLtd/SSJetPackComposeProgressButton) [![Kotlin Version](https://img.shields.io/badge/Kotlin-v1.5.10-blue.svg)](https://kotlinlang.org) [![Platform](https://img.shields.io/badge/Platform-Android-green.svg?style=flat)](https://www.android.com/) [![API](https://img.shields.io/badge/API-21%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=21) [![Android Arsenal]( https://img.shields.io/badge/Android%20Arsenal-SSJetPackComposeProgressButton-green.svg?style=flat )]( https://android-arsenal.com/details/1/8302 )
6+
[![CI Status](https://img.shields.io/github/v/release/SimformSolutionsPvtLtd/SSJetPackComposeProgressButton?style=flat)](https://travis-ci.org/SimformSolutionsPvtLtd/SSJetPackComposeProgressButton) [![](https://jitpack.io/v/SimformSolutionsPvtLtd/SSJetPackComposeProgressButton.svg)](https://jitpack.io/#SimformSolutionsPvtLtd/SSJetPackComposeProgressButton) [![Kotlin Version](https://img.shields.io/badge/Kotlin-v1.5.10-blue.svg)](https://kotlinlang.org) [![Platform](https://img.shields.io/badge/Platform-Android-green.svg?style=flat)](https://www.android.com/) [![API](https://img.shields.io/badge/API-21%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=21) [![Android Arsenal]( https://img.shields.io/badge/Android%20Arsenal-SSJetPackComposeProgressButton-green.svg?style=flat )]( https://android-arsenal.com/details/1/8302 )
77

88
# Jetpack Compose
99
Jetpack Compose is Android’s modern toolkit for building native UI. It simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs.
@@ -48,7 +48,7 @@ Please get **Android Studio Arctic Fox 2020.3.1** or above [from here](https://d
4848

4949
```groovy
5050
dependencies {
51-
implementation 'com.github.SimformSolutionsPvtLtd:SSJetPackComposeProgressButton:1.0.7'
51+
implementation 'com.github.SimformSolutionsPvtLtd:SSJetPackComposeProgressButton:1.0.8'
5252
}
5353
```
5454

@@ -155,6 +155,7 @@ Please get **Android Studio Arctic Fox 2020.3.1** or above [from here](https://d
155155
| `customLoadingIconPainter` | painter [Painter] to draw your custom loading icon. | `painterResource(id = R.drawable.simform_logo)` |
156156
| `customLoadingEffect` | Custom loading animation type like roation, zoom in out etc. | `SSCustomLoadingEffect( rotation = false, zoomInOut = false, colorChanger = false)` |
157157
| `customLoadingPadding` | Spacing between button border and loading icon. | `0` |
158+
| `shouldAutoMoveToIdleState` | In case of success/failure state after defined time it move back to idle state. | `true` |
158159

159160
## Our JetPackCompose Sample
160161
[SSComposeCookBook](https://github.com/SimformSolutionsPvtLtd/SSComposeCookBook) : A Collection of major Jetpack compose UI components which are commonly used.

app/build.gradle

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ plugins {
44
}
55

66
android {
7-
compileSdk 33
7+
compileSdk 34
88

99
defaultConfig {
1010
applicationId "com.simform.ssjetpackcomposeprogressbutton"
1111
minSdk 21
12-
targetSdk 33
12+
targetSdk 34
1313
versionCode 2
1414
versionName "1.0.7"
1515

@@ -26,11 +26,11 @@ android {
2626
}
2727
}
2828
compileOptions {
29-
sourceCompatibility JavaVersion.VERSION_11
30-
targetCompatibility JavaVersion.VERSION_11
29+
sourceCompatibility JavaVersion.VERSION_17
30+
targetCompatibility JavaVersion.VERSION_17
3131
}
3232
kotlinOptions {
33-
jvmTarget = '11'
33+
jvmTarget = '17'
3434
}
3535
buildFeatures {
3636
compose true
@@ -41,11 +41,11 @@ android {
4141
}
4242

4343
dependencies {
44-
implementation 'androidx.appcompat:appcompat:1.6.0-rc01'
45-
implementation 'com.google.android.material:material:1.6.1'
46-
implementation "androidx.compose.ui:ui:1.2.1"
44+
implementation 'androidx.appcompat:appcompat:1.6.1'
45+
implementation 'com.google.android.material:material:1.11.0'
46+
implementation "androidx.compose.ui:ui:1.5.4"
4747
implementation "androidx.compose.material:material:$compose_version"
4848
implementation "androidx.compose.ui:ui-tooling:$compose_version"
49-
implementation 'androidx.activity:activity-compose:1.5.1'
49+
implementation 'androidx.activity:activity-compose:1.8.2'
5050
implementation project(path: ':ssjetpackcomposeprogressbutton')
5151
}

app/src/main/java/com/simform/ssjetpackcomposeprogressbutton/MainActivity.kt

+15-14
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ fun SSLoadingButtonExample() {
165165
item {
166166
SSJetPackComposeProgressButton(
167167
assetColor = colorResource(id = R.color.pink),
168-
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White),
168+
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White, disabledBackgroundColor = Color.White),
169169
buttonBorderStroke = BorderStroke(COMMON_BORDER_WIDTH.dp, SolidColor(colorResource(id = R.color.pink))),
170170
type = SSButtonType.CIRCLE,
171171
onClick = { roundedProgressState2 = SSButtonState.LOADING },
@@ -174,11 +174,12 @@ fun SSLoadingButtonExample() {
174174
height = COMMON_HEIGHT.dp,
175175
padding = PaddingValues(TWELVE.dp),
176176
cornerRadius = COMMON_CORNER_RADIUS,
177-
leftImagePainter = rememberVectorPainter(image = Icons.Default.Home)
177+
leftImagePainter = rememberVectorPainter(image = Icons.Default.Home),
178+
shouldAutoMoveToIdleState = false
178179
)
179180
SSJetPackComposeProgressButton(
180181
assetColor = colorResource(id = R.color.pink),
181-
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White),
182+
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White, disabledBackgroundColor = Color.White),
182183
buttonBorderStroke = BorderStroke(
183184
COMMON_BORDER_WIDTH.dp,
184185
SolidColor(colorResource(id = R.color.pink))
@@ -194,7 +195,7 @@ fun SSLoadingButtonExample() {
194195
)
195196
SSJetPackComposeProgressButton(
196197
assetColor = colorResource(id = R.color.pink),
197-
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White),
198+
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White, disabledBackgroundColor = Color.White),
198199
buttonBorderStroke = BorderStroke(COMMON_BORDER_WIDTH.dp, SolidColor(colorResource(id = R.color.pink))),
199200
type = SSButtonType.ZOOM_IN_OUT_CIRCLE,
200201
onClick = { zoomInOutState = SSButtonState.LOADING },
@@ -207,7 +208,7 @@ fun SSLoadingButtonExample() {
207208
)
208209
SSJetPackComposeProgressButton(
209210
assetColor = colorResource(id = R.color.pink),
210-
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White),
211+
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White, disabledBackgroundColor = Color.White),
211212
buttonBorderStroke = BorderStroke(COMMON_BORDER_WIDTH.dp, SolidColor(colorResource(id = R.color.pink))),
212213
type = SSButtonType.CLOCK,
213214
onClick = { clockState = SSButtonState.LOADING },
@@ -220,7 +221,7 @@ fun SSLoadingButtonExample() {
220221
)
221222
SSJetPackComposeProgressButton(
222223
assetColor = colorResource(id = R.color.pink),
223-
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White),
224+
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White, disabledBackgroundColor = Color.White),
224225
buttonBorderStroke = BorderStroke(COMMON_BORDER_WIDTH.dp, SolidColor(colorResource(id = R.color.pink))),
225226
type = SSButtonType.SPIRAL,
226227
onClick = { spiralState = SSButtonState.LOADING },
@@ -233,7 +234,7 @@ fun SSLoadingButtonExample() {
233234
)
234235
SSJetPackComposeProgressButton(
235236
assetColor = Color.White,
236-
colors = ButtonDefaults.buttonColors(backgroundColor = colorResource(id = R.color.pink)),
237+
colors = ButtonDefaults.buttonColors(backgroundColor = colorResource(id = R.color.pink), disabledBackgroundColor = colorResource(id = R.color.pink)),
237238
type = SSButtonType.CIRCLE,
238239
onClick = { roundedProgressState = SSButtonState.LOADING },
239240
buttonState = roundedProgressState,
@@ -254,12 +255,12 @@ fun SSLoadingButtonExample() {
254255
leftImagePainter = rememberVectorPainter(image = Icons.Default.FavoriteBorder),
255256
padding = PaddingValues(TWELVE.dp),
256257
cornerRadius = COMMON_CORNER_RADIUS,
257-
colors = ButtonDefaults.buttonColors(backgroundColor = colorResource(id = R.color.pink)),
258+
colors = ButtonDefaults.buttonColors(backgroundColor = colorResource(id = R.color.pink), disabledBackgroundColor = colorResource(id = R.color.pink)),
258259
hourHandColor = colorResource(id = R.color.handColor)
259260
)
260261
SSJetPackComposeProgressButton(
261262
assetColor = Color.White,
262-
colors = ButtonDefaults.buttonColors(backgroundColor = colorResource(id = R.color.pink)),
263+
colors = ButtonDefaults.buttonColors(backgroundColor = colorResource(id = R.color.pink), disabledBackgroundColor = colorResource(id = R.color.pink)),
263264
type = SSButtonType.ZOOM_IN_OUT_CIRCLE,
264265
onClick = { ssTextButtonState = SSButtonState.LOADING },
265266
buttonState = ssTextButtonState,
@@ -290,7 +291,7 @@ fun SSLoadingButtonExample() {
290291
blinkingIcon = true,
291292
padding = PaddingValues(TWELVE.dp),
292293
cornerRadius = COMMON_CORNER_RADIUS,
293-
colors = ButtonDefaults.buttonColors(backgroundColor = colorResource(id = R.color.pink))
294+
colors = ButtonDefaults.buttonColors(backgroundColor = colorResource(id = R.color.pink), disabledBackgroundColor = colorResource(id = R.color.pink))
294295
)
295296
SSJetPackComposeProgressButton(
296297
assetColor = Color.White,
@@ -307,7 +308,7 @@ fun SSLoadingButtonExample() {
307308
fontWeight = FontWeight.Bold,
308309
padding = PaddingValues(TWELVE.dp),
309310
cornerRadius = COMMON_CORNER_RADIUS,
310-
colors = ButtonDefaults.buttonColors(backgroundColor = colorResource(id = R.color.pink))
311+
colors = ButtonDefaults.buttonColors(backgroundColor = colorResource(id = R.color.pink), disabledBackgroundColor = colorResource(id = R.color.pink))
311312
)
312313
Spacer(modifier = Modifier.size(COMMON_HEIGHT.dp))
313314
SSJetPackComposeProgressButton(
@@ -324,7 +325,7 @@ fun SSLoadingButtonExample() {
324325
zoomInOut = false,
325326
colorChanger = false
326327
),
327-
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White),
328+
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White, disabledBackgroundColor = Color.White),
328329
padding = PaddingValues(TWELVE.dp),
329330
cornerRadius = COMMON_CORNER_RADIUS,
330331
text = stringResource(id = R.string.simform),
@@ -348,7 +349,7 @@ fun SSLoadingButtonExample() {
348349
zoomInOut = true,
349350
colorChanger = false
350351
),
351-
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White),
352+
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White, disabledBackgroundColor = Color.White),
352353
padding = PaddingValues(TWELVE.dp),
353354
cornerRadius = COMMON_CORNER_RADIUS,
354355
text = stringResource(id = R.string.simform),
@@ -372,7 +373,7 @@ fun SSLoadingButtonExample() {
372373
zoomInOut = false,
373374
colorChanger = true
374375
),
375-
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White),
376+
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White, disabledBackgroundColor = Color.White),
376377
padding = PaddingValues(ten.dp),
377378
cornerRadius = COMMON_CORNER_RADIUS,
378379
text = stringResource(id = R.string.simform),

build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
buildscript {
22
ext {
3-
compose_version = '1.2.1'
3+
compose_version = '1.5.4'
44
compose_compiler = '1.3.1'
55
}
66
repositories {
77
google()
88
mavenCentral()
99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:7.2.2'
11+
classpath 'com.android.tools.build:gradle:7.4.2'
1212
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'
1313
}
1414
configurations {
15-
all {
15+
configureEach {
1616
exclude group: 'androidx.lifecycle', module: 'lifecycle-viewmodel-ktx'
1717
}
1818
}
1919
}
2020

21-
task clean(type: Delete) {
21+
tasks.register('clean', Delete) {
2222
delete rootProject.buildDir
2323
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Thu May 06 09:44:53 IST 2021
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

jitpack.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
jdk:
2-
- openjdk11
2+
- openjdk17
3+
before_install:
4+
- sdk install java 17.0.3-tem
5+
- sdk use java 17.0.3-tem

ssjetpackcomposeprogressbutton/build.gradle

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ afterEvaluate {
1919
}
2020

2121
android {
22-
compileSdk 33
22+
compileSdk 34
2323

2424
defaultConfig {
2525
minSdk 21
26-
targetSdk 33
26+
targetSdk 34
2727

2828
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2929
consumerProguardFiles "consumer-rules.pro"
@@ -37,12 +37,12 @@ android {
3737
}
3838

3939
compileOptions {
40-
sourceCompatibility JavaVersion.VERSION_11
41-
targetCompatibility JavaVersion.VERSION_11
40+
sourceCompatibility JavaVersion.VERSION_17
41+
targetCompatibility JavaVersion.VERSION_17
4242
}
4343

4444
kotlinOptions {
45-
jvmTarget = '11'
45+
jvmTarget = '17'
4646
}
4747

4848
buildFeatures {
@@ -58,8 +58,8 @@ android {
5858
dependencies {
5959

6060
testImplementation 'junit:junit:4.13.2'
61-
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
62-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
61+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
62+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
6363
implementation "androidx.compose.ui:ui:$compose_version"
6464
implementation "androidx.compose.material:material:$compose_version"
6565
}

ssjetpackcomposeprogressbutton/src/main/java/com/simform/ssjetpackcomposeprogressbuttonlibrary/SSJetPackComposeProgressButton.kt

+31-22
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ import kotlinx.coroutines.delay
8686
* @param customLoadingIconPainter painter [Painter] to draw your custom loading icon.
8787
* @param customLoadingEffect custom loading animation type.
8888
* @param customLoadingPadding spacing between button border and loading icon.
89+
* @param shouldAutoMoveToIdleState In case of success/failure state after defined time it move back to idle state
8990
*/
9091

9192
@Composable
@@ -124,7 +125,8 @@ fun SSJetPackComposeProgressButton(
124125
zoomInOut = false,
125126
colorChanger = false
126127
),
127-
customLoadingPadding: Int = ZERO
128+
customLoadingPadding: Int = ZERO,
129+
shouldAutoMoveToIdleState: Boolean = true
128130
) {
129131
var buttonWidth by remember { mutableStateOf(width) }
130132
var buttonHeight by remember { mutableStateOf(height) }
@@ -175,17 +177,20 @@ fun SSJetPackComposeProgressButton(
175177
successIconAlphaValue = oneFloat
176178
progressAlphaValue = zeroFloat
177179
cornerRadiusValue = fifty
178-
//Delay to show success icon and then IDLE state
179-
delay((speedMillis * two).toLong())
180-
if (height > width) {
181-
buttonHeight = height
182-
} else {
183-
buttonWidth = width
180+
181+
if (shouldAutoMoveToIdleState) {
182+
//Delay to show success icon and then IDLE state
183+
delay((speedMillis * two).toLong())
184+
if (height > width) {
185+
buttonHeight = height
186+
} else {
187+
buttonWidth = width
188+
}
189+
iconAlphaValue = oneFloat
190+
failureAlphaValue = zeroFloat
191+
successIconAlphaValue = zeroFloat
192+
cornerRadiusValue = cornerRadius
184193
}
185-
iconAlphaValue = oneFloat
186-
failureAlphaValue = zeroFloat
187-
successIconAlphaValue = zeroFloat
188-
cornerRadiusValue = cornerRadius
189194
})
190195
}
191196
SSButtonState.FAILURE -> {
@@ -200,17 +205,21 @@ fun SSJetPackComposeProgressButton(
200205
progressAlphaValue = zeroFloat
201206
failureAlphaValue = oneFloat
202207
cornerRadiusValue = fifty
203-
//Delay to show failure icon and then IDLE state
204-
delay((speedMillis * two).toLong())
205-
if (height > width) {
206-
buttonHeight = height
207-
} else {
208-
buttonWidth = width
208+
209+
if (shouldAutoMoveToIdleState) {
210+
//Delay to show failure icon and then IDLE state
211+
delay((speedMillis * two).toLong())
212+
213+
if (height > width) {
214+
buttonHeight = height
215+
} else {
216+
buttonWidth = width
217+
}
218+
iconAlphaValue = oneFloat
219+
failureAlphaValue = zeroFloat
220+
successIconAlphaValue = zeroFloat
221+
cornerRadiusValue = cornerRadius
209222
}
210-
iconAlphaValue = oneFloat
211-
failureAlphaValue = zeroFloat
212-
successIconAlphaValue = zeroFloat
213-
cornerRadiusValue = cornerRadius
214223
})
215224
}
216225
}
@@ -230,7 +239,7 @@ fun SSJetPackComposeProgressButton(
230239
durationMillis = speedMillis
231240
)
232241
),
233-
enabled = enabled,
242+
enabled = enabled && buttonState != SSButtonState.LOADING,
234243
elevation = elevation,
235244
shape = RoundedCornerShape(ssAnimateIntAsState(cornerRadiusValue, speedMillis)),
236245
border = buttonBorderStroke,

0 commit comments

Comments
 (0)