Skip to content

Commit

Permalink
Merge pull request #26 from gauravyad69/newfeaturebranch
Browse files Browse the repository at this point in the history
2 new features, (TYPE.NONE) and (change fontsize of title and description)
  • Loading branch information
iamageo committed Feb 10, 2024
2 parents b80d254 + 1bc1c6f commit 027c484
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 29 deletions.
45 changes: 45 additions & 0 deletions .idea/appInsightsSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 50 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ allprojects {
}
}
```
For Ktx
```gradle
allprojects {
repositories {
...
maven { url = uri("https://www.jitpack.io" ) }
}
}
```


And add a dependency code to your **module**'s `build.gradle` file.
```gradle
dependencies {
Expand All @@ -55,7 +66,7 @@ Add in you Activity file.
```kotlin
BeautifulDialog.build(this)
.title("Title success", titleColor = R.color.black)
.body("Description success", color = R.color.black)
.description("Description success", color = R.color.black)
.type(type= BeautifulDialog.TYPE.SUCCESS)
.position(BeautifulDialog.POSITIONS.CENTER)
.onPositive(text = "Confirm", shouldIDismissOnClick = false) {
Expand Down Expand Up @@ -94,13 +105,13 @@ TYPE.SUCCESS
TYPE.INFO
TYPE.ALERT
TYPE.ERROR
TYPE.NONE
```
By Default Position is Bottom.

| SUCCESS | INFO | ALERT | ERROR |
| :---------------: | :---------------: | :---------------: | :---------------: |
| <img src="https://user-images.githubusercontent.com/26925002/162633413-8cc80819-5ff8-4258-b60e-5101d058c907.png" align="center" width="70%"/> | <img src="https://user-images.githubusercontent.com/26925002/162633421-653961c1-a77b-4009-945d-09618c6fd772.png" align="center" width="70%"/> | | <img src="https://user-images.githubusercontent.com/26925002/162633431-38a1a45e-91b7-4a1a-b4ba-686fe440b8b5.png" align="center" width="70%"/>

| SUCCESS | INFO | ALERT | ERROR |
|:---------------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------:|:-----:|:---------------------------------------------------------------------------------------------------------------------------------------------:|
| <img src="https://user-images.githubusercontent.com/26925002/162633413-8cc80819-5ff8-4258-b60e-5101d058c907.png" align="center" width="70%"/> | <img src="https://user-images.githubusercontent.com/26925002/162633421-653961c1-a77b-4009-945d-09618c6fd772.png" align="center" width="70%"/> | | <img src="https://user-images.githubusercontent.com/26925002/162633431-38a1a45e-91b7-4a1a-b4ba-686fe440b8b5.png" align="center" width="70%"/> |

## Positioning 📱
We can customize the Position of Dialog.
Expand All @@ -110,26 +121,45 @@ POSITIONS.BOTTOM
```
By default, the Position is **Bottom**.

| CENTER | BOTTOM
| :---------------: | :---------------: |
| <img src="https://user-images.githubusercontent.com/26925002/162633413-8cc80819-5ff8-4258-b60e-5101d058c907.png" align="center" width="50%"/> | <img src="https://user-images.githubusercontent.com/26925002/162633465-7dae6ed4-c638-432e-a823-7276e046546b.png" align="center" width="50%"/>
| CENTER | BOTTOM |
|:---------------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------:|
| <img src="https://user-images.githubusercontent.com/26925002/162633413-8cc80819-5ff8-4258-b60e-5101d058c907.png" align="center" width="50%"/> | <img src="https://user-images.githubusercontent.com/26925002/162633465-7dae6ed4-c638-432e-a823-7276e046546b.png" align="center" width="50%"/> |

## Hacktoberfest 2022
This project has been submitted for hacktoberfest 2022. [See more here](https://hacktoberfest.com/)

## Beautiful Dialog Attributes
Attributes | Type | Default | Description
--- | --- | --- | ---
title | String | none | Title of you dialog.
description | String | none | Description of you dialog.
position | POSITIONS.BOTTOM, POSITIONS.CENTER | POSITIONS.BOTTOM | Indicates the position of the dialog.
type | TYPE.SUCCESS, TYPE.INFO, TYPE.ALERT or TYPE.ERROR | none | Indicates the dialog type, each type contains an icon.
onPositive | onClick | none | Button positive click.
onNegative | onClick | none | Button negative click.
hideNegativeButton | Boolean | false | hide negative button.
cancelable | Boolean | false | set if Beautiful is cancelable on click in screen ❌.
shouldIDismissOnClick | boolean | true | set if dialog dismiss on click in onPositive or onNegative.
dialogIcon | Int, drawable | none | set dialog icon.
| Attributes | Type | Default | Description |
|-----------------------|--------------------------------------------------------------|------------------|-------------------------------------------------------------|
| title | String | none | Title of you dialog. |
| description | String | none | Description of you dialog. |
| position | POSITIONS.BOTTOM, POSITIONS.CENTER | POSITIONS.BOTTOM | Indicates the position of the dialog. |
| type | TYPE.SUCCESS, TYPE.INFO, TYPE.ALERT, TYPE.ERROR or TYPE.NONE | success | Indicates the dialog type, each type contains an icon. |
| onPositive | onClick | none | Button positive click. |
| onNegative | onClick | none | Button negative click. |
| hideNegativeButton | Boolean | false | hide negative button. |
| cancelable | Boolean | false | set if Beautiful is cancelable on click in screen ❌. |
| shouldIDismissOnClick | boolean | true | set if dialog dismiss on click in onPositive or onNegative. |
| dialogIcon | Int, drawable | none | set dialog icon. |

## Attributes of Positive and Negative Buttons
| Attributes | Type | Default | Description |
|-----------------------|----------|---------|-------------------------------|
| text | String | none | Text of button |
| fontStyle | typeface | default | Fontstyle of button |
| buttonBackroundColor | Int | black | Backround resource of button |
| textColor | Int | gray | Text color of button |
| shouldIDismissOnClick | Boolean | none | Cancel dialog onclick if true |
| action | Unit | none | what to do |

## Attributes of Title And Description
| Attributes | Type | Default | Description |
|------------|----------|---------|------------------|
| text | String | none | Text |
| fontStyle | typeface | default | Fontstyle |
| fontSize | Int | 14 | Change font size |
| color | Int | gray | Text Color |

## License
```
Copyright 2022 Geovani Amaral
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/com/iamageo/beautiful_dialog/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,21 @@ class MainActivity : AppCompatActivity() {
.hideNegativeButton(hide = false)
}


binding.btnNone.setOnClickListener {
BeautifulDialog.build(this)
.title("Title alert", titleColor = R.color.black)
.description("Description alert", color = R.color.black)
.position(BeautifulDialog.POSITIONS.CENTER)
.type(BeautifulDialog.TYPE.NONE)
.onPositive("Confirm", shouldIDismissOnClick = false) {
Toast.makeText(this, "confirm", Toast.LENGTH_SHORT).show()
}
.onNegative("Cancel") {
Toast.makeText(this, "cancel", Toast.LENGTH_SHORT).show()
}
.hideNegativeButton(hide = false)
}

}
}
8 changes: 8 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
android:layout_marginTop="16dp"
android:text="@string/error_dialog" />

