SSJetPackComposeProgressButton is an elegant button with a different loading animations. 🚀

Overview

alt text

SSJetPackComposeProgressButton

SSJetPackComposeProgressButton is an elegant button with a different loading animations which makes your app attractive.

Build Status Kotlin Version Platform API

Jetpack Compose

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.

How to get started

Please get Android Studio Arctic Fox 2020.3.1 or above from here and use JDK 11 to build this project.

Features

  • Android’s modern toolkit - Jetpack Compose support.
  • Newly designed loading animation make your app attractive.
  • Blinking icon button for your hot-feature.
  • Button with text, right and left icon.
  • Different types of state makes it easy to manage button. (Idle, Loading, Success, Failure)
  • Fully customized button (Corner radius, background, colors, animation speed etc.)
  • Customize button loading animation with your logo and special animation effect.

🎬 Preview

On Success On Failure

🎬 Customized loading animation

On Success On Failure

Installation

  1. Add it in your root build.gradle at the end of repositories:

    allprojects {
    	repositories {
    		...
    		maven { url 'https://jitpack.io' }
    	}
    }
  • Add the dependency in your app's build.gradle file

     dependencies {
             implementation 'com.github.SimformSolutionsPvtLtd:SSJetPackComposeProgressButton:1.0.6'
     }

Usage

  • Just use SSJetPackComposeProgressButton where you want button.

     var submitButtonState by remember { mutableStateOf(SSButtonState.IDLE) }
     SSJetPackComposeProgressButton(
         type = SSButtonType.CLOCK,
         width = 300.dp,
         height = 50.dp,
         onClick = {
             //Perform action on click of button and make it's state to LOADING
             submitButtonState = SSButtonState.LOADING
         },
         assetColor = Color.Red,
         buttonState = submitButtonState
     )
     // On Success change submitButtonState to success state
     submitButtonState = SSButtonState.SUCCESS
     // On Failure change submitButtonState to failure state
     submitButtonState = SSButtonState.FAILIURE

Customization

  • You can customize loading icon and animation effect according to your requirement.You can apply multiple animation effect from rotation, zoom-in-out and color changer too.

     var submitButtonState by remember { mutableStateOf(SSButtonState.IDLE) }
     SSJetPackComposeProgressButton(
         type = SSButtonType.CUSTOM,
         width = 300.dp,
         height = 50.dp,
         onClick = {
             //Perform action on click of button and make it's state to LOADING
             submitButtonState = SSButtonState.LOADING
         },
         assetColor = Color.Red,
         buttonState = submitButtonState,
         successIconPainter = painterResource(id = R.drawable.custom_success),
         failureIconPainter = painterResource(id = R.drawable.custom_fail),
         colors = ButtonDefaults.buttonColors(backgroundColor = Color.White),
         padding = PaddingValues(six.dp),
         text = stringResource(id = R.string.simform),
         textModifier = Modifier.padding(ten.dp),
         fontWeight = FontWeight.Bold,
         leftImagePainter = painterResource(id = R.drawable.simform_logo),
         buttonBorderStroke = BorderStroke(two.dp, colorResource(id = R.color.pink)),
         customLoadingIconPainter = painterResource(id = R.drawable.simform_logo),
         customLoadingEffect = SSCustomLoadingEffect(
             rotation = false,
             zoomInOut = true,
             colorChanger = false
         )
     )
     // On Success change submitButtonState to success state
     submitButtonState = SSButtonState.SUCCESS
     // On Failure change submitButtonState to failure state
     submitButtonState = SSButtonState.FAILIURE

All Attributes


Attribute Description Default
type Choose type of animation from:[CIRCLE, WHEEL, ZOOM_IN_OUT_CIRCLE, CLOCK, SPIRAL, CUSTOM] None
width Width to be applied to the button. None
height Height to be applied to the button. None
onClick Will be called when the user clicks the button. None
assetColor Color to be applied to icon and text inside button. None
buttonState Represent the state of button from IDLE, LOADING, SUCCESS, FAILIURE from SSButtonState. None
buttonBorderStroke Border to draw around the button. None
blinkingIcon Icon will be blink with size and color. false
cornerRadius Corner radius to be applied to the button. 20
speedMillis Speed of the animation while changing the state. 1000
enabled Controls the enabled state of the button. true
elevation It is used to resolve the elevation for this button in different. ButtonDefaults.elevation()
colors Colors that will be used to resolve the background and content color for this button in different states ButtonDefaults.buttonColors()
padding The spacing values to apply internally between the container and the content. PaddingValues(0.dp)
alphaValue The alpha of the drawn area. 1f
leftImagePainter Painter to draw inside this left Icon. null
rightImagePainter Painter to draw inside this right Icon. null
successIconPainter Painter to draw inside this success state Icon. rememberVectorPainter(image = Icons.Default.Done)
failureIconPainter Painter to draw inside this failiure state Icon. rememberVectorPainter(image = Icons.Outlined.Info)
successIconColor Color to be applied to success icon. assetColor
failureIconColor Color to be applied to failure icon. assetColor
text The text to be displayed. null
textModifier To apply to this text layout node. Modifier
fontSize The size of glyphs to use when painting the text. TextUnit.Unspecified
fontStyle The typeface variant to use when drawing the letters (e.g., italic). null
fontFamily The font family to be used when rendering the text. null
fontWeight The typeface thickness to use when painting the text (e.g., [FontWeight.Bold]). null
hourHandColor Color will be apply to hour hand in clock type animation only. Color.Black
customLoadingIconPainter painter [Painter] to draw your custom loading icon. painterResource(id = R.drawable.simform_logo)
customLoadingEffect Custom loading animation type like roation, zoom in out etc. SSCustomLoadingEffect( rotation = false, zoomInOut = false, colorChanger = false)
customLoadingPadding Spacing between button border and loading icon. 0

