-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
83 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,97 @@ | ||
# iOSAlertForAndroid | ||
|
||
[![](https://jitpack.io/v/Maliotis/iOSAlertForAndroid.svg)](https://jitpack.io/#Maliotis/iOSAlertForAndroid) | ||
iOSAlertForAndroid is an easy to use library for displaying ios likel alerts. | ||
|
||
## Setup | ||
|
||
Gradle: | ||
Gradle: [![](https://jitpack.io/v/Maliotis/iOSAlertForAndroid.svg)](https://jitpack.io/#Maliotis/iOSAlertForAndroid) | ||
|
||
``` | ||
```gradle | ||
repositories { | ||
mavenCentral() | ||
google() | ||
maven { url 'https://jitpack.io' } | ||
} | ||
dependencies { | ||
implementation 'com.github.Maliotis:iOSAlertForAndroid:0.1.1' | ||
implementation 'com.github.Maliotis:iOSAlertForAndroid:${latestVersion}' | ||
} | ||
``` | ||
|
||
## Usage | ||
|
||
A simple usage of the library | ||
|
||
![Simple Alert](https://github.com/Maliotis/iOSAlertForAndroid/blob/master/app/src/main/res/drawable/simple_alert.png) | ||
|
||
```Kotlin | ||
IOSAlert.Builder(this) | ||
.title("title") | ||
.body("body") | ||
.iOSAlertPositiveClickListener(object: IOSClickListener { | ||
override fun onClick(dialog: Dialog?) { | ||
// Your code here on Positive Click | ||
dialog?.dismiss() | ||
} | ||
}) | ||
.isCancellable(false) | ||
.buildAndShow() | ||
``` | ||
|
||
## Customization | ||
|
||
The library allows for the following customizations: | ||
* **Typeface** | ||
* **Body** *optional* | ||
* **Blur Radius** - controls the intensity if the blur. *0f < blurRadius ≤ 25f* | ||
* **Transparency** - Sets the transparency value with a white background | ||
* **Background Color** | ||
* **Cancellable** - Prevents user from escaping the alert | ||
|
||
|
||
![Custom Alert](https://github.com/Maliotis/iOSAlertForAndroid/blob/master/app/src/main/res/drawable/custom_alert.png) | ||
|
||
```Kotlin | ||
IOSAlert.Builder(this) | ||
.title("Title") | ||
.body("This is a body text") | ||
.typeface(Typeface.SERIF) | ||
.iOSAlertPositiveClickListener(object: IOSClickListener { | ||
override fun onClick(dialog: Dialog?) { | ||
// Your code here on Positive Click | ||
Log.d(TAG, "onClick: positive button pressed") | ||
dialog?.dismiss() | ||
} | ||
}) | ||
.negativeText("Cancel") | ||
.iOSAlertNegativeClickListener(object: IOSClickListener { | ||
override fun onClick(dialog: Dialog?) { | ||
// Your code here on Negative Click | ||
Log.d(TAG, "onClick: negative button pressed") | ||
dialog?.dismiss() | ||
} | ||
}) | ||
// The blur radius <= 25f | ||
.blurRadius(22f) | ||
// Sets the transparency to 0.2f - that translates to 0.8 alpha value | ||
.transparency(0.2f) | ||
// On touch down will highlight the buttons with a gray tint | ||
.tintButtons(true) | ||
//.tintButtonsColor(Color.DKGRAY) | ||
//.backgroundColor(Color.WHITE) | ||
//.backgroundColor(255, 255, 255, 255) | ||
//.cornerRadius(10f) // 10f by default | ||
|
||
// User won't be able to leave the alert without pressing one of the buttons | ||
.isCancellable(false) | ||
|
||
|
||
//.build() // Use build instead of buildAndShow if you want to show the alert yourself | ||
// In the case use: iosAlert.show(supportFragmentManager, "tag") | ||
.buildAndShow() | ||
``` | ||
|
||
|
||
|
||
## License | ||
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) |