Skip to content

Commit

Permalink
Merge pull request #14 from Trendyol/fix-resource-override
Browse files Browse the repository at this point in the history
Fix resource override
  • Loading branch information
bsobe authored Dec 24, 2020
2 parents b59cff3 + 6e62ab4 commit babad9e
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ data class TooltipViewState(

fun getDescriptionVisibility() = descriptionText.isNotEmpty()

fun getTopArrowResource() = if (arrowResource == Constants.DEFAULT_ARROW_RESOURCE) R.drawable.ic_arrow_up else arrowResource
fun getTopArrowResource() = if (arrowResource == Constants.DEFAULT_ARROW_RESOURCE) R.drawable.ic_showcase_arrow_up else arrowResource

fun getTopArrowVisibility() = if (arrowPosition == ArrowPosition.UP) View.VISIBLE else View.GONE

fun getBottomArrowResource() = if (arrowResource == Constants.DEFAULT_ARROW_RESOURCE) R.drawable.ic_arrow_down else arrowResource
fun getBottomArrowResource() = if (arrowResource == Constants.DEFAULT_ARROW_RESOURCE) R.drawable.ic_showcase_arrow_down else arrowResource

fun getBottomArrowVisibility() = if (arrowPosition == ArrowPosition.DOWN) View.VISIBLE else View.GONE

Expand Down
12 changes: 0 additions & 12 deletions library/src/main/res/drawable/ic_custom_arrow_down.xml

This file was deleted.

File renamed without changes.
6 changes: 3 additions & 3 deletions library/src/main/res/layout/layout_tooltip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
bind:arrowHorizontalPosition="@{tooltipViewState.arrowMargin}"
bind:arrowPercentage="@{tooltipViewState.arrowPercentage}"
bind:drawableRes="@{tooltipViewState.topArrowResource}"
tools:srcCompat="@drawable/ic_arrow_up" />
tools:srcCompat="@drawable/ic_showcase_arrow_up" />

<androidx.cardview.widget.CardView
android:id="@+id/card_content"
Expand Down Expand Up @@ -74,7 +74,7 @@
android:visibility="@{tooltipViewState.getCloseButtonVisibility()}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_close"
app:srcCompat="@drawable/ic_showcase_close"
app:tint="@{tooltipViewState.closeButtonColor}" />

<androidx.appcompat.widget.AppCompatTextView
Expand Down Expand Up @@ -133,7 +133,7 @@
bind:arrowHorizontalPosition="@{tooltipViewState.arrowMargin}"
bind:arrowPercentage="@{tooltipViewState.arrowPercentage}"
bind:drawableRes="@{tooltipViewState.bottomArrowResource}"
tools:srcCompat="@drawable/ic_arrow_down" />
tools:srcCompat="@drawable/ic_showcase_arrow_down" />

</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down
8 changes: 0 additions & 8 deletions library/src/main/res/values/colors.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.trendyol.showcase.ui.tooltip

import android.graphics.Color
import com.trendyol.showcase.R

object TooltipViewStateFactory {

fun getInstance() = TooltipViewState(
titleText = "",
descriptionText = "",
titleTextColor = R.color.black,
descriptionTextColor = R.color.black,
backgroundColor = R.color.white,
closeButtonColor = R.color.black,
titleTextColor = Color.BLACK,
descriptionTextColor = Color.BLACK,
backgroundColor = Color.WHITE,
closeButtonColor = Color.BLACK,
showCloseButton = true,
arrowResource = R.drawable.ic_custom_arrow_down,
arrowResource = R.drawable.ic_showcase_arrow_down,
arrowPosition = ArrowPosition.DOWN,
arrowPercentage = 50,
arrowMargin = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class TooltipViewStateTest {
val tooltipViewState = TooltipViewStateFactory.getInstance().copy(arrowResource = DEFAULT_ARROW_RESOURCE)

//then
val expectedResult = R.drawable.ic_arrow_up
val expectedResult = R.drawable.ic_showcase_arrow_up
val actualResult = tooltipViewState.getTopArrowResource()

actualResult `should be` expectedResult
Expand All @@ -131,13 +131,13 @@ class TooltipViewStateTest {
@Test
fun `when arrowResource is not DEFAULT_ARROW_RESOURCE then getTopArrowResource() returns arrowResource`() {
//when
val tooltipViewState = TooltipViewStateFactory.getInstance().copy(arrowResource = R.drawable.ic_custom_arrow_down)
val givenArrowResource = android.R.drawable.arrow_down_float
val tooltipViewState = TooltipViewStateFactory.getInstance().copy(arrowResource = givenArrowResource)

//then
val expectedResult = R.drawable.ic_custom_arrow_down
val actualResult = tooltipViewState.getTopArrowResource()

actualResult `should be` expectedResult
actualResult `should be` givenArrowResource
}

@Test
Expand Down Expand Up @@ -170,7 +170,7 @@ class TooltipViewStateTest {
val tooltipViewState = TooltipViewStateFactory.getInstance().copy(arrowResource = DEFAULT_ARROW_RESOURCE)

//then
val expectedResult = R.drawable.ic_arrow_down
val expectedResult = R.drawable.ic_showcase_arrow_down
val actualResult = tooltipViewState.getBottomArrowResource()

actualResult `should be` expectedResult
Expand All @@ -179,13 +179,13 @@ class TooltipViewStateTest {
@Test
fun `when arrowResource is not DEFAULT_ARROW_RESOURCE then getBottomArrowResource() returns arrowResource`() {
//when
val tooltipViewState = TooltipViewStateFactory.getInstance().copy(arrowResource = R.drawable.ic_custom_arrow_down)
val givenArrowResource = android.R.drawable.arrow_down_float
val tooltipViewState = TooltipViewStateFactory.getInstance().copy(arrowResource = givenArrowResource)

//then
val expectedResult = R.drawable.ic_custom_arrow_down
val actualResult = tooltipViewState.getBottomArrowResource()

actualResult `should be` expectedResult
actualResult `should be` givenArrowResource
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/java/com/trendyol/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void onClick(View v) {
.titleText("Title without a description")
.titleTextSize(16)
.showCloseButton(true)
.arrowResource(R.drawable.ic_custom_arrow_down)
.arrowResource(android.R.drawable.arrow_down_float)
.arrowPosition(ArrowPosition.AUTO)
.highlightType(HighlightType.RECTANGLE)
.highlightPadding(8F)
Expand Down
2 changes: 2 additions & 0 deletions sample/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="black">#000000</color>
<color name="white">#ffffff</color>
</resources>

0 comments on commit babad9e

Please sign in to comment.