Skip to content

Commit

Permalink
Send current textColor to initProgress() so it'll be able to restor…
Browse files Browse the repository at this point in the history
…e it when progress is done
  • Loading branch information
KevinBoulongne committed May 24, 2024
1 parent d15ded0 commit be700bd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main/java/com/infomaniak/lib/core/utils/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import androidx.viewbinding.ViewBinding
import coil.ImageLoader
import coil.load
import com.github.razir.progressbutton.DrawableButton.Companion.GRAVITY_CENTER
import com.github.razir.progressbutton.TextChangeAnimatorParams
import com.github.razir.progressbutton.attachTextChangeAnimator
import com.github.razir.progressbutton.bindProgressButton
import com.github.razir.progressbutton.hideProgress
Expand Down Expand Up @@ -101,9 +102,20 @@ fun Context.showToast(title: Int, duration: Int = Toast.LENGTH_LONG) {
Toast.makeText(this, title, duration).show()
}

fun MaterialButton.initProgress(lifecycle: LifecycleOwner) {
fun MaterialButton.initProgress(lifecycle: LifecycleOwner, color: Int? = null) {

lifecycle.bindProgressButton(button = this)
attachTextChangeAnimator()

val params = color?.let {
TextChangeAnimatorParams().apply {
useCurrentTextColor = false
textColor = color
fadeInMills = 0L
fadeOutMills = 0L
}
}

attachTextChangeAnimator(params)
}

fun MaterialButton.showProgress(color: Int? = null) {
Expand Down

0 comments on commit be700bd

Please sign in to comment.