Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi selection listview #10

Merged
merged 8 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 53 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,40 +85,71 @@ This is a library for creating and managing ....

### SingleSelectionChipGroup((Verticle/Horizontal))

SmartFilter.addChipGroupSingleSelection {
addSingleSelectionChipGroup(binding.root) { radioGroupData ->
SmartFilter.addChipGroupSingleSelection {
addSingleSelectionChipGroupVertical(binding.root) { radioGroupData ->
toast("name: ${radioGroupData.name} ") } }

- **Horizontal**

SmartFilter.addChipGroupSingleSelection {
addSingleSelectionChipGroupHorizontal(binding.root) { radioGroupData ->
toast("name: ${radioGroupData.name} ") } }

<img src="media/single_selection_chip.png" width="250" />

<img src="media/single_selection_chip.png" width="250" />
### MultiSelectionChipGroup(MultiRaw - (Verticle/Horizontal))

### MultiSelectionChipGroup(MultiRaw)
- **Verticle**

SmartFilter.addChipGroupMultiSelection {
addMultiSelectionChipGroupVertical(binding.root) { radioGroupData ->
toast("Checked IDs: ${radioGroupData.joinToString(", ")}") } }
- **Horizontal**

SmartFilter.addChipGroupMultiSelection {
addMultiSelectionChipGroup(binding.root) { radioGroupData ->
toast("Checked IDs: ${radioGroupData.joinToString(", ")}") } }
SmartFilter.addChipGroupMultiSelection {
addMultiSelectionChipGroupHorizontal(binding.root) { radioGroupData ->
toast("Checked IDs: ${radioGroupData.joinToString(", ")}")}}

<img src="media/multiselect_chip.png" width="250" />


<img src="media/multiselect_chip.png" width="250" />
### SingleSelectionListView((Verticle/Horizontal))

- **Verticle**

SmartFilter.addListViewSingleSelection {
addSingleSelectionListVertical(binding.root) { radioGroupData ->
toast("id: " + radioGroupData) } }

### Attribute
<img src="media/single_selection_vertical.png.png" width="250" />
- **Horizontal**

| Attribute | Description | Type | Default Value |
| --- | --- | --- | --- |
| rootView | The root view of the radio group. | ViewGroup | - |
| singleGroupSubType | The type of the radio group. | SingleGroupSubType | - |
| orientation | The orientation of the radio group. | Orientation | VERTICAL |
| mData | The list of radio group items. | List<RadioGroupData> | - |
| callbacks | The event listener for the radio group. | BaseEventListener | - |
| bgSelector | The background selector for the radio group items. | Int | - |
| textSelector | The text color selector for the radio group items. | Int | - |
SmartFilter.addListViewSingleSelection {
addSingleSelectionListHorizontal(binding.root) { radioGroupData ->
toast("id: " + radioGroupData) } }

### Usage
<img src="media/single_selection_horizental.png.png.png" width="250" />


### MultiSelectionListView((Verticle/Horizontal))

- **Verticle**

SmartFilter.addListViewMultiSelection{
addMultiSelectionList(binding.root) { radioGroupData ->
toast("id: " + radioGroupData) } }

<img src="media/multi_selection_vertical.png" width="250" />

- **Horizontal**

SmartFilter.addListViewMultiSelection{
addMultiSelectionListHorizontal(binding.root) { radioGroupData ->
toast("id: " + radioGroupData) } }

<img src="media/multi_selection_horizontal.png" width="250" />

- **To use the Smart Filter library in your Android application, you need to include it in your project's dependencies. Add the following line to your `build.gradle` file:**

### Dependency

### Default Drawable for SingleSelectionRadioGroup

Expand All @@ -145,5 +176,6 @@ This is a library for creating and managing ....
textSelector = R.color.multiline_text_selector


### Dependency
```kotlin
implementation 'com.ss:smartfilterlib:1.0.0'
2 changes: 0 additions & 2 deletions app/src/main/java/com/ss/smartfilter/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import com.ss.smartfilter.databinding.ActivityMainBinding
import com.ss.smartfilterlib.SmartFilter
import com.ss.smartfilterlib.data.RadioGroupData
import com.ss.smartfilterlib.utils.Params
import com.ss.smartfilterlib.utils.toast


Expand Down
159 changes: 105 additions & 54 deletions app/src/main/java/com/ss/smartfilter/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package com.ss.smartfilter

import android.view.ViewGroup
import com.ss.smartfilterlib.R
import com.ss.smartfilterlib.data.Data
import com.ss.smartfilterlib.data.MultiSelectionParams
import com.ss.smartfilterlib.data.RadioGroupData
import com.ss.smartfilterlib.data.SingleChipSelectionParams
import com.ss.smartfilterlib.data.SingleSelectionMultiRawParams
import com.ss.smartfilterlib.data.SingleSelectionParams
import com.ss.smartfilterlib.data.mRadioGroupData
import com.ss.smartfilterlib.data.mData
import com.ss.smartfilterlib.utils.MultiChipType
import com.ss.smartfilterlib.utils.Orientation
import com.ss.smartfilterlib.utils.Params
Expand All @@ -17,113 +15,166 @@ import com.ss.smartfilterlib.utils.SingleGroupSubType
/**
* created by Mala Ruparel ON 23/04/24
*/
fun addRadioGroupSingleLineVertical(
rootView: ViewGroup,
radioGroupCallback: (RadioGroupData) -> Unit
) =
Params.SingleSelection(
fun addRadioGroupSingleLineVertical(rootView: ViewGroup,onItemSelected: (Data) -> Unit) = Params.SingleSelection(
SingleSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.SINGLE_LINE,
chipType = SingleChipType.NONE,
orientation = Orientation.VERTICAL,
mData = mRadioGroupData(),
callbacks = radioGroupCallback,
mData = mData(),
onItemSelected = onItemSelected,
bgSelector = R.drawable.singleline_rb_selector,
textSelector = R.color.single_text_color_selector
)
)

fun addRadioGroupSingleLineHorizontal(
rootView: ViewGroup,
radioGroupCallback: (RadioGroupData) -> Unit
) =
Params.SingleSelection(
fun addRadioGroupSingleLineHorizontal(rootView: ViewGroup,onItemSelected: (Data) -> Unit) = Params.SingleSelection(
SingleSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.SINGLE_LINE,
chipType = SingleChipType.NONE,
orientation = Orientation.HORIZONTAL,
mData = mRadioGroupData(),
callbacks = radioGroupCallback,
mData = mData(),
onItemSelected = onItemSelected,
bgSelector = R.drawable.singleline_rb_selector,
textSelector = R.color.single_text_color_selector
)
)

fun addRadioMultiRow(rootView: ViewGroup, radioGroupCallback: (RadioGroupData) -> Unit) =
Params.SingleSelectionMultiRaw(
SingleSelectionMultiRawParams(
fun addRadioMultiRow(rootView: ViewGroup, onItemSelected: (Data) -> Unit) = Params.SingleSelection(
SingleSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.MULTI_LINE,
chipType = SingleChipType.NONE,
orientation = Orientation.VERTICAL,
mData = mRadioGroupData(),
callbacks = radioGroupCallback,
mData = mData(),
onItemSelected = onItemSelected,
bgSelector = R.drawable.multiline_bg_selector,
textSelector = R.color.multiline_text_selector
)
)


fun addRadioGroupRowItemHorizontal(
rootView: ViewGroup,
radioGroupCallback: (RadioGroupData) -> Unit
) = Params.SingleSelection(
fun addRadioGroupRowItemHorizontal(rootView: ViewGroup,onItemSelected: (Data) -> Unit) = Params.SingleSelection(
SingleSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.ROW_ITEM,
chipType = SingleChipType.NONE,
orientation = Orientation.HORIZONTAL,
mData = mRadioGroupData(),
callbacks = radioGroupCallback,
mData = mData(),
onItemSelected = onItemSelected,
bgSelector = R.drawable.row_item_selector,
textSelector = R.color.single_text_color_selector

)
)
fun addRadioGroupRowItemVertical(
rootView: ViewGroup,
radioGroupCallback: (RadioGroupData) -> Unit
) = Params.SingleSelection(
fun addRadioGroupRowItemVertical(rootView: ViewGroup,onItemSelected: (Data) -> Unit) = Params.SingleSelection(
SingleSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.ROW_ITEM,
chipType = SingleChipType.NONE,
orientation = Orientation.VERTICAL,
mData = mRadioGroupData(),
callbacks = radioGroupCallback,
mData = mData(),
onItemSelected = onItemSelected,
bgSelector = R.drawable.row_item_selector,
textSelector = R.color.single_text_color_selector

)
)
fun addSingleSelectionChipGroup(rootView: ViewGroup, radioGroupCallback: (RadioGroupData) -> Unit) =

SingleChipSelectionParams(
fun addSingleSelectionChipGroupVertical(rootView: ViewGroup, onItemSelected: (Data) -> Unit) = Params.SingleSelection(
SingleSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.CHIP_GROUP,
chipType = SingleChipType.ENTRY_CHIP,
orientation = Orientation.VERTICAL,
mData = mData(),
onItemSelected = onItemSelected,
bgSelector = R.color.chip_bg_selector,
textSelector = R.color.multiline_text_selector
)
)
fun addSingleSelectionChipGroupHorizontal(rootView: ViewGroup, onItemSelected: (Data) -> Unit) = Params.SingleSelection(
SingleSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.CHIP_GROUP,
chipType = SingleChipType.ENTRY_CHIP,
orientation = Orientation.HORIZONTAL,
mData = mData(),
onItemSelected = onItemSelected,
bgSelector = R.color.chip_bg_selector,
textSelector = R.color.chip_text_selector
)
)
fun addMultiSelectionChipGroupVertical(rootView: ViewGroup, onItemsSelected: (List<Int>) -> Unit) = Params.MultiSelection(
MultiSelectionParams(
rootView = rootView,
chipType = MultiChipType.FILTER_CHIP,
orientation = Orientation.VERTICAL,
mData = mData(),
onItemsSelected = onItemsSelected,
bgSelector = R.color.chip_bg_selector,
textSelector = R.color.chip_text_selector
)
)


fun addMultiSelectionChipGroupHorizontal(rootView: ViewGroup, onItemsSelected: (List<Int>) -> Unit) =Params.MultiSelection(
MultiSelectionParams(
rootView = rootView,
chipType = MultiChipType.FILTER_CHIP,
orientation = Orientation.HORIZONTAL,
mData = mData(),
onItemsSelected = onItemsSelected,
bgSelector = R.color.chip_bg_selector,
textSelector = R.color.chip_text_selector
)
)
fun addSingleSelectionListHorizontal(rootView: ViewGroup, onItemselected: (Data) -> Unit) = Params.SingleSelection(
SingleSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.SINGLE_LINE,
chipType = SingleChipType.NONE,
orientation = Orientation.HORIZONTAL,
mData = mData(),
onItemSelected = onItemselected,
bgSelector = R.drawable.ic_check_selector,
textSelector = R.color.chip_text_selector
)
)
fun addSingleSelectionListVertical(rootView: ViewGroup, onItemselected: (Data) -> Unit) = Params.SingleSelection(
SingleSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.CHIP_GROUP,
chipType = SingleChipType.CHOICE_CHIP,
singleGroupSubType = SingleGroupSubType.SINGLE_LINE,
chipType = SingleChipType.NONE,
orientation = Orientation.VERTICAL,
mData = mRadioGroupData(),
callbacks = radioGroupCallback,
bgSelector = R.color.chip_bg_selector,
mData = mData(),
onItemSelected = onItemselected,
bgSelector = R.drawable.ic_check_selector,
textSelector = R.color.chip_text_selector
)

fun addMultiSelectionChipGroup(rootView: ViewGroup, radioGroupCallback: (List<Int>) -> Unit) =
)
fun addMultiSelectionListVertical(rootView: ViewGroup, onItemsSelected: (List<Int>) -> Unit) = Params.MultiSelection(
MultiSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.SINGLE_LINE,
chipType = MultiChipType.NONE,
orientation = Orientation.VERTICAL,
mData = mData(),
onItemsSelected = onItemsSelected,
bgSelector = R.color.chip_bg_selector,
textSelector = R.color.chip_text_selector
)
)
fun addMultiSelectionListHorizontal(rootView: ViewGroup, onItemsSelected: (List<Int>) -> Unit) = Params.MultiSelection(
MultiSelectionParams(
rootView = rootView,
chipType = MultiChipType.FILTER_CHIP,
orientation = Orientation.VERTICAL,
mData = mRadioGroupData(),
callbacks = radioGroupCallback,
singleGroupSubType = SingleGroupSubType.SINGLE_LINE,
chipType = MultiChipType.NONE,
orientation = Orientation.HORIZONTAL,
mData = mData(),
onItemsSelected = onItemsSelected,
bgSelector = R.color.chip_bg_selector,
textSelector = R.color.chip_text_selector
)






)
6 changes: 4 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rootView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">



</LinearLayout>

Binary file added media/multi_selection_horizontal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/multi_selection_vertical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/single_selection_horizental.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/single_selection_vertical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading