项目作者: varunjohn

项目描述 :
A library to show iOS like AlertView in Android as Dialogs
高级语言: Java
项目地址: git://github.com/varunjohn/iOSDialogs4Android.git
创建时间: 2018-08-14T13:04:49Z
项目社区:https://github.com/varunjohn/iOSDialogs4Android

开源协议:

下载


iOSDialogs4Android

Its a library to show iOS like AlertView in Android as Dialogs with similar animations.

ezgif-2-83e6a67994e5

Gradle dependency

Download

Add this dependency in your app level build.gradle file

  1. implementation 'com.varunjohn1990.libraries:iosdialogs4android:2.0.1'

How to use

Just use this friendly builder pattern to show the Dialog.

For simple message

  1. new IOSDialog.Builder(this)
  2. .message(R.string.dialog_message) // String or String Resource ID
  3. .build()
  4. .show();

For 2 options

  1. new IOSDialog.Builder(context)
  2. .title("iOS Dialogs") // String or String Resource ID
  3. .message(R.string.dialog_message) // String or String Resource ID
  4. .positiveButtonText("Yeah, sure") // String or String Resource ID
  5. .negativeButtonText("No Thanks") // String or String Resource ID
  6. .positiveClickListener(new IOSDialog.Listener() {
  7. @Override
  8. public void onClick(IOSDialog iosDialog) {
  9. iosDialog.dismiss();
  10. Toast.makeText(context, "Thanks :)", Toast.LENGTH_SHORT).show();
  11. }
  12. }).negativeClickListener(new IOSDialog.Listener() {
  13. @Override
  14. public void onClick(IOSDialog iosDialog) {
  15. iosDialog.dismiss();
  16. Toast.makeText(context, ":(", Toast.LENGTH_SHORT).show();
  17. }
  18. })
  19. .build()
  20. .show();

For multiple options

  1. List<IOSDialogButton> iosDialogButtons = new ArrayList<>();
  2. iosDialogButtons.add(new IOSDialogButton(1, "Add new user", true, IOSDialogButton.TYPE_POSITIVE));
  3. iosDialogButtons.add(new IOSDialogButton(2, "Check user status"));
  4. iosDialogButtons.add(new IOSDialogButton(3, "Logout all user", false, IOSDialogButton.TYPE_NEGATIVE));
  5. new IOSDialog.Builder(this)
  6. .title("iOS Dialogs") // String or String Resource ID
  7. .message(R.string.dialog_message) // String or String Resource ID
  8. .multiOptions(true) // Set this true other it will not work
  9. .multiOptionsListeners(new IOSDialogMultiOptionsListeners() {
  10. @Override
  11. public void onClick(IOSDialog iosDialog, IOSDialogButton iosDialogButton) {
  12. iosDialog.dismiss();
  13. switch (iosDialogButton.getId()) {
  14. case 1:
  15. Toast.makeText(context, "Add new user", Toast.LENGTH_SHORT).show();
  16. case 2:
  17. Toast.makeText(context, "Check user status", Toast.LENGTH_SHORT).show();
  18. break;
  19. case 3:
  20. Toast.makeText(context, "Logout all user", Toast.LENGTH_SHORT).show();
  21. }
  22. }
  23. })
  24. .iosDialogButtonList(iosDialogButtons)
  25. .build()
  26. .show();

All available options

  1. new IOSDialog.Builder(context)
  2. .title("iOS Dialogs") // String or String Resource ID
  3. .message(R.string.dialog_message) // String or String Resource ID
  4. .positiveButtonText("Yeah, sure") // String or String Resource ID
  5. .negativeButtonText("No Thanks") // String or String Resource ID
  6. .cancelable(true) // Dialog will dismiss if clicked outside
  7. .enableAnimation(true) // To enable enter and exit animations
  8. .positiveClickListener(new IOSDialog.Listener() {
  9. @Override
  10. public void onClick(IOSDialog iosDialog) {
  11. iosDialog.dismiss();
  12. Toast.makeText(context, "Thanks :)", Toast.LENGTH_SHORT).show();
  13. }
  14. }).negativeClickListener(new IOSDialog.Listener() {
  15. @Override
  16. public void onClick(IOSDialog iosDialog) {
  17. iosDialog.dismiss();
  18. Toast.makeText(context, ":(", Toast.LENGTH_SHORT).show();
  19. }
  20. }).cancelListener(new IOSDialog.Listener() {
  21. @Override
  22. public void onClick(IOSDialog iosDialog) {
  23. Toast.makeText(context, "Cancelled", Toast.LENGTH_SHORT).show();
  24. }
  25. })
  26. .build()
  27. .show();

About Me

Varun John

Sr. Android Developer

varunjohn1990@gmail.com

Skype varun.john1990

Follow me https://github.com/varunjohn for other samples and libraries like these

If you like this library then please add a star :)

License

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