Skip to content

Commit

Permalink
Merge branch 'changes_1' into development
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	app/src/main/java/com/ss/smartfilter/MainActivity.kt
#	ss-smart-filter/src/main/java/com/ss/smartfilterlib/utils/Attributes.kt
#	ss-smart-filter/src/main/res/color/chip_text_selector.xml
  • Loading branch information
MalaRuparel2023 committed May 17, 2024
2 parents ed4d9cc + 4bc6e8b commit 830cae0
Show file tree
Hide file tree
Showing 70 changed files with 1,297 additions and 187 deletions.
43 changes: 9 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Smart Filter Library

<img src="media/test.gif" width="250" />

This library provides a set of customizable filter components for Android applications. It supports both single and multi-selection filters in various formats such as radio groups, chip groups, and list views. The filters can be displayed either vertically or horizontally.

## Features
Expand Down Expand Up @@ -52,7 +54,6 @@ The library depends on the following libraries:
addRadioGroupSingleLineVertical(binding.root) { radioGroupData ->
toast("name: ${radioGroupData.name} ") }}

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


- **Horizontal**
Expand All @@ -63,8 +64,6 @@ The library depends on the following libraries:
toast("name: ${radioGroupData.name} ") } }


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


### SingleSelectionMultiLine(MultiRaw)

Expand All @@ -73,7 +72,6 @@ The library depends on the following libraries:
toast("name: ${radioGroupData.name} ") } }


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


### SingleSelectionRowItem(Verticle/Horizontal)
Expand All @@ -85,7 +83,6 @@ The library depends on the following libraries:
toast("name: ${radioGroupData.name} ") } }


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

- **Horizontal**

Expand All @@ -94,7 +91,7 @@ The library depends on the following libraries:
toast("name: ${radioGroupData.name} ") } }


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


### SingleSelectionChipGroup((Verticle/Horizontal))

Expand All @@ -108,7 +105,7 @@ The library depends on the following libraries:
addSingleSelectionChipGroupHorizontal(binding.root) { radioGroupData ->
toast("name: ${radioGroupData.name} ") } }
<img src="media/single_selection_chip.png" width="250" />


### MultiSelectionChipGroup(MultiRaw - (Verticle/Horizontal))

Expand All @@ -123,7 +120,7 @@ The library depends on the following libraries:
addMultiSelectionChipGroupHorizontal(binding.root) { radioGroupData ->
toast("Checked IDs: ${radioGroupData.joinToString(", ")}")}}
<img src="media/multiselect_chip.png" width="250" />



### SingleSelectionListView((Verticle/Horizontal))
Expand All @@ -134,14 +131,13 @@ The library depends on the following libraries:
addSingleSelectionListVertical(binding.root) { radioGroupData ->
toast("name: " + radioGroupData.name) } }

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

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

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



### MultiSelectionListView((Verticle/Horizontal))
Expand All @@ -152,41 +148,20 @@ The library depends on the following libraries:
addMultiSelectionListVertical(binding.root) { radioGroupData ->
toast("name: " + radioGroupData) } }

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


- **Horizontal**

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

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



### Default Drawable for SingleSelectionRadioGroup

@DrawableRes val bgSelector: Int = androidx.appcompat.R.drawable.abc_btn_radio_material,
@ColorRes val textSelector: Int = android.R.color.black

##Selector

bgSelector = R.drawable.singleline_rb_selector,
textSelector = R.color.single_text_color_selector

### Drawable for SingleSelectionMultiRaw

##Default

```kotlin
@DrawableRes val bgSelector: Int = R.drawable.multiline_default,
@ColorRes val textSelector: Int = android.R.color.black
<img src="media/test1.png" width="250" /> <img src="media/test2.png" width="250" />
<img src="media/test3.png" width="250" /> <img src="media/test4.png" width="250" />

##Selector

```kotlin
bgSelector = R.drawable.multiline_selector,
textSelector = R.color.multiline_text_selector


### Dependency
Expand Down
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ dependencies {
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.androidx.navigation.runtime.ktx)
implementation(libs.androidx.navigation.compose)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
Expand Down
18 changes: 6 additions & 12 deletions app/src/main/java/com/ss/smartfilter/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,18 @@ package com.ss.smartfilter

import android.os.Bundle
import androidx.activity.ComponentActivity
import com.ss.smartfilter.databinding.ActivityMainBinding
import com.ss.smartfilterlib.SmartFilter
import com.ss.smartfilterlib.utils.toast
import androidx.activity.compose.setContent
import com.ss.smartfilter.screens.FilterScreen


class MainActivity : ComponentActivity() {
private lateinit var binding: ActivityMainBinding


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)


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

