Skip to content

Commit

Permalink
3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
angcyo committed Oct 27, 2022
1 parent c2d0f32 commit 8cc8097
Show file tree
Hide file tree
Showing 13 changed files with 209 additions and 46 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 2022-10-27

版本: `3.3.0`, 更新日志:

- `Border`支持禁用色设置
- `DslTabLayout`支持属性`itemEquWidthCount`, 当子元素大于此值时, 开启等宽模式
- 调整变粗属性调用的api
- 修复已知问题

# 2022-9-16

版本: `3.2.5`, 更新日志:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ allprojects {

```kotlin
dependencies {
implementation 'com.github.angcyo.DslTablayout:TabLayout:3.2.5'
implementation 'com.github.angcyo.DslTablayout:TabLayout:3.3.0'

//可选
implementation 'com.github.angcyo.DslTablayout:ViewPager1Delegate:3.2.5'
implementation 'com.github.angcyo.DslTablayout:ViewPager1Delegate:3.3.0'
//可选
implementation 'com.github.angcyo.DslTablayout:ViewPager2Delegate:3.2.5'
implementation 'com.github.angcyo.DslTablayout:ViewPager2Delegate:3.3.0'
}
```

Expand Down
6 changes: 3 additions & 3 deletions Sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation 'com.airbnb.android:lottie:3.2.0'
implementation 'com.airbnb.android:lottie:4.2.2'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.github.angcyo:DslAdapter:4.1.0'
implementation 'com.github.angcyo:DslAdapter:5.2.0'
implementation 'com.github.angcyo:RRes:1.0.1'
implementation 'com.github.angcyo:DslButton:1.1.0'
implementation 'com.github.angcyo:DslButton:1.2.0'

implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation "androidx.viewpager:viewpager:1.0.0"
Expand Down
6 changes: 3 additions & 3 deletions Sample/src/main/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
android:id="@+id/lottie_view"
android:layout_width="30dp"
android:layout_height="30dp"
app:lottie_colorFilter="#333AC4"
app:lottie_colorFilter="@color/colorFilter"
app:lottie_rawRes="@raw/json_play" />

<com.angcyo.widget.DslButton
Expand Down Expand Up @@ -80,7 +80,7 @@
android:id="@+id/lottie_view"
android:layout_width="50dp"
android:layout_height="50dp"
app:lottie_colorFilter="#333AC4"
app:lottie_colorFilter="@color/colorFilter"
app:lottie_rawRes="@raw/json_add" />

<com.angcyo.widget.DslButton
Expand All @@ -105,7 +105,7 @@
android:id="@+id/lottie_view"
android:layout_width="30dp"
android:layout_height="30dp"
app:lottie_colorFilter="#333AC4"
app:lottie_colorFilter="@color/colorFilter"
app:lottie_rawRes="@raw/json_home" />

<com.angcyo.widget.DslButton
Expand Down
6 changes: 3 additions & 3 deletions Sample/src/main/res/layout/sample_fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
android:id="@+id/lottie_view"
android:layout_width="30dp"
android:layout_height="30dp"
app:lottie_colorFilter="#333AC4"
app:lottie_colorFilter="@color/colorFilter"
app:lottie_rawRes="@raw/json_play" />

<com.angcyo.widget.DslButton
Expand Down Expand Up @@ -79,7 +79,7 @@
android:id="@+id/lottie_view"
android:layout_width="50dp"
android:layout_height="50dp"
app:lottie_colorFilter="#333AC4"
app:lottie_colorFilter="@color/colorFilter"
app:lottie_rawRes="@raw/json_add" />

<com.angcyo.widget.DslButton
Expand All @@ -104,7 +104,7 @@
android:id="@+id/lottie_view"
android:layout_width="30dp"
android:layout_height="30dp"
app:lottie_colorFilter="#333AC4"
app:lottie_colorFilter="@color/colorFilter"
app:lottie_rawRes="@raw/json_home" />

<com.angcyo.widget.DslButton
Expand Down
1 change: 1 addition & 0 deletions Sample/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

<color name="white">#ffffff</color>
<color name="text">#A0A0A0</color>
<color name="colorFilter">#333AC4</color>
</resources>
61 changes: 58 additions & 3 deletions TabLayout/src/main/java/com/angcyo/tablayout/DslTabBorder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.view.View
import androidx.core.view.ViewCompat

/**
* 边框
* 边框绘制, 支持首尾圆角中间不圆角的样式
* Email:angcyo@126.com
* @author angcyo
* @date 2019/11/27
Expand All @@ -22,6 +22,9 @@ open class DslTabBorder : DslGradientDrawable() {
* */
var borderDrawItemBackground: Boolean = true

/**是否保持每个[itemView]的圆角都一样, 否则首尾有圆角, 中间没有圆角*/
var borderKeepItemRadius: Boolean = false

var borderBackgroundDrawable: Drawable? = null

/**宽度补偿*/
Expand All @@ -30,6 +33,17 @@ open class DslTabBorder : DslGradientDrawable() {
/**高度补偿*/
var borderBackgroundHeightOffset: Int = 0

/**强制指定选中item的背景颜色*/
var borderItemBackgroundSolidColor: Int? = null

/**当item不可选中时的背景绘制颜色
* [com.angcyo.tablayout.DslTabLayout.itemEnableSelector]
* [borderItemBackgroundSolidColor]*/
var borderItemBackgroundSolidDisableColor: Int? = null

/**强制指定选中item的背景渐变颜色*/
var borderItemBackgroundGradientColors: IntArray? = null

override fun initAttribute(context: Context, attributeSet: AttributeSet?) {
val typedArray =
context.obtainStyledAttributes(attributeSet, R.styleable.DslTabLayout)
Expand Down Expand Up @@ -57,6 +71,11 @@ open class DslTabBorder : DslGradientDrawable() {
borderDrawItemBackground
)

borderKeepItemRadius = typedArray.getBoolean(
R.styleable.DslTabLayout_tab_border_keep_item_radius,
borderKeepItemRadius
)

borderBackgroundWidthOffset = typedArray.getDimensionPixelOffset(
R.styleable.DslTabLayout_tab_border_item_background_width_offset,
borderBackgroundWidthOffset
Expand All @@ -67,6 +86,34 @@ open class DslTabBorder : DslGradientDrawable() {
borderBackgroundHeightOffset
)

//
if (typedArray.hasValue(R.styleable.DslTabLayout_tab_border_item_background_solid_color)) {
borderItemBackgroundSolidColor = typedArray.getColor(
R.styleable.DslTabLayout_tab_border_item_background_solid_color,
gradientStrokeColor
)
}
if (typedArray.hasValue(R.styleable.DslTabLayout_tab_border_item_background_solid_disable_color)) {
borderItemBackgroundSolidDisableColor = typedArray.getColor(
R.styleable.DslTabLayout_tab_border_item_background_solid_disable_color,
borderItemBackgroundSolidColor ?: gradientStrokeColor
)
}

if (typedArray.hasValue(R.styleable.DslTabLayout_tab_border_item_background_gradient_start_color) ||
typedArray.hasValue(R.styleable.DslTabLayout_tab_border_item_background_gradient_end_color)
) {
val startColor = typedArray.getColor(
R.styleable.DslTabLayout_tab_border_item_background_gradient_start_color,
gradientStrokeColor
)
val endColor = typedArray.getColor(
R.styleable.DslTabLayout_tab_border_item_background_gradient_end_color,
gradientStrokeColor
)
borderItemBackgroundGradientColors = intArrayOf(startColor, endColor)
}

typedArray.recycle()

if (originDrawable == null) {
Expand Down Expand Up @@ -132,9 +179,17 @@ open class DslTabBorder : DslGradientDrawable() {
gradientWidthOffset = borderBackgroundWidthOffset
gradientHeightOffset = borderBackgroundHeightOffset

gradientSolidColor = this@DslTabBorder.gradientStrokeColor
gradientSolidColor =
borderItemBackgroundSolidColor ?: this@DslTabBorder.gradientStrokeColor
if (!tabLayout.itemEnableSelector) {
if (borderItemBackgroundSolidDisableColor != null) {
gradientSolidColor = borderItemBackgroundSolidDisableColor!!
}
}

gradientColors = borderItemBackgroundGradientColors

if (isFirst && isLast) {
if ((isFirst && isLast) || borderKeepItemRadius) {
//只有一个child
gradientRadii = this@DslTabBorder.gradientRadii
} else if (isFirst) {
Expand Down
20 changes: 16 additions & 4 deletions TabLayout/src/main/java/com/angcyo/tablayout/DslTabDivider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,22 @@ open class DslTabDivider : DslGradientDrawable() {
dividerMarginBottom
)

gradientSolidColor = typedArray.getColor(
R.styleable.DslTabLayout_tab_divider_solid_color,
gradientSolidColor
)
if (typedArray.hasValue(R.styleable.DslTabLayout_tab_divider_solid_color)) {
gradientSolidColor = typedArray.getColor(
R.styleable.DslTabLayout_tab_divider_solid_color,
gradientSolidColor
)
} else if (typedArray.hasValue(R.styleable.DslTabLayout_tab_border_stroke_color)) {
gradientSolidColor = typedArray.getColor(
R.styleable.DslTabLayout_tab_border_stroke_color,
gradientSolidColor
)
} else {
gradientSolidColor = typedArray.getColor(
R.styleable.DslTabLayout_tab_deselect_color,
gradientSolidColor
)
}

gradientStrokeColor = typedArray.getColor(
R.styleable.DslTabLayout_tab_divider_stroke_color,
Expand Down
Loading

0 comments on commit 8cc8097

Please sign in to comment.