Skip to content

Commit

Permalink
- Changed setLoadingProgressBarColor() name to setProgressBarColor()
Browse files Browse the repository at this point in the history
- Added setDialogColorTheme() which changes the color of all dialog elements
  • Loading branch information
Ido-Barnea committed Apr 20, 2022
1 parent 22a2085 commit d363fcd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
16 changes: 15 additions & 1 deletion Dialoger/src/main/java/com/barnea/dialoger/Dialoger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@ class Dialoger(
return this
}

/**
* Changes the color of all dialog elements
* @param color the chosen color id
* @return Dialoger object
*/
fun setDialogColorTheme(color: Int): Dialoger {
setTitleColor(color)
setDescriptionColor(color)
setButtonBackgroundColor(color)
setProgressBarColor(color)

return this
}

/**
* @param color the chosen color id
* @return Dialoger object
Expand Down Expand Up @@ -187,7 +201,7 @@ class Dialoger(
* @param color the chosen color id
* @return Dialoger object
*/
fun setLoadingProgressBarColor(color: Int): Dialoger {
fun setProgressBarColor(color: Int): Dialoger {
getDialogProgressBar().indeterminateDrawable.setTintList(intToColorStateList(color))
return this
}
Expand Down
9 changes: 3 additions & 6 deletions app/src/main/java/com/barnea/dialoger/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.barnea.dialoger

import android.os.Bundle
import android.os.Handler
import android.view.Gravity
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity

Expand All @@ -13,21 +12,19 @@ class MainActivity : AppCompatActivity() {

val dialog = Dialoger(this, Dialoger.TYPE_LOADING)
.setTitle("This is a loading dialog...")
.setDescription("We couldn\\'t find the address, and we are not sure anyone will be able to. ever. Maybe try writing it again?")
.setLoadingProgressBarColor(R.color.purple_200)
.setDescription("This might take a while...")
.setProgressBarColor(R.color.purple_200)
.show()

// dismiss the dialog after 3 seconds
Handler().postDelayed({
dialog.dismiss()

Dialoger(this, Dialoger.TYPE_MESSAGE)
.setDialogColorTheme(R.color.green)
.setTitle("New Dialog!")
.setTitleColor(R.color.green)
.setDescription("This was an amazing success!")
.setDescriptionColor(R.color.green)
.setButtonText("ALLONS-Y!")
.setButtonBackgroundColor(R.color.green)
.setButtonOnClickListener {
Toast.makeText(this, "dialog button clicked", Toast.LENGTH_SHORT).show()
}
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
id 'com.android.application' version '7.1.3' apply false
id 'com.android.library' version '7.1.3' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}

Expand Down

0 comments on commit d363fcd

Please sign in to comment.