Skip to content

A MaterialChipSetWidget is used to hold multiple chipsets 🤩 and each chipset has multiple values. 🔖

License

Notifications You must be signed in to change notification settings

JustinGeorgeJoseph/MaterialChipsetWidget

Repository files navigation

MaterialChipSetWidget


A MaterialChipSetWidget is used to hold multiple chipsets 🤩 and each chipset has multiple values.:bookmark:

License License API


Including in your project

Gradle

Add below codes to your root build.gradle file (not your module build.gradle file).

allprojects {
    repositories {
        mavenCentral()
    }
}

And add a dependency code to your module's build.gradle file.

dependencies {
    implementation 'com.github.JustinGeorgeJoseph:MaterialChipsetWidget:v1.0.1'
}

Usage

ColorPickerView in XML layout

We can use MaterialChipSetsContainer without any customized attributes.
Initally there won't be any content you have add those contents dynamically.

    <com.justin.materialchipsetwidget.MaterialChipSetsContainer
        android:id="@+id/materialChipSetsContainer"
        android:layout_width="match_parent"
        android:scrollbars="none"
        android:layout_height="wrap_content"/>

Attribute descriptions

android:scrollbars="none" // sets whether a horizontal scrollbar is required or not.

Initalize MaterialChipsetWidget with chips

Create a list of data that should be shown in the widget

    private fun createDataSet(): List<List<String>> {
        val arrayTime = arrayListOf("Recent", "2000s", "90s", "Old")
        val arrayPurchaseMode = arrayListOf("Paid", "Rent")
        val arrayGenre = arrayListOf("Action", "Comedy", "Sci-Fi", "Science", "Drama")
        val arrayRating = arrayListOf("Award-winning", "Highly rated")
        return arrayListOf(arrayPurchaseMode, arrayTime, arrayGenre, arrayRating)
    }

Initialize the widget with colors and dataset

findViewById<MaterialChipSetsContainer>(R.id.materialChipSetsContainer).apply {

            chipSetSolidColorUnselected = ContextCompat.getColor(context, android.R.color.black)
            chipSetSolidColorSelected = ContextCompat.getColor(context, R.color.green)
            chipSetStrokeWidth = Utils.convertDpToPx(this@MainActivity, 3)
            chipSetStrokeColorUnselected =
                ColorStateList.valueOf(ContextCompat.getColor(context, R.color.green))
            chipSetStrokeColorSelected =
                ColorStateList.valueOf(ContextCompat.getColor(context, R.color.green))

            chipTextColorUnselected = ContextCompat.getColor(context, android.R.color.white)
            chipTextColorSelected = ContextCompat.getColor(context, android.R.color.white)
            chipTextDividerColorUnselected =
                ContextCompat.getColor(context, R.color.green)

            dataSet = createDataSet()
        }

MaterialChipsetWidgetListener

MaterialChipsetWidgetListener {

                override fun onChipSelectionChanged(
                    name: String?,
                    chipSelectionGroup: String,
                    checked: Boolean,
                ) {
                    
                }

                override fun onChipsetsResetClicked() {
                   
                }

            }

License

Copyright 2022 JustinGeorgeJoseph (Justin George)

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.