setContent {
FilterScreen()
}
}

}
83 changes: 81 additions & 2 deletions app/src/main/java/com/ss/smartfilter/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import com.ss.smartfilterlib.R
import com.ss.smartfilterlib.data.Data
import com.ss.smartfilterlib.data.MultiSelectionParams
import com.ss.smartfilterlib.data.SingleSelectionParams
import com.ss.smartfilterlib.data.mAmenties
import com.ss.smartfilterlib.data.mBusOperatorType
import com.ss.smartfilterlib.data.mBusType
import com.ss.smartfilterlib.data.mData
import com.ss.smartfilterlib.data.mDeal
import com.ss.smartfilterlib.data.mOperatorType
import com.ss.smartfilterlib.data.mSeatType
import com.ss.smartfilterlib.data.mTime
import com.ss.smartfilterlib.utils.MultiChipType
import com.ss.smartfilterlib.utils.Orientation
import com.ss.smartfilterlib.utils.Params
Expand Down Expand Up @@ -166,15 +173,87 @@ fun addMultiSelectionListVertical(rootView: ViewGroup, onItemsSelected: (List<I
textSelector = R.color.text_color_selector
)
)
fun addMultiSelectionListHorizontal(rootView: ViewGroup, onItemsSelected: (List<Int>) -> Unit) = Params.MultiSelection(
fun addMultiSelectionListBus(rootView: ViewGroup, onItemsSelected: (List<Int>) -> Unit) = Params.MultiSelection(
MultiSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.SINGLE_LINE,
chipType = MultiChipType.NONE,
orientation = Orientation.HORIZONTAL,
mData = mData(),
mData = mBusType(),
onItemsSelected = onItemsSelected,
bgSelector = R.drawable.multiline_bg_selector,
textSelector = R.color.chip_text_selector
)
)
fun addMultiSelectionListSeat(rootView: ViewGroup, onItemsSelected: (List<Int>) -> Unit) = Params.MultiSelection(
MultiSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.SINGLE_LINE,
chipType = MultiChipType.NONE,
orientation = Orientation.HORIZONTAL,
mData = mSeatType(),
onItemsSelected = onItemsSelected,
bgSelector = R.drawable.multiline_bg_selector,
textSelector = R.color.chip_text_selector
)
)
fun addRadioGroupSingleOperator(rootView: ViewGroup,onItemSelected: (Data) -> Unit) = Params.SingleSelection(
SingleSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.SINGLE_LINE,
chipType = SingleChipType.NONE,
orientation = Orientation.VERTICAL,
mData = mOperatorType(),
onItemSelected = onItemSelected,
bgSelector = R.drawable.star_selector,
textSelector = R.color.text_color_selector
)
)
fun addRadioGroupSingleBusOperator(rootView: ViewGroup,onItemSelected: (Data) -> Unit) = Params.SingleSelection(
SingleSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.SINGLE_LINE,
chipType = SingleChipType.NONE,
orientation = Orientation.VERTICAL,
mData = mBusOperatorType(),
onItemSelected = onItemSelected,
bgSelector = R.drawable.check_selector,
textSelector = R.color.text_color_selector
)
)
fun addMultiSelectionChipGroupAmenties(rootView: ViewGroup, onItemsSelected: (List<Int>) -> Unit) = Params.MultiSelection(
MultiSelectionParams(
rootView = rootView,
chipType = MultiChipType.ENTRY_CHIP,
orientation = Orientation.VERTICAL,
mData = mAmenties(),
onItemsSelected = onItemsSelected,
bgSelector = R.drawable.ic_check_selector,
textSelector = R.color.text_color_selector
)
)

fun addRadioGroupSingleLineHorizontalDeal(rootView: ViewGroup,onItemSelected: (Data) -> Unit) = Params.SingleSelection(
SingleSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.SINGLE_LINE,
chipType = SingleChipType.NONE,
orientation = Orientation.VERTICAL,
mData = mDeal(),
onItemSelected = onItemSelected,
bgSelector = R.drawable.rb_selector,
textSelector = R.color.text_color_selector
)
)
fun addRadioMultiRowDeparture(rootView: ViewGroup, onItemSelected: (Data) -> Unit) = Params.SingleSelection(
SingleSelectionParams(
rootView = rootView,
singleGroupSubType = SingleGroupSubType.MULTI_LINE,
chipType = SingleChipType.NONE,
orientation = Orientation.VERTICAL,
mData = mTime(),
onItemSelected = onItemSelected,
bgSelector = R.drawable.multiline_bg_selector,
textSelector = R.color.multiline_text_selector
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.ss.smartfilter.screens

import android.widget.LinearLayout
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.KeyboardArrowDown
import androidx.compose.material.icons.filled.KeyboardArrowUp
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.data.UiToolingDataApi
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.viewinterop.AndroidView
import com.ss.smartfilter.addMultiSelectionChipGroupAmenties
import com.ss.smartfilterlib.SmartFilter

/**
* created by Mala Ruparel ON 16/05/24
*/
@OptIn(UiToolingDataApi::class)
@Composable
fun ExpandableAmentiesType(title: String) {
var expanded by remember { mutableStateOf(false) }
Column(
modifier = Modifier
.fillMaxWidth()
.padding(8.dp)

) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {

Text(
modifier = Modifier
.weight(1f)
.padding(16.dp),
text = title,
fontSize = 18.sp,
style = TextStyle(fontWeight = FontWeight.Bold)
)
IconButton(
onClick = { expanded = !expanded },
modifier = Modifier.size(36.dp)
) {
Icon(
if (expanded) Icons.Default.KeyboardArrowUp else Icons.Default.KeyboardArrowDown,
contentDescription = if (expanded) "Collapse" else "Expand"
)
}
}

if (expanded) {
AndroidView(factory = { context ->
LinearLayout(context).apply {
layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)
}
}) { view ->

SmartFilter.addChipGroupMultiSelection {
addMultiSelectionChipGroupAmenties(view) { }
}
}
}


}
}
Loading

0 comments on commit 830cae0

Please sign in to comment.