Git Product home page Git Product logo

quantitypicker's Introduction

QuantityPicker

QuantityPicker is compose component to add/remove anything

Installation

  • To implement QuantityPicker to your Android project via Gradle, you need to add JitPack repository to your root/project level build.gradle.
allprojects {  
 repositories { ... maven { url 'https://jitpack.io' } }}  
  • After adding JitPack repository, you can add QuantityPicker dependency to your app/module level build.gradle.
dependencies {
 implementation 'com.github.selimtoksal:QuantityPicker:0.0.1'
 }

Usage

You can add QuantityPicker wherever you want with your modifier

quantityPickerShape attribute defines background of your QuantityPicker and border

Attribute Type Description
modifier Modifier Compose modifier for QuantityPicker
quantityTextModifier Modifier Compose modifier for quantity text. if you need background or custom modifier etc.
textStyle TextStyle Text style for quantity text
addIconResId Int Drawable for add button
subtractIconResId Int Drawable for subtract button
removeIconResId Int Drawable for remove button. Visible if it is null and current quantity is 1
quantityPickerShape QuantityPickerShape Background of all view also defines border if it is not null
quantityData QuantityData Quantity values. It has min,max,current and postfix
showLoading Boolean Loading state
addIconContentDescription String contentDescription for add button
subtractIconContentDescription String contentDescription for subtract button
progressColor Color Color for loading progress indicator
onAddClick (() -> Unit) Listener for add button clicks
onSubtractClick (() -> Unit) Listener for subtract clicks

Implementation

If you don't need any customization

QuantityPicker(
    quantityData = quantityData,
    addIconResId = R.drawable.ic_plus,
    subtractIconResId = R.drawable.ic_minus,
    removeIconResId = R.drawable.ic_remove,
    showLoading = isLoading,
    onAddClick = { },
    onSubtractClick = { }
)

If you need background or custom modifier for quantity text and all view

QuantityPicker(
    textStyle = Typography.body2,
    quantityData = quantityData,
    addIconResId = R.drawable.ic_plus,
    subtractIconResId = R.drawable.ic_minus,
    quantityPickerShape = QuantityPickerShape(
        shape = RoundedCornerShape(50),
        borderColor = MyQuantityPickerPrimaryColor,
        borderWidth = 1.dp
    ),
    removeIconResId = R.drawable.ic_remove,
    quantityTextModifier = Modifier
        .background(
            color = MyQuantityPickerPrimaryColor,
            shape = CircleShape
        )
        .padding(vertical = 4.dp, horizontal = 8.dp),
    showLoading = isLoading,
    progressColor = MyQuantityPickerPrimaryColor,
    onAddClick = { },
    onSubtractClick = { }
)

Contribution

Feel free to contribute

Inspired

This library is inspired by QuantityPickerView in Trendyol android-ui-components

quantitypicker's People

Contributors

selimtoksal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.