forked from bilgehankalkan/showcase
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Trendyol/master
Align with fork
- Loading branch information
Showing
44 changed files
with
662 additions
and
719 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#Tue Jun 11 08:49:55 EET 2019 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
library/src/main/java/com/trendyol/showcase/ui/ViewExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.trendyol.showcase.ui | ||
|
||
import android.content.res.ColorStateList | ||
import android.util.TypedValue | ||
import android.view.View | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.annotation.ColorInt | ||
import androidx.annotation.DrawableRes | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import androidx.core.content.ContextCompat | ||
import androidx.core.widget.ImageViewCompat | ||
import com.bumptech.glide.Glide | ||
import com.trendyol.showcase.ui.tooltip.AbsoluteArrowPosition | ||
import com.trendyol.showcase.ui.tooltip.TooltipView | ||
import com.trendyol.showcase.ui.tooltip.TooltipViewState | ||
|
||
internal fun TooltipView.setTooltipViewState(tooltipViewState: TooltipViewState) { | ||
bind(tooltipViewState) | ||
} | ||
|
||
internal fun TooltipView.placeTooltip(margin: Int, arrowPosition: AbsoluteArrowPosition) { | ||
if (arrowPosition == AbsoluteArrowPosition.UP) { | ||
(layoutParams as? ConstraintLayout.LayoutParams)?.apply { | ||
topToTop = 0 // parent | ||
bottomToBottom = -1 | ||
topMargin = margin | ||
} | ||
} else if (arrowPosition == AbsoluteArrowPosition.DOWN) { | ||
(layoutParams as? ConstraintLayout.LayoutParams)?.apply { | ||
topToTop = -1 | ||
bottomToBottom = 0 // parent | ||
bottomMargin = margin | ||
} | ||
} | ||
} | ||
|
||
internal fun TextView.setTextSizeInSp(size: Float) { | ||
setTextSize(TypedValue.COMPLEX_UNIT_SP, size) | ||
} | ||
|
||
internal fun ImageView.layoutMarginStart(margin: Int, percentage: Int?) { | ||
(layoutParams as? ConstraintLayout.LayoutParams)?.apply { | ||
percentage?.let { | ||
endToEnd = 0 | ||
horizontalBias = (it.toFloat() / 100) | ||
} ?: run { | ||
this.marginStart = margin | ||
} | ||
} | ||
} | ||
|
||
internal fun ImageView.setDrawableRes(@DrawableRes drawableRes: Int) { | ||
setImageDrawable(ContextCompat.getDrawable(context, drawableRes)) | ||
} | ||
|
||
internal fun View.isVisible(isVisible: Boolean) { | ||
visibility = if (isVisible) View.VISIBLE else View.GONE | ||
} | ||
|
||
internal fun ImageView.setTint(@ColorInt color: Int) { | ||
ImageViewCompat.setImageTintList(this, ColorStateList.valueOf(color)) | ||
} | ||
|
||
internal fun ImageView.loadImage(imageUrl: String) { | ||
Glide.with(context).load(imageUrl).into(this) | ||
} |
Oops, something went wrong.