diff --git a/libraries/imageslider/src/main/java/com/trendyol/uicomponents/imageslider/ImageSliderView.kt b/libraries/imageslider/src/main/java/com/trendyol/uicomponents/imageslider/ImageSliderView.kt index 27a895f4..a989f036 100644 --- a/libraries/imageslider/src/main/java/com/trendyol/uicomponents/imageslider/ImageSliderView.kt +++ b/libraries/imageslider/src/main/java/com/trendyol/uicomponents/imageslider/ImageSliderView.kt @@ -1,9 +1,7 @@ package com.trendyol.uicomponents.imageslider -import android.annotation.TargetApi import android.app.Activity import android.content.Context -import android.os.Build import android.util.AttributeSet import android.widget.FrameLayout import androidx.appcompat.app.AppCompatActivity @@ -46,8 +44,12 @@ class ImageSliderView : FrameLayout, ImagesPagerAdapter.SliderAdapterItemClickLi } fun setViewState(imageSliderViewState: ImageSliderViewState?) { - if (imageSliderViewState == null) return - setImages(imageSliderViewState) + imageSliderViewState?.let { + binding.viewState = it + binding.executePendingBindings() + + setImages(imageSliderViewState) + } } private fun setImages(imageSliderViewState: ImageSliderViewState?) { @@ -63,6 +65,8 @@ class ImageSliderView : FrameLayout, ImagesPagerAdapter.SliderAdapterItemClickLi } } + + override fun onImageItemClicked(imageUrlList: List, position: Int) { imageSliderViewListener?.onImageSliderItemClicked(imageUrlList, position) } diff --git a/libraries/imageslider/src/main/java/com/trendyol/uicomponents/imageslider/ImageSliderViewState.kt b/libraries/imageslider/src/main/java/com/trendyol/uicomponents/imageslider/ImageSliderViewState.kt index 48b7ef05..31cd8d52 100644 --- a/libraries/imageslider/src/main/java/com/trendyol/uicomponents/imageslider/ImageSliderViewState.kt +++ b/libraries/imageslider/src/main/java/com/trendyol/uicomponents/imageslider/ImageSliderViewState.kt @@ -1,14 +1,29 @@ package com.trendyol.uicomponents.imageslider +import android.view.View + data class ImageSliderViewState( val imageList: List, var isImageDynamic: Boolean? = null, - var imageHeight: Int? = null + var imageHeight: Int? = null, + var isIndicatorAlwaysVisible: Boolean = false ) { fun isSingleImage() = imageList.size == 1 fun isSingleImageVisible() = isSingleImage() - private fun isMultiImage() = imageList.size.greaterThan(1) + fun isMultiImage() = imageList.size.greaterThan(1) + + fun getIndicatorVisibility(): Int { + return if (isIndicatorAlwaysVisible) { + View.VISIBLE + } else { + if (isMultiImage()) { + View.VISIBLE + } else { + View.GONE + } + } + } } diff --git a/libraries/imageslider/src/main/res/layout/view_image_slider.xml b/libraries/imageslider/src/main/res/layout/view_image_slider.xml index 548df6e5..e6ad9165 100644 --- a/libraries/imageslider/src/main/res/layout/view_image_slider.xml +++ b/libraries/imageslider/src/main/res/layout/view_image_slider.xml @@ -1,6 +1,14 @@ + + + + + + @@ -21,6 +29,7 @@ android:paddingTop="@dimen/indicator_padding_vertical" android:paddingRight="@dimen/indicator_padding_horizontal" android:paddingBottom="@dimen/indicator_padding_vertical" + android:visibility="@{viewState.indicatorVisibility}" app:ci_animator="@animator/animator_alpha" app:ci_animator_reverse="@animator/animator_alpha" app:ci_drawable="@drawable/shape_indicator_selected"