Skip to content

Latest commit

 

History

History

quantity-picker-compose

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

quantityPickerComposeVersion= quantity-picker-compose-1.0.1 License

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.Trendyol.android-ui-components:quantity-picker-compose:$quantityPickerComposeVersion"
 }

Usage

You can add QuantityPicker wherever you want with your modifier

Attribute Type Description
modifier Modifier Compose modifier for QuantityPicker
direction QuantityPickerDirection Picker Direction Vertical or Horizontal
icons QuantityIcons Drawables for add subtract remove and colors
quantityTextShape QuantityPickerShape Compose shape for quantity text.
quantityPickerShape QuantityPickerShape Background of all view also defines border if it is not null
textStyle TextStyle Text style for quantity text
quantityData QuantityData Quantity values. It has min,max,current and postfix
showLoading Boolean Loading state
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(
    modifier = modifier,
    quantityData = quantityData,
    showLoading = isLoading,
    onAddClick = { },
    onSubtractClick = { }
)

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

QuantityPicker(
    textStyle = Typography.body2,
    quantityData = quantityData,
    icons: QuantityIcons = QuantityIcons( // QuantityIcons.default
        addIconResId = R.drawable.ic_plus,
        subtractIconResId = R.drawable.ic_subtract,
        removeIconResId = R.drawable.ic_trash,
        iconColor = QuantityPickerDefaults.defaultColor,
        disabledColor = QuantityPickerDefaults.disabledColor
    ),
    quantityPickerShape = QuantityPickerShape( // QuantityPickerDefaults.quantityShape,
        shape = RoundedCornerShape(50),
        borderColor = MyQuantityPickerPrimaryColor,
        borderWidth = 1.dp
    ),
    quantityTextShape = QuantityPickerShape( // QuantityPickerDefaults.quantityTextShape
        shape = RoundedCornerShape(50),
        borderColor = MyQuantityPickerPrimaryColor,
        borderWidth = 1.dp
    ),
    showLoading = isLoading,
    progressColor = MyQuantityPickerPrimaryColor, // QuantityPickerDefaults.defaultColor
    onAddClick = { },
    onSubtractClick = { }
)

Repository From

https://github.com/selimtoksal/QuantityPicker

Contributors

This library is maintained mainly by Trendyol Android Team members but also other Android lovers contributes.

License

Copyright 2023 Trendyol.com    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.