Skip to content

Commit

Permalink
#refactoring code
Browse files Browse the repository at this point in the history
  • Loading branch information
MalaRuparel2023 committed May 14, 2024
1 parent bd83d18 commit 753dcb7
Show file tree
Hide file tree
Showing 34 changed files with 360 additions and 375 deletions.
47 changes: 34 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,43 @@ This is a library for creating and managing ....
<img src="media/multiselect_chip.png" width="250" />


### Attribute
### SingleSelectionListView((Verticle/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 | - |
- **Verticle**

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

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

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

<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 @@ -156,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
134 changes: 73 additions & 61 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,152 +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 addSingleSelectionChipGroupVertical(rootView: ViewGroup, radioGroupCallback: (RadioGroupData) -> Unit) =
Params.SingleChipSelection(
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 = mRadioGroupData(),
callbacks = radioGroupCallback,
mData = mData(),
onItemSelected = onItemSelected,
bgSelector = R.color.chip_bg_selector,
textSelector = R.color.chip_text_selector
textSelector = R.color.multiline_text_selector
)
)
fun addSingleSelectionChipGroupHorizontal(rootView: ViewGroup, radioGroupCallback: (RadioGroupData) -> Unit) =
Params.SingleChipSelection(
SingleChipSelectionParams(
fun addSingleSelectionChipGroupHorizontal(rootView: ViewGroup, onItemSelected: (Data) -> Unit) = Params.SingleSelection(
SingleSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.CHIP_GROUP,
chipType = SingleChipType.ENTRY_CHIP,
orientation = Orientation.HORIZONTAL,
mData = mRadioGroupData(),
callbacks = radioGroupCallback,
mData = mData(),
onItemSelected = onItemSelected,
bgSelector = R.color.chip_bg_selector,
textSelector = R.color.chip_text_selector
)
)
fun addMultiSelectionChipGroupVertical(rootView: ViewGroup, radioGroupCallback: (List<Int>) -> Unit) =
Params.MultiChipSelection(
fun addMultiSelectionChipGroupVertical(rootView: ViewGroup, onItemsSelected: (List<Int>) -> Unit) = Params.MultiSelection(
MultiSelectionParams(
rootView = rootView,
chipType = MultiChipType.FILTER_CHIP,
orientation = Orientation.VERTICAL,
mData = mRadioGroupData(),
callbacks = radioGroupCallback,
mData = mData(),
onItemsSelected = onItemsSelected,
bgSelector = R.color.chip_bg_selector,
textSelector = R.color.chip_text_selector
)
)


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

0 comments on commit 753dcb7

Please sign in to comment.