├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── example │ │ └── cupertinodialogdemo │ │ └── MainActivity.kt │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ ├── btn_round_8dp.xml │ ├── ic_launcher.png │ └── ic_launcher_background.xml │ ├── layout │ └── activity_main.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── cupertinodialog ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── hanter │ │ └── android │ │ └── radwidget │ │ └── cupertino │ │ ├── ActionDividerDecoration.java │ │ ├── CupertinoActionSheetAction.java │ │ ├── CupertinoActionSheetDialog.java │ │ ├── CupertinoAlertDialog.java │ │ ├── CupertinoAlertDialogAction.java │ │ ├── CupertinoColors.java │ │ ├── CupertinoDialogActionButton.java │ │ └── blur │ │ ├── BlockingBlurController.java │ │ ├── BlurAlgorithm.java │ │ ├── BlurController.java │ │ ├── BlurView.java │ │ ├── BlurViewFacade.java │ │ ├── NoOpBlurAlgorithm.java │ │ ├── NoOpController.java │ │ └── RenderScriptBlur.java │ ├── res │ ├── anim │ │ ├── action_sheet_slide_in.xml │ │ └── action_sheet_slide_out.xml │ ├── drawable │ │ ├── bg_item_action_sheet.xml │ │ ├── btn_action_sheet_cancel.xml │ │ └── btn_cupertino_alert.xml │ ├── layout │ │ ├── cupertino_alert_button.xml │ │ ├── dialog_action_sheet.xml │ │ ├── dialog_cupertino_alert.xml │ │ └── item_action_sheet.xml │ ├── values-v19 │ │ └── styles.xml │ ├── values-v21 │ │ └── styles.xml │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── rs │ └── BlendEx.rs ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshots └── screenshots.jpg └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Cupertino Dialog 2 | 3 | IOS Style Dialog: AlertDialog, ActionSheetDialog 4 | 5 | ## 效果 6 | 7 | ![CupertinoDialogGallery](/screenshots/screenshots.jpg) 8 | 9 | ## 使用方法 10 | 11 | ### 添加依赖 12 | 13 | 添加仓库到根build.gradle文件及库依赖 14 | ``` gradle 15 | allprojects { 16 | repositories { 17 | ... 18 | maven { url 'https://jitpack.io' } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation 'com.github.wangmingshuo:CupertinoDialog:1.0.1' 24 | } 25 | ``` 26 | ### 使用 27 | 28 | - 使用CupertinoAlertDialog(kotlin) 29 | 30 | ``` kotlin 31 | val actions = ArrayList() 32 | actions.add("test1") 33 | actions.add("test2") 34 | actions.add("test3") 35 | 36 | CupertinoAlertDialog.newInstance("title", "message", actions) 37 | .show(supportFragmentManager, "alert") 38 | ``` 39 | 40 | - 使用CupertinoActionSheetDialog(kotlin) 41 | 42 | ``` kotlin 43 | val actions = ArrayList() 44 | actions.add(CupertinoActionSheetAction.create("test1")) 45 | actions.add(CupertinoActionSheetAction.create("test2")) 46 | actions.add(CupertinoActionSheetAction.create("test3")) 47 | 48 | val cancelAction = CupertinoActionSheetAction("取消") 49 | cancelAction.isDefaultAction = true 50 | 51 | CupertinoActionSheetDialog.newInstance("title", "message", actions, cancelAction) 52 | .show(supportFragmentManager, "sheet") 53 | }); 54 | ``` 55 | ## Thanks 56 | 57 | [BlurView](https://github.com/Dimezis/BlurView) 58 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 29 9 | buildToolsVersion "29.0.2" 10 | defaultConfig { 11 | applicationId "com.example.cupertinodialogdemo" 12 | minSdkVersion 17 13 | targetSdkVersion 29 14 | versionCode 1 15 | versionName "1.0" 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | } 25 | 26 | dependencies { 27 | implementation fileTree(dir: 'libs', include: ['*.jar']) 28 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 29 | implementation 'androidx.appcompat:appcompat:1.1.0' 30 | implementation 'com.google.android.material:material:1.1.0' 31 | implementation 'androidx.core:core-ktx:1.1.0' 32 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 33 | testImplementation 'junit:junit:4.12' 34 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 35 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 36 | implementation 'androidx.recyclerview:recyclerview:1.0.0' 37 | implementation project(path: ':cupertinodialog') 38 | // implementation 'com.github.wangmingshuo:CupertinoDialog:1.0.0' 39 | } 40 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/cupertinodialogdemo/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.cupertinodialogdemo 2 | 3 | import android.os.Bundle 4 | import android.view.View 5 | import androidx.appcompat.app.AppCompatActivity 6 | import com.hanter.android.radwidget.cupertino.CupertinoActionSheetAction 7 | import com.hanter.android.radwidget.cupertino.CupertinoActionSheetDialog 8 | import com.hanter.android.radwidget.cupertino.CupertinoAlertDialog 9 | import com.hanter.android.radwidget.cupertino.CupertinoAlertDialogAction 10 | import java.util.* 11 | 12 | 13 | class MainActivity : AppCompatActivity(), View.OnClickListener, CupertinoAlertDialog.OnActionClickListener, 14 | CupertinoActionSheetDialog.OnActionClickListener { 15 | 16 | override fun onCreate(savedInstanceState: Bundle?) { 17 | super.onCreate(savedInstanceState) 18 | setContentView(R.layout.activity_main) 19 | } 20 | 21 | override fun onClick(v: View?) { 22 | when (v?.id) { 23 | R.id.btnAlert -> { 24 | val actions = ArrayList() 25 | actions.add(CupertinoAlertDialogAction("Delete", false, true)) 26 | actions.add(CupertinoAlertDialogAction("Cancel", false, false)) 27 | 28 | CupertinoAlertDialog.newInstance("Delete file?", "", actions) 29 | .show(supportFragmentManager, "TEST") 30 | } 31 | 32 | R.id.btnAlertWithTitle -> { 33 | val actions = ArrayList() 34 | actions.add("Don\'t Allow") 35 | actions.add("Allow") 36 | 37 | CupertinoAlertDialog.newInstance("Allow \"Maps\" to access your location while you are using the app?", 38 | "Your current location will be displayed on the map and used for directions, nearby search results, and estimated travel times.", 39 | actions) 40 | .show(supportFragmentManager, "TEST") 41 | } 42 | 43 | R.id.btnAlertWithButton -> { 44 | val actions = ArrayList() 45 | actions.add("test1") 46 | actions.add("test2") 47 | actions.add("test3") 48 | actions.add("test4") 49 | 50 | CupertinoAlertDialog.newInstance("title", "message", actions) 51 | .show(supportFragmentManager, "TEST") 52 | } 53 | 54 | R.id.btnAlertButtonOnly -> { 55 | val actions = ArrayList() 56 | actions.add("test1") 57 | actions.add("test2") 58 | actions.add("test3") 59 | actions.add("test4") 60 | 61 | CupertinoAlertDialog.newInstance("", "", actions) 62 | .show(supportFragmentManager, "TEST") 63 | } 64 | 65 | R.id.btnActionSheet -> { 66 | val actions = ArrayList() 67 | actions.add(CupertinoActionSheetAction.create("test1")) 68 | actions.add(CupertinoActionSheetAction.create("test2")) 69 | actions.add(CupertinoActionSheetAction.create("test3")) 70 | 71 | val cancelAction = CupertinoActionSheetAction("取消") 72 | cancelAction.isDefaultAction = true 73 | 74 | CupertinoActionSheetDialog.newInstance("title", "message", actions, cancelAction) 75 | .show(supportFragmentManager, "TEST") 76 | } 77 | } 78 | } 79 | 80 | override fun onActionClick(dialog: CupertinoAlertDialog?, position: Int) { 81 | dialog?.dismiss() 82 | } 83 | 84 | override fun onActionClick(dialog: CupertinoActionSheetDialog?, position: Int) { 85 | dialog?.dismiss() 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_round_8dp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/classops/CupertinoDialog/f755eb85520436030ae12ee474939c4ef2e70b3b/app/src/main/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 |