Skip to content

Repository files navigation

Beautiful Dialog


🗨️ Beautiful Dialog is a Simple and Beautiful custom dialog.


LicenseAPIrepo size
forksstars

Android CIAndroid Unit Test

Demonstration

Star history 🌟

Star History Chart

Including in your project

Gradle

Add below codes to your rootbuild.gradle file (not your module build.gradle file).

allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}

For Ktx

allprojects {
repositories {
...
maven { url = uri("https://www.jitpack.io" ) }
}
}

And add a dependency code to your module's build.gradle file.

dependencies {
implementation 'com.github.iamageo:beautiful-dialog:1.0.8'
}

Basic Usage

Add in you Activity file.

BeautifulDialog.build(this)
.title("Title success", titleColor =R.color.black)
.description("Description success", color =R.color.black)
.type(type=BeautifulDialog.TYPE.SUCCESS)
.position(BeautifulDialog.POSITIONS.CENTER)
.onPositive(text ="Confirm", shouldIDismissOnClick =false) {
Toast.makeText(this, "confirm", Toast.LENGTH_SHORT).show()
}
.onNegative(text ="Cancel") {
Toast.makeText(this, "cancel", Toast.LENGTH_SHORT).show()
}

How to hide Negative Button

just call in build:

.hideNegativeButton(hide =true)

How to change animation 📌

📌 Note: your icon can be of type iconRes (Int)

if you call .dialogAnimation() don't call .type()

.dialogAnimation(iconRes)

how not to cancel dialog on click ❌

just call property shouldIDismissOnClick in onPositive or onNegative:

.onPositive(text ="Confirm", shouldIDismissOnClick =false) {
Toast.makeText(this, "click in positive button", Toast.LENGTH_SHORT).show()
}

Type ✔️ ℹ️ ⚠ ❌

We can customize the type of Dialog.

TYPE.SUCCESSTYPE.INFOTYPE.ALERTTYPE.ERRORTYPE.NONE
SUCCESSINFOALERTERRORNONE

Positioning 📱

We can customize the Position of Dialog.

POSITIONS.TOPPOSITIONS.CENTERPOSITIONS.BOTTOM

By default, the Position is CENTER.

TOPCENTERBOTTOM

Hacktoberfest 2022

This project has been submitted for hacktoberfest 2022. See more here

Beautiful Dialog Attributes

AttributesTypeDefaultDescription
titleStringnoneTitle of you dialog.
descriptionStringnoneDescription of you dialog.
positionPOSITIONS.BOTTOM, POSITIONS.CENTERPOSITIONS.BOTTOMIndicates the position of the dialog.
typeTYPE.SUCCESS, TYPE.INFO, TYPE.ALERT, TYPE.ERROR or TYPE.NONEsuccessIndicates the dialog type, each type contains an icon.
onPositiveonClicknoneButton positive click.
onNegativeonClicknoneButton negative click.
hideNegativeButtonBooleanfalsehide negative button.
cancelableBooleanfalseset if Beautiful is cancelable on click in screen ❌.
shouldIDismissOnClickbooleantrueset if dialog dismiss on click in onPositive or onNegative.
dialogIconInt, drawablenoneset dialog icon.

Attributes of Positive and Negative Buttons

AttributesTypeDefaultDescription
textStringnoneText of button
fontStyletypefacedefaultFontstyle of button
buttonBackroundColorIntblackBackround resource of button
textColorIntgrayText color of button
shouldIDismissOnClickBooleannoneCancel dialog onclick if true
actionUnitnonewhat to do

Attributes of Title And Description

AttributesTypeDefaultDescription
textStringnoneText
fontStyletypefacedefaultFontstyle
fontSizeInt14Change font size
colorIntgrayText Color

License

 Copyright 2022 Geovani Amaral
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.