diff --git a/libraries/toolbar/README.md b/libraries/toolbar/README.md index 92b2b835..277e0882 100644 --- a/libraries/toolbar/README.md +++ b/libraries/toolbar/README.md @@ -46,6 +46,8 @@ To customize **Toolbar** you can set [ToolbarViewState](src/main/java/com/trendy | `app:hideLeftImage` | Hide flag for left image. | false | `app:hideLeftImage="true"` | | `app:leftImageContentDescription` | Text for Left Image of Talkback | "" | `app:hideLeftImage="Back"` | | `app:rightImageContentDescription` | Text for Right Image of Talkback | "" | `app:hideLeftImage="Add"` | +| `app:rightImageDrawableVerticalMargin` | Vertical margin for right drawable | 0 | `app:rightImageDrawableVerticalMargin="12dp"`| +| `app:enableDotPoint` | Right drawable's dots point enabled status | false | `app:enableDotPoint="true"` | Sample usage with attributes: diff --git a/libraries/toolbar/src/main/java/com/trendyol/uicomponents/toolbar/Extensions.kt b/libraries/toolbar/src/main/java/com/trendyol/uicomponents/toolbar/Extensions.kt index b2453b1e..5547f924 100644 --- a/libraries/toolbar/src/main/java/com/trendyol/uicomponents/toolbar/Extensions.kt +++ b/libraries/toolbar/src/main/java/com/trendyol/uicomponents/toolbar/Extensions.kt @@ -35,6 +35,11 @@ internal fun View.setEndMargin(endMargin: Int?) { } } +internal fun AppCompatImageView.setVerticalPadding(padding: Int?) { + if (padding == null) return + this.setPadding(0, padding, 0, padding) +} + /** * Set debounce time(millis) to onClickListener for prevent multiple clicks. * @param debounceMillis: Millis time that gives delay between clicks. diff --git a/libraries/toolbar/src/main/java/com/trendyol/uicomponents/toolbar/Toolbar.kt b/libraries/toolbar/src/main/java/com/trendyol/uicomponents/toolbar/Toolbar.kt index d595dd8e..638e043a 100644 --- a/libraries/toolbar/src/main/java/com/trendyol/uicomponents/toolbar/Toolbar.kt +++ b/libraries/toolbar/src/main/java/com/trendyol/uicomponents/toolbar/Toolbar.kt @@ -6,6 +6,7 @@ import android.view.LayoutInflater import android.view.View import androidx.constraintlayout.widget.ConstraintLayout import com.trendyol.uicomponents.toolbar.databinding.ViewToolbarBinding +import androidx.core.view.isVisible class Toolbar : ConstraintLayout { @@ -103,6 +104,10 @@ class Toolbar : ConstraintLayout { ) val rightImageDrawableMarginEnd = getDimensionPixelOffset(R.styleable.Toolbar_rightImageDrawableMarginEnd, 0) + val rightImageDrawableVerticalMargin = + getDimensionPixelOffset(R.styleable.Toolbar_rightImageDrawableVerticalMargin, 0) + val enableDotPoint = + getBoolean(R.styleable.Toolbar_enableDotPoint, false) val leftImageDrawableMarginStart = getDimensionPixelOffset(R.styleable.Toolbar_leftImageDrawableMarginStart, 0) val hideLeftImage = getBoolean(R.styleable.Toolbar_hideLeftImage, false) @@ -127,6 +132,8 @@ class Toolbar : ConstraintLayout { lowerRightTextMarginEndInPixel = lowerRightTextMarginEnd, rightImageDrawableMarginEndInPixel = rightImageDrawableMarginEnd, leftImageDrawableMarginStartInPixel = leftImageDrawableMarginStart, + rightImageDrawableVerticalMarginInPixel = rightImageDrawableVerticalMargin, + enableDotPoint = enableDotPoint, hideLeftImage = hideLeftImage, leftImageContentDescription = leftImageContentDescription, rightImageContentDescription = rightImageContentDescription @@ -148,6 +155,9 @@ class Toolbar : ConstraintLayout { binding.imageRight.setDrawableResource(rightImageDrawableResId) binding.imageRight.setEndMargin(rightImageDrawableMarginEndInPixel) binding.imageRight.contentDescription = rightImageContentDescription + binding.imageRight.setVerticalPadding(rightImageDrawableVerticalMarginInPixel) + + binding.imageViewDot.isVisible = enableDotPoint binding.textLeftUp.text = upperLeftTextValue binding.textLeftUp.visibility = upperLeftTextVisibility diff --git a/libraries/toolbar/src/main/java/com/trendyol/uicomponents/toolbar/ToolbarViewState.kt b/libraries/toolbar/src/main/java/com/trendyol/uicomponents/toolbar/ToolbarViewState.kt index b2043b20..3328ad0c 100644 --- a/libraries/toolbar/src/main/java/com/trendyol/uicomponents/toolbar/ToolbarViewState.kt +++ b/libraries/toolbar/src/main/java/com/trendyol/uicomponents/toolbar/ToolbarViewState.kt @@ -30,6 +30,8 @@ data class ToolbarViewState( @Px val lowerRightTextMarginEndInPixel: Int? = null, @Px val rightImageDrawableMarginEndInPixel: Int? = null, @Px val leftImageDrawableMarginStartInPixel: Int? = null, + @Px val rightImageDrawableVerticalMarginInPixel: Int? = null, + val enableDotPoint: Boolean = false, val isUpperRightTextEnabled: Boolean = true, val hideLeftImage: Boolean = false, val leftImageContentDescription: String = "", diff --git a/libraries/toolbar/src/main/res/drawable/orange_dot.xml b/libraries/toolbar/src/main/res/drawable/orange_dot.xml new file mode 100644 index 00000000..eceed98e --- /dev/null +++ b/libraries/toolbar/src/main/res/drawable/orange_dot.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/libraries/toolbar/src/main/res/layout/view_toolbar.xml b/libraries/toolbar/src/main/res/layout/view_toolbar.xml index 2b23b9bd..ae55aa31 100644 --- a/libraries/toolbar/src/main/res/layout/view_toolbar.xml +++ b/libraries/toolbar/src/main/res/layout/view_toolbar.xml @@ -120,6 +120,16 @@ app:layout_constraintTop_toTopOf="parent" tools:srcCompat="@drawable/trendyol_uicomponents_toolbar_arrow_back" /> + + + + diff --git a/sample/src/main/java/com/trendyol/uicomponents/ToolbarActivity.kt b/sample/src/main/java/com/trendyol/uicomponents/ToolbarActivity.kt index 9128a041..16549f9b 100644 --- a/sample/src/main/java/com/trendyol/uicomponents/ToolbarActivity.kt +++ b/sample/src/main/java/com/trendyol/uicomponents/ToolbarActivity.kt @@ -25,10 +25,13 @@ class ToolbarActivity : AppCompatActivity() { private fun setUpToolbar3() { with(binding.toolbar3) { viewState = ToolbarViewState( - rightImageDrawableResId = android.R.drawable.ic_menu_add, + rightImageDrawableResId = R.drawable.ic_info, rightImageContentDescription = "Add", middleText = "

HTML text

", - upperLeftTextMarginStartInPixel = 20 + upperLeftTextMarginStartInPixel = 20, + rightImageDrawableMarginEndInPixel = 0, + rightImageDrawableVerticalMarginInPixel = 0, + enableDotPoint = true ) lowerLeftTextClickListener = { showToast("toolbar3.lowerLeftTextClickListener") } diff --git a/sample/src/main/res/drawable/ic_info.xml b/sample/src/main/res/drawable/ic_info.xml new file mode 100644 index 00000000..74ae206e --- /dev/null +++ b/sample/src/main/res/drawable/ic_info.xml @@ -0,0 +1,13 @@ + + + +