Skip to content

Commit 264ba6e

Browse files
Merge pull request #18 from SimformSolutionsPvtLtd/develop
Develop
2 parents 6289cd2 + e0feb9d commit 264ba6e

File tree

26 files changed

+197
-69
lines changed

26 files changed

+197
-69
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright [2021] [Simform Solutions]
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 126 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,126 @@
1-
# android-morphing-button-jetpack-compose
1+
# SSJetPackComposeProgressButton
2+
### _SSJetPackComposeProgressButton is an elegant button with a different loading animations._
3+
4+
[![Build Status](https://travis-ci.org/joemccann/dillinger.svg?branch=master)][git-repo-url] [![](https://jitpack.io/v/SimformSolutionsPvtLtd/android-morphing-button-jetpack-compose.svg)](https://jitpack.io/#SimformSolutionsPvtLtd/android-morphing-button-jetpack-compose) [![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)
5+
6+
## Features
7+
- Android’s modern toolkit - Jetpack Compose support.
8+
- Newly designed loading animation make your app atterective.
9+
- Blinking icon button for your hot-feature
10+
- Button with text, right and left icon
11+
- Different types of state makes it easy to manage button. (Idle, Loading, Success, failure)
12+
- Fully customized button (Corner radius, background, colors, animation speed etc.)
13+
14+
# 🎬 Preview
15+
16+
| On Success | On Failure |
17+
|--|--|
18+
| ![](https://github.com/SimformSolutionsPvtLtd/android-morphing-button-jetpack-compose/blob/feature/UNT-T5677_readme_and_licenece_update/gif/success.gif) | ![](https://github.com/SimformSolutionsPvtLtd/android-morphing-button-jetpack-compose/blob/feature/UNT-T5677_readme_and_licenece_update/gif/failure.gif) |
19+
20+
## Installation
21+
1. Add it in your root build.gradle at the end of repositories:
22+
23+
```groovy
24+
allprojects {
25+
repositories {
26+
...
27+
maven { url 'https://jitpack.io' }
28+
}
29+
}
30+
```
31+
32+
* Add the dependency in your app's build.gradle file
33+
34+
```groovy
35+
dependencies {
36+
implementation 'com.github.SimformSolutionsPvtLtd:android-morphing-button-jetpack-compose:Tag'
37+
}
38+
```
39+
40+
## Usage
41+
* Just use SSLoadingButton where you want button.
42+
43+
```kotlin
44+
var submitButtonState by remember { mutableStateOf(SSButtonState.IDLE) }
45+
SSLoadingButton(
46+
type = SSButtonType.CLOCK,
47+
width = 300.dp,
48+
height = 50.dp,
49+
onClick = {
50+
//Perform action on click of button and make it state to LOADING
51+
submitButtonState = SSButtonState.LOADING
52+
},
53+
assetColor = Color.Red,
54+
buttonState = submitButtonState
55+
)
56+
```
57+
```kotlin
58+
// On Success change submitButtonState to success state
59+
submitButtonState = SSButtonState.SUCCESS
60+
```
61+
```kotlin
62+
// On Failure change submitButtonState to failure state
63+
submitButtonState = SSButtonState.FAILIURE
64+
```
65+
### All Attributes
66+
------------------------
67+
68+
| Attribute | Description | Default |
69+
| --- | --- | --- |
70+
| `type` | Choose type of animation from:[CIRCLE, WHEEL, ZOOM_IN_OUT_CIRCLE, CLOCK, SPIRAL] | None |
71+
| `width` | Width to be applied to the button. | None |
72+
| `height` | Height to be applied to the button. | None |
73+
| `onClick` | Will be called when the user clicks the button. | None |
74+
| `assetColor` | Color to be applied to icon and text inside button. | None |
75+
| `buttonState` | Represent the state of button from IDLE, LOADING, SUCCESS, FAILIURE from SSButtonState. | None |
76+
| `buttonBorderStroke` | Border to draw around the button. | None |
77+
| `blinkingIcon` | Icon will be blink with size and color. | `false` |
78+
| `cornerRadius` | Corner radius to be applied to the button. | `20` |
79+
| `speedMillis` | Speed of the animation while changing the state. | `1000` |
80+
| `enabled` | Controls the enabled state of the button. | `true` |
81+
| `elevation` | It is used to resolve the elevation for this button in different. | `ButtonDefaults.elevation()` |
82+
| `colors` | Colors that will be used to resolve the background and content color for this button in different states | `ButtonDefaults.buttonColors()` |
83+
| `padding` | The spacing values to apply internally between the container and the content. | `PaddingValues(0.dp)` |
84+
| `alphaValue` | The alpha of the drawn area. | `1f` |
85+
| `leftImagePainter` | Painter to draw inside this left Icon. | `null` |
86+
| `rightImagePainter` | Painter to draw inside this right Icon. | `null` |
87+
| `successIconPainter` | Painter to draw inside this success state Icon. | `rememberVectorPainter(image = Icons.Default.Done)` |
88+
| `failureIconPainter` | Painter to draw inside this failiure state Icon. | `rememberVectorPainter(image = Icons.Outlined.Info)` |
89+
| `text` | The text to be displayed. | `null` |
90+
| `textModifier` | To apply to this text layout node. | `Modifier` |
91+
| `fontSize` | The size of glyphs to use when painting the text. | `TextUnit.Unspecified` |
92+
| `fontStyle` | The typeface variant to use when drawing the letters (e.g., italic). | `null` |
93+
| `fontFamily` | The font family to be used when rendering the text. | `null` |
94+
| `hourHandColor` | Color will be apply to hour hand in clock type animation only. | `Color.Black` |
95+
96+
97+
## Find this library useful? ❤️
98+
Support it by joining __[stargazers]__ for this repository.⭐
99+
100+
## 🤝 How to Contribute
101+
102+
Whether you're helping us fix bugs, improve the docs, or a feature request, we'd love to have you! 💪
103+
Check out our __[Contributing Guide]__ for ideas on contributing.
104+
105+
## Bugs and Feedback
106+
For bugs, feature requests, and discussion please use __[GitHub Issues]__.
107+
108+
## License
109+
```
110+
Copyright 2021 Simform Solutions
111+
112+
Licensed under the Apache License, Version 2.0 (the "License");
113+
you may not use this file except in compliance with the License.
114+
You may obtain a copy of the License at
115+
http://www.apache.org/licenses/LICENSE-2.0
116+
Unless required by applicable law or agreed to in writing, software
117+
distributed under the License is distributed on an "AS IS" BASIS,
118+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
119+
See the License for the specific language governing permissions and limitations under the License.
120+
```
121+
122+
[//]: # (These are reference links used in the body of this note and get stripped out when the markdown processor does its job. There is no need to format nicely because it shouldn't be seen. Thanks SO - http://stackoverflow.com/questions/4823468/store-comments-in-markdown-syntax)
123+
[git-repo-url]: <https://github.com/SimformSolutionsPvtLtd/android-morphing-button-jetpack-compose.git>
124+
[stargazers]: <https://github.com/SimformSolutionsPvtLtd/android-morphing-button-jetpack-compose/stargazers>
125+
[Contributing Guide]: <https://github.com/SimformSolutionsPvtLtd/android-morphing-button-jetpack-compose/blob/main/CONTRIBUTING.md>
126+
[GitHub Issues]: <https://github.com/SimformSolutionsPvtLtd/android-morphing-button-jetpack-compose/issues>

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ dependencies {
5050
implementation "androidx.compose.material:material:$compose_version"
5151
implementation "androidx.compose.ui:ui-tooling:$compose_version"
5252
implementation 'androidx.activity:activity-compose:1.3.0-rc02'
53-
implementation project(path: ':ssloadingbuttonlibrary')
53+
implementation project(path: ':ssjetpackcomposeprogressbutton')
5454
}

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.simform.ssloadingbuttonandroid">
3+
package="com.simform.ssjetpackcomposeprogressbutton">
44

55
<application
66
android:allowBackup="true"
@@ -10,7 +10,7 @@
1010
android:supportsRtl="true"
1111
android:theme="@style/Theme.SSLoadingButtonAndroid">
1212
<activity
13-
android:name=".MainActivity"
13+
android:name="com.simform.ssjetpackcomposeprogressbutton.MainActivity"
1414
android:exported="true"
1515
android:label="@string/app_name"
1616
android:theme="@style/Theme.SSLoadingButtonAndroid.NoActionBar">

app/src/main/java/com/simform/ssloadingbuttonandroid/MainActivity.kt renamed to app/src/main/java/com/simform/ssjetpackcomposeprogressbutton/MainActivity.kt

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.simform.ssloadingbuttonandroid
1+
package com.simform.ssjetpackcomposeprogressbutton
22

33
import android.os.Bundle
44
import androidx.activity.ComponentActivity
@@ -15,6 +15,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
1515
import androidx.compose.foundation.layout.padding
1616
import androidx.compose.foundation.lazy.LazyColumn
1717
import androidx.compose.material.Button
18+
import androidx.compose.material.ButtonColors
1819
import androidx.compose.material.ButtonDefaults
1920
import androidx.compose.material.Text
2021
import androidx.compose.material.icons.Icons
@@ -31,6 +32,7 @@ import androidx.compose.ui.Alignment
3132
import androidx.compose.ui.Modifier
3233
import androidx.compose.ui.graphics.Color
3334
import androidx.compose.ui.graphics.SolidColor
35+
import androidx.compose.ui.graphics.graphicsLayer
3436
import androidx.compose.ui.graphics.vector.rememberVectorPainter
3537
import androidx.compose.ui.res.colorResource
3638
import androidx.compose.ui.res.stringResource
@@ -39,16 +41,16 @@ import androidx.compose.ui.text.font.FontStyle
3941
import androidx.compose.ui.tooling.preview.Preview
4042
import androidx.compose.ui.unit.dp
4143
import androidx.compose.ui.unit.sp
42-
import com.simform.ssloadingbuttonandroid.utils.COMMON_HEIGHT
43-
import com.simform.ssloadingbuttonandroid.utils.COMMON_WIDTH
44-
import com.simform.ssloadingbuttonandroid.utils.forty
45-
import com.simform.ssloadingbuttonandroid.utils.oneFloat
46-
import com.simform.ssloadingbuttonandroid.utils.six
47-
import com.simform.ssloadingbuttonandroid.utils.two
48-
import com.simform.ssloadingbuttonandroid.utils.zero
49-
import com.simform.ssloadingbuttonlibrary.SSButtonState
50-
import com.simform.ssloadingbuttonlibrary.SSButtonType
51-
import com.simform.ssloadingbuttonlibrary.SSLoadingButton
44+
import com.simform.ssjetpackcomposeprogressbutton.utils.COMMON_HEIGHT
45+
import com.simform.ssjetpackcomposeprogressbutton.utils.COMMON_WIDTH
46+
import com.simform.ssjetpackcomposeprogressbutton.utils.forty
47+
import com.simform.ssjetpackcomposeprogressbutton.utils.oneFloat
48+
import com.simform.ssjetpackcomposeprogressbutton.utils.six
49+
import com.simform.ssjetpackcomposeprogressbutton.utils.two
50+
import com.simform.ssjetpackcomposeprogressbutton.utils.zero
51+
import com.simform.ssjetpackcomposeprogressbuttonlibrary.SSButtonState
52+
import com.simform.ssjetpackcomposeprogressbuttonlibrary.SSButtonType
53+
import com.simform.ssjetpackcomposeprogressbuttonlibrary.SSJetPackComposeProgressButton
5254

5355
class MainActivity : ComponentActivity() {
5456
override fun onCreate(savedInstanceState: Bundle?) {
@@ -107,9 +109,9 @@ fun SSLoadingButtonExample() {
107109
modifier = Modifier
108110
.padding(six.dp)
109111
.weight(oneFloat),
110-
elevation = ButtonDefaults.elevation(),
112+
elevation = ButtonDefaults.elevation(), colors = ButtonDefaults.buttonColors(backgroundColor = colorResource(id = R.color.light_blue))
111113
) {
112-
Text(text = stringResource(id = R.string.on_success))
114+
Text(text = stringResource(id = R.string.on_success), color = Color.White )
113115
}
114116
Button(
115117
onClick = {
@@ -127,15 +129,15 @@ fun SSLoadingButtonExample() {
127129
modifier = Modifier
128130
.padding(six.dp)
129131
.weight(1f),
130-
elevation = ButtonDefaults.elevation()
132+
elevation = ButtonDefaults.elevation(), colors = ButtonDefaults.buttonColors(backgroundColor = colorResource(id = R.color.light_blue))
131133
) {
132-
Text(text = stringResource(id = R.string.on_failure))
134+
Text(text = stringResource(id = R.string.on_failure), color = Color.White)
133135
}
134136
}
135137
}
136138
//Various example of SSLoadingButton
137139
item {
138-
SSLoadingButton(
140+
SSJetPackComposeProgressButton(
139141
assetColor = Color.Red,
140142
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White),
141143
buttonBorderStroke = BorderStroke(two.dp, SolidColor(Color.Red)),
@@ -145,7 +147,7 @@ fun SSLoadingButtonExample() {
145147
width = COMMON_WIDTH.dp, height = COMMON_HEIGHT.dp, padding = PaddingValues(six.dp),
146148
leftImagePainter = rememberVectorPainter(image = Icons.Default.Home)
147149
)
148-
SSLoadingButton(
150+
SSJetPackComposeProgressButton(
149151
assetColor = colorResource(id = R.color.dark_green),
150152
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White),
151153
buttonBorderStroke = BorderStroke(
@@ -158,7 +160,7 @@ fun SSLoadingButtonExample() {
158160
width = COMMON_WIDTH.dp, height = COMMON_HEIGHT.dp, padding = PaddingValues(six.dp),
159161
leftImagePainter = rememberVectorPainter(image = Icons.Default.Home)
160162
)
161-
SSLoadingButton(
163+
SSJetPackComposeProgressButton(
162164
assetColor = Color.Blue,
163165
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White),
164166
buttonBorderStroke = BorderStroke(two.dp, SolidColor(Color.Blue)),
@@ -168,7 +170,7 @@ fun SSLoadingButtonExample() {
168170
width = COMMON_WIDTH.dp, height = COMMON_HEIGHT.dp, padding = PaddingValues(six.dp),
169171
leftImagePainter = rememberVectorPainter(image = Icons.Default.Home)
170172
)
171-
SSLoadingButton(
173+
SSJetPackComposeProgressButton(
172174
assetColor = Color.Red,
173175
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White),
174176
buttonBorderStroke = BorderStroke(two.dp, SolidColor(Color.Red)),
@@ -178,7 +180,7 @@ fun SSLoadingButtonExample() {
178180
width = COMMON_WIDTH.dp, height = COMMON_HEIGHT.dp, padding = PaddingValues(six.dp),
179181
leftImagePainter = rememberVectorPainter(image = Icons.Default.Home)
180182
)
181-
SSLoadingButton(
183+
SSJetPackComposeProgressButton(
182184
assetColor = Color.Blue,
183185
colors = ButtonDefaults.buttonColors(backgroundColor = Color.White),
184186
buttonBorderStroke = BorderStroke(two.dp, SolidColor(Color.Blue)),
@@ -188,7 +190,7 @@ fun SSLoadingButtonExample() {
188190
width = COMMON_WIDTH.dp, height = COMMON_HEIGHT.dp, padding = PaddingValues(six.dp),
189191
leftImagePainter = rememberVectorPainter(image = Icons.Default.Home)
190192
)
191-
SSLoadingButton(
193+
SSJetPackComposeProgressButton(
192194
assetColor = Color.White,
193195
colors = ButtonDefaults.buttonColors(backgroundColor = Color.Red),
194196
type = SSButtonType.CIRCLE,
@@ -197,7 +199,7 @@ fun SSLoadingButtonExample() {
197199
width = COMMON_WIDTH.dp, height = COMMON_HEIGHT.dp, padding = PaddingValues(six.dp),
198200
leftImagePainter = rememberVectorPainter(image = Icons.Default.Person)
199201
)
200-
SSLoadingButton(
202+
SSJetPackComposeProgressButton(
201203
assetColor = Color.Yellow,
202204
type = SSButtonType.CLOCK,
203205
onClick = { blinkingIcon = SSButtonState.LOADING },
@@ -209,7 +211,7 @@ fun SSLoadingButtonExample() {
209211
padding = PaddingValues(six.dp),
210212
hourHandColor = Color.Red
211213
)
212-
SSLoadingButton(
214+
SSJetPackComposeProgressButton(
213215
assetColor = Color.White,
214216
colors = ButtonDefaults.buttonColors(backgroundColor = colorResource(id = R.color.yellow)),
215217
buttonBorderStroke = BorderStroke(
@@ -228,7 +230,7 @@ fun SSLoadingButtonExample() {
228230
fontFamily = FontFamily.Monospace,
229231
textModifier = Modifier.padding(six.dp),
230232
)
231-
SSLoadingButton(
233+
SSJetPackComposeProgressButton(
232234
assetColor = Color.White,
233235
type = SSButtonType.WHEEL,
234236
onClick = { textWithIconState = SSButtonState.LOADING },
@@ -240,9 +242,10 @@ fun SSLoadingButtonExample() {
240242
fontFamily = FontFamily.SansSerif,
241243
textModifier = Modifier.padding(six.dp),
242244
blinkingIcon = true,
243-
padding = PaddingValues(six.dp)
245+
padding = PaddingValues(six.dp),
246+
colors = ButtonDefaults.buttonColors( backgroundColor = colorResource(id = R.color.light_blue))
244247
)
245-
SSLoadingButton(
248+
SSJetPackComposeProgressButton(
246249
assetColor = Color.White,
247250
type = SSButtonType.SPIRAL,
248251
onClick = { textWithRightButton = SSButtonState.LOADING },

app/src/main/java/com/simform/ssloadingbuttonandroid/utils/Constant.kt renamed to app/src/main/java/com/simform/ssjetpackcomposeprogressbutton/utils/Constant.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.simform.ssloadingbuttonandroid.utils
1+
package com.simform.ssjetpackcomposeprogressbutton.utils
22

33

44
const val COMMON_WIDTH = 370

app/src/main/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
<color name="white">#FFFFFFFF</color>
1010
<color name="dark_green">#07a34d</color>
1111
<color name="yellow">#ffbb00</color>
12+
<color name="light_blue">#23395D</color>
1213
</resources>

gif/failure.gif

13.4 MB
Loading

gif/success.gif

12.7 MB
Loading

settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ dependencyResolutionManagement {
66
maven { url 'https://jitpack.io' }
77
}
88
}
9-
rootProject.name = "SSLoadingButtonAndroid"
9+
rootProject.name = "SSJetPackComposeProgressButton"
1010
include ':app'
11-
include ':ssloadingbuttonlibrary'
11+
include ':ssjetpackcomposeprogressbutton'

0 commit comments

Comments
 (0)