From 5147c1d0e7f450f365ae3e037ca1f36b2380ecc3 Mon Sep 17 00:00:00 2001 From: sigma1326 Date: Wed, 16 Jan 2019 03:35:31 +0330 Subject: [PATCH] Create README.md --- README.md | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..685333d --- /dev/null +++ b/README.md @@ -0,0 +1,151 @@ +# SweetAlertDialogPersian +updated version of original sweetAlertDialog repo + +## Setup +The simplest way to use SweetAlertDialog is to add the library as aar dependency to your build. + + + +**Gradle** + + allprojects { + repositories { + ... + maven { url 'https://jitpack.io' } + } + } + + dependencies { + implementation 'com.github.sigma1326:SweetAlertDialogPersian:v1.0' + } + + + + + ## Usage + +show material progress + + SweetAlertDialog pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE); + pDialog.getProgressHelper().setBarColor(Color.parseColor("#A5DC86")); + pDialog.setTitleText("Loading"); + pDialog.setCancelable(false); + pDialog.show(); + + +You can customize progress bar dynamically with materialish-progress methods via **SweetAlertDialog.getProgressHelper()**: +- resetCount() +- isSpinning() +- spin() +- stopSpinning() +- getProgress() +- setProgress(float progress) +- setInstantProgress(float progress) +- getCircleRadius() +- setCircleRadius(int circleRadius) +- getBarWidth() +- setBarWidth(int barWidth) +- getBarColor() +- setBarColor(int barColor) +- getRimWidth() +- setRimWidth(int rimWidth) +- getRimColor() +- setRimColor(int rimColor) +- getSpinSpeed() +- setSpinSpeed(float spinSpeed) + + + +more usages about progress, please see the sample. + +A basic message: + + new SweetAlertDialog(this) + .setTitleText("Here's a message!") + .show(); + +A title with a text under: + + new SweetAlertDialog(this) + .setTitleText("Here's a message!") + .setContentText("It's pretty, isn't it?") + .show(); + +A error message: + + new SweetAlertDialog(this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("Oops...") + .setContentText("Something went wrong!") + .show(); + +A warning message: + + new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("Are you sure?") + .setContentText("Won't be able to recover this file!") + .setConfirmText("Yes,delete it!") + .show(); + +A success message: + + new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE) + .setTitleText("Good job!") + .setContentText("You clicked the button!") + .show(); + +A message with a custom icon: + + new SweetAlertDialog(this, SweetAlertDialog.CUSTOM_IMAGE_TYPE) + .setTitleText("Sweet!") + .setContentText("Here's a custom image.") + .setCustomImage(R.drawable.custom_img) + .show(); + +Bind the listener to confirm button: + + new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("Are you sure?") + .setContentText("Won't be able to recover this file!") + .setConfirmText("Yes,delete it!") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sDialog) { + sDialog.dismissWithAnimation(); + } + }) + .show(); + +Show the cancel button and bind listener to it: + + new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("Are you sure?") + .setContentText("Won't be able to recover this file!") + .setCancelText("No,cancel plx!") + .setConfirmText("Yes,delete it!") + .showCancelButton(true) + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sDialog) { + sDialog.cancel(); + } + }) + .show(); + +**Change** the dialog style upon confirming: + + new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("Are you sure?") + .setContentText("Won't be able to recover this file!") + .setConfirmText("Yes,delete it!") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sDialog) { + sDialog + .setTitleText("Deleted!") + .setContentText("Your imaginary file has been deleted!") + .setConfirmText("OK") + .setConfirmClickListener(null) + .changeAlertType(SweetAlertDialog.SUCCESS_TYPE); + } + }) + .show();