Our JetPackCompose Sample

SSComposeCookBook : A Collection of major Jetpack compose UI components which are commonly used.

Find this library useful? ❤️

Support it by joining stargazers for this repository.

How to Contribute 🤝

Whether you're helping us fix bugs, improve the docs, or a feature request, we'd love to have you! 💪 Check out our Contributing Guide for ideas on contributing.

Bugs and Feedback

For bugs, feature requests, and discussion please use GitHub Issues.

Medium Blog

For more info go to Progress Button using JetPack Compose : SSJetPackComposeProgressButton

License

Copyright 2021 Simform Solutions

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and limitations under the License.
You might also like...
A wave-like loading drawable
A wave-like loading drawable

#WaveLoading This library provides a wave loading animation as a Drawable. How to use Add dependency: compile 'com.race604.waveloading:library:1.1.1'

Some loading GIF .
Some loading GIF .

Android GifLoadingView This project idea is from Link . Thanks for the idea. I like all the animation in that webpage , but it's so hard to develop al

MaterialLoadingProgressBar   provide a styled ProgressBar which looks  like SwipeRefreshLayout's loading indicator(support-v4  v21+)
MaterialLoadingProgressBar provide a styled ProgressBar which looks like SwipeRefreshLayout's loading indicator(support-v4 v21+)

MaterialLoadingProgressBar MaterialLoadingProgressBar provide a styled ProgressBar which looks like SwipeRefreshLayout's loading indicator(support-v4

A highly configurable library to do loading progress with animated balls

Loading Balls A highly configurable library to do loading progress with animated balls for Android How to use Custom attributes lib:path="triangle" Th

Cool bezier loading view

What's BezierLoadingView ? A cool loading view with Bezier and a smooth circular motion, Demo Features Bezier Circular motion ##Attributes name format

ColoringLoading 4.7 0.0 Java This project provide Coloring Loading View for Android. And this project is not using the image file!
ColoringLoading 4.7 0.0 Java This project provide Coloring Loading View for Android. And this project is not using the image file!