<Button
android:id="@+id/btnNone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="16dp"
android:text="@string/none_dialog" />


</LinearLayout>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<string name="info_dialog">Info dialog</string>
<string name="alert_dialog">Alert dialog</string>
<string name="error_dialog">Error dialog</string>
<string name="none_dialog">None Dialog</string>
</resources>
19 changes: 17 additions & 2 deletions library/src/main/java/com/iamageo/library/BeautifulDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.app.AlertDialog
import android.graphics.Typeface
import android.graphics.drawable.Drawable
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.widget.RelativeLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.view.isVisible
import com.iamageo.library.BeautifulDialog.Companion.binding
import com.iamageo.library.databinding.BeautifulDialogBinding

Expand All @@ -24,7 +26,7 @@ class BeautifulDialog {
* Types For Alert Dialog
* */
enum class TYPE {
SUCCESS, INFO, ALERT, ERROR
SUCCESS, INFO, ALERT, ERROR, NONE
}

companion object {
Expand Down Expand Up @@ -57,12 +59,16 @@ class BeautifulDialog {
fun AlertDialog.title(
title: String,
fontStyle: Typeface? = null,
fontSize: Int = 0,
titleColor: Int = 0
): AlertDialog {
binding.title.text = title.trim()
if (fontStyle != null) {
binding.title.typeface = fontStyle
}
if (fontSize != 0) {
binding.subHeading.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize.toFloat())
}
if (titleColor != 0) {
binding.title.setTextColor(titleColor)
}
Expand Down Expand Up @@ -114,13 +120,17 @@ fun AlertDialog.position(
fun AlertDialog.description(
description: String,
fontStyle: Typeface? = null,
fontSize: Int = 0,
color: Int = 0
): AlertDialog {
binding.subHeading.text = description.trim()
binding.subHeading.show()
if (fontStyle != null) {
binding.subHeading.typeface = fontStyle
}
if (fontSize != 0) {
binding.subHeading.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize.toFloat())
}
if (color != 0) {
binding.subHeading.setTextColor(color)
}
Expand All @@ -146,6 +156,11 @@ fun AlertDialog.type(
BeautifulDialog.TYPE.ERROR -> {
binding.dialogAnimation.setAnimation(R.raw.error)
}
BeautifulDialog.TYPE.NONE -> {
binding.dialogAnimation.hide()
binding.dialogAnimation.layoutParams.height=0

}
}
binding.dialogAnimation.show()

Expand Down
4 changes: 2 additions & 2 deletions library/src/main/res/layout/beautiful_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

<com.airbnb.lottie.LottieAnimationView
android:id="@+id/dialogAnimation"
app:lottie_fileName="@raw/success"
app:lottie_autoPlay="true"
app:lottie_loop="true"
android:layout_width="70dp"
Expand Down Expand Up @@ -117,4 +116,5 @@
</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
</RelativeLayout>
<!-- app:lottie_fileName="@raw/success"-->

0 comments on commit 027c484

Please sign in to comment.