Skip to content

Commit

Permalink
Mobileapps 988 (#61)
Browse files Browse the repository at this point in the history
* fixed search and scrollable issue.

1. Title drawer is not showing
2. Search input field will show if more than 10 items
3. Implement scroll to facet component value if item is more than 10.
  • Loading branch information
aman-alfresco authored Dec 17, 2021
1 parent c19ad91 commit f7691e4
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ data class SearchChipCategory(
fun resetData(searchChipCategory: SearchChipCategory): SearchChipCategory {
return SearchChipCategory(
category = searchChipCategory.category,
fieldsItem = searchChipCategory.fieldsItem,
intervalsItem = searchChipCategory.intervalsItem,
isSelected = searchChipCategory.category?.component == null,
selectedName = "",
selectedQuery = ""
Expand Down Expand Up @@ -89,7 +91,7 @@ data class SearchChipCategory(
return SearchChipCategory(
category = CategoriesItem(
null, Component(null, ChipComponentType.FACET_FIELDS.component),
null, data.label, null
data.label, data.label, null
),
fieldsItem = data,
selectedName = "",
Expand All @@ -104,7 +106,7 @@ data class SearchChipCategory(
return SearchChipCategory(
category = CategoriesItem(
null, Component(null, ChipComponentType.FACET_INTERVALS.component),
null, data.label, null
data.label, data.label, null
),
intervalsItem = data,
selectedName = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import android.annotation.SuppressLint
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.LinearLayout
import android.widget.RelativeLayout
import androidx.lifecycle.lifecycleScope
import com.airbnb.epoxy.AsyncEpoxyController
import com.airbnb.mvrx.MavericksView
Expand Down Expand Up @@ -40,6 +43,7 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView {
var onReset: ComponentResetCallback? = null
var onCancel: ComponentCancelCallback? = null
var executedPicker = false
private val minVisibleItem = 10

override fun onCreateView(
inflater: LayoutInflater,
Expand All @@ -56,7 +60,6 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView {
dialog?.setOnCancelListener {
onCancel?.invoke()
}

setupComponents()
setListeners()
}
Expand All @@ -69,8 +72,6 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView {
bottomSheet?.let {
BottomSheetBehavior.from<View>(it).apply {
val peekAmount = 1.0
isHideable = false
skipCollapsed = false
peekHeight = ((it.parent as View).height * peekAmount).toInt()
}
}
Expand All @@ -79,7 +80,10 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView {

private fun setupComponents() {
withState(viewModel) { state ->
binding.title.text = state.parent.category?.name
binding.parentView.removeAllViews()
binding.parentView.addView(binding.topView)
binding.parentView.addView(binding.separator)
binding.title.text = requireContext().getLocalizedName(state.parent.category?.name ?: "")
when (state.parent.category?.component?.selector) {
ChipComponentType.TEXT.component -> setupTextComponent(state)
ChipComponentType.CHECK_LIST.component -> setupCheckListComponent()
Expand All @@ -88,7 +92,9 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView {
ChipComponentType.SLIDER.component -> setupSliderComponent(state)
ChipComponentType.DATE_RANGE.component -> setupDateRangeComponent(state)
ChipComponentType.FACET_FIELDS.component,
ChipComponentType.FACET_INTERVALS.component -> setupFacetComponent()
ChipComponentType.FACET_INTERVALS.component -> {
setupFacetComponent(state)
}
}
}
}
Expand Down Expand Up @@ -130,6 +136,7 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView {
}

private fun setupTextComponent(state: ComponentCreateState) {
binding.parentView.addView(binding.frameText)
binding.textComponent.componentParent.visibility = View.VISIBLE
binding.textComponent.nameInput.isFocusableInTouchMode = true
binding.textComponent.nameInput.requestFocus()
Expand All @@ -152,12 +159,14 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView {
}

private fun setupCheckListComponent() {
binding.parentView.addView(binding.frameCheckList)
viewModel.buildCheckListModel()
binding.checkListComponent.componentParent.visibility = View.VISIBLE
binding.checkListComponent.recyclerView.setController(epoxyCheckListController)
}

private fun setupRadioListComponent(state: ComponentCreateState) {
binding.parentView.addView(binding.frameRadio)
viewModel.buildSingleDataModel()
if (state.parent.selectedName.isEmpty())
viewModel.copyDefaultComponentData()
Expand All @@ -166,6 +175,7 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView {
}

private fun setupNumberRangeComponent(state: ComponentCreateState) {
binding.parentView.addView(binding.frameNumberRange)
viewModel.buildSingleDataModel()
binding.numberRangeComponent.componentParent.visibility = View.VISIBLE
binding.numberRangeComponent.fromInput.isFocusableInTouchMode = true
Expand Down Expand Up @@ -222,6 +232,7 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView {
}

private fun setupSliderComponent(state: ComponentCreateState) {
binding.parentView.addView(binding.frameSlider)
viewModel.fromValue = "0"
viewModel.buildSingleDataModel()
binding.sliderComponent.componentParent.visibility = View.VISIBLE
Expand Down Expand Up @@ -250,6 +261,8 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView {
}

private fun setupDateRangeComponent(state: ComponentCreateState) {

binding.parentView.addView(binding.frameDateRange)
binding.dateRangeComponent.componentParent.visibility = View.VISIBLE

binding.dateRangeComponent.fromInput.inputType = 0
Expand Down Expand Up @@ -331,8 +344,15 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView {
}

@SuppressLint("ClickableViewAccessibility")
private fun setupFacetComponent() {
private fun setupFacetComponent(state: ComponentCreateState) {
viewModel.buildCheckListModel()
binding.parentView.addView(binding.frameFacet)
state.parent.fieldsItem?.buckets?.let {
if (it.size > minVisibleItem) {
binding.facetCheckListComponent.recyclerView.layoutParams = getRecyclerviewLayoutParams()
binding.facetCheckListComponent.searchInputLayout.visibility = View.VISIBLE
}
}
binding.facetCheckListComponent.componentParent.visibility = View.VISIBLE
binding.facetCheckListComponent.recyclerView.setController(epoxyCheckFacetListController)
binding.facetCheckListComponent.searchInputLayout.editText?.addTextChangedListener(object : TextWatcher {
Expand Down Expand Up @@ -468,4 +488,9 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView {
}
}
}

private fun getRecyclerviewLayoutParams(): LinearLayout.LayoutParams {
val calculatedHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, minVisibleItem * 48f, resources.displayMetrics).toInt()
return LinearLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, calculatedHeight)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.airbnb.epoxy.CallbackProp
import com.airbnb.epoxy.ModelProp
import com.airbnb.epoxy.ModelView
import com.alfresco.content.data.Buckets
import com.alfresco.content.search.R
import com.alfresco.content.search.databinding.ViewCheckListRowBinding

@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT)
Expand All @@ -21,9 +22,9 @@ internal class ListViewFacetCheckRow @JvmOverloads constructor(
@ModelProp
fun setData(options: Buckets) {
if (options.metrics == null) {
binding.title.text = options.label + " (${options.count})"
binding.title.text = String.format(context.getString(R.string.label_count_format_integer), options.label, options.count)
} else {
binding.title.text = options.label + " (${options.metrics?.get(0)?.value?.count})"
binding.title.text = String.format(context.getString(R.string.label_count_format_string), options.label, options.metrics?.get(0)?.value?.count)
}
}

Expand Down
Loading

0 comments on commit f7691e4

Please sign in to comment.