ColoringLoading ![Release](https://img.shields.io/github/release/recruit-lifestyle/ColoringLoading.svg?label=maven version) This project provide Color

:seedling: A custom loading view for android, just like alipay.
:seedling: A custom loading view for android, just like alipay.

#SmileyLoadingView A custom loading view, just like alipay. Usage Edit your layout XML: cn.refactor.smileyloadingview.lib.SmileyLoadingView

KdLoadingView - A Custom Loading View for Android
KdLoadingView - A Custom Loading View for Android

KdLoadingView This is a circular loading view for android. Motivation In default progress view, its hard to change drawable, color and animation. So t

Open source android library for different progress bar designs
Open source android library for different progress bar designs

MultiProgressBar A progress bar library for Android that provides customized progress bars. Built with ❤︎ by Aseem Khare 💻 Installation Add this in y

Comments
  • Few drawbacks needs to improve

    Few drawbacks needs to improve

    Is your feature request related to a problem? Please describe.

    1. The button should be disable when it is in loading state, There is no meaning of showing progress indicator and user can still able to request the operation on click of button.
    2. There should be no mandatory pass the width and height arguments. What if user wants to set wrap content or fillMaxWidth()(match parent) of button size. This is not proper use case where user needs to calculate the width and height of the button and pass as argument.
    3. There is no modifier argument for button itself.
    opened by hiteshsarsava 1
  • Not able to use in material3

    Not able to use in material3

    Describe the bug It's showing compile error, Please check the below error showing in android studio. It's for colors and elevation property :

    
    @Composable
    public fun SSJetPackComposeProgressButton(
        type: SSButtonType,
        width: Dp,
        height: Dp,
        onClick: () -> Unit,
        assetColor: Color,
        buttonState: SSButtonState,
        buttonBorderStroke: BorderStroke?,
        blinkingIcon: Boolean,
        cornerRadius: Int,
        speedMillis: Int,
        enabled: Boolean,
        elevation: [Error type: Unresolved type for androidx.compose.material.ButtonElevation]?,
        colors: [Error type: Unresolved type for androidx.compose.material.ButtonColors],
        padding: PaddingValues,
        alphaValue: Float,
        leftImagePainter: Painter?,
        rightImagePainter: Painter?,
        successIconPainter: Painter,
        failureIconPainter: Painter,
        successIconColor: Color,
        failureIconColor: Color,
        text: String?,
        textModifier: Modifier,
        fontSize: TextUnit,
        fontStyle: FontStyle?,
        fontFamily: FontFamily?,
        fontWeight: FontWeight?,
        hourHandColor: Color,
        customLoadingIconPainter: Painter,
        customLoadingEffect: SSCustomLoadingEffect,
        customLoadingPadding: Int
    ): Unit
    

    More error details given by android studio

    Cannot access class 'androidx.compose.material.ButtonColors'. Check your module classpath for missing or conflicting dependencies
    Cannot access class 'androidx.compose.material.ButtonElevation'. Check your module classpath for missing or conflicting dependencies
    

    To Reproduce Cope paste the code from given in readme

    Expected behavior It should not give any compile time error.

    Screenshots image

    Smartphone (please complete the following information): All Devices

    Additional context I am forking this lib and make it compatible to material3

    Thanks for this awesome lib.

    opened by hiteshsarsava 1
  • Button state should reflect its state

    Button state should reflect its state

    Describe the bug Button should stay at either error or success state unless the backing state is modified. It should not return on the idle state (ui-wise) automatically if the state does not reflect.

    To Reproduce Steps to reproduce the behavior:

    1. Set the state to either error or success

    Expected behavior It should stay in its set state and not automatically go to idle even if it is just ui-wise.

    Smartphone (please complete the following information):

    • All

    Additional context This makes the library so opinionated and does not give the developer flexibility. It is also a common anti-pattern with declarative style ui to have a side-effect when state is changed. This kind of behavior also will not conform to single source of truth, and will cause the library to have unexpected behaviors.

    opened by OliverRhyme 0
Releases(1.0.7)
Owner
Simform Solutions
Simform Solutions
Android loading or progress dialog widget library, provide efficient way to implement iOS like loading dialog and progress wheel

ACProgressLite English Version / 中文版本 An Android loading widget library. Lite and easy to use, strong customizability. Can be used to implement 'iOS'

Cloudist Technology Co., Ltd. 234 Nov 24, 2022
Loading layout is a container view that manages easy switching between loading, completed and other states of your screen with a single line.

Loading layout is a container view that manages easy switching between loading, completed and other states of your screen with a single line.

ValarTech 16 Jul 5, 2022
Progress Button is a android library for hanling different types state like active, finished, enabled, disabled and reset with a single line of code.

Progress Button is a android library for hanling different types state like active, finished, enabled, disabled and reset with a single line of code.

Sagar Khurana 38 Nov 15, 2022
Android loading animations

Android-SpinKit Android loading animations(I wrote a android edition according SpinKit) Demo Apk Preview Gradle Dependency dependencies { implement

ybq 8.4k Jan 5, 2023
Android - An action bar item which acts both as a refresh button and as a progress indicator

RefreshActionItem An action bar item that implements this common pattern: Initially it shows a refresh button. If the button is clicked, a background

Manuel Peinado Gallego 655 Nov 10, 2022
A button to substitute the ProgressDialog.

Progress Button Android Android Button that morphs into a loading progress bar. Fully customizable in the XML Really simple to use. Makes your app loo

Farham Hosseini 9 Aug 17, 2022
Android loading view

Loading Loading is a poject with kinds of Android loading view. Yan can see the wiki for more detail. RotateLoading BookLoading NewtonCradleLoading Us

null 1.2k Jan 1, 2023
An animated circle loading view

Animated Circle Loading View A determiante/indetermiante loading view animation. Based on android-watch-loading-animation by Nils Banner. How it looks

José Luis Martín 1.2k Dec 7, 2022
Customizable bouncing dots for smooth loading effect. Mostly used in chat bubbles to indicate the other person is typing.

LoadingDots for Android Customizable bouncing dots view for smooth loading effect. Mostly used in chat bubbles to indicate the other person is typing.

Eyal Biran 162 Dec 2, 2022
An Android library providing to realize wave loading effect.

WaveLoadingView WaveLoadingView - An Android library that provides a realistic wave-loading effect. Sample Usage For a working implementation of this

Tang 1.7k Jan 2, 2023