capacitor-extended-dialog 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CapacitorExtendedDialog.podspec +17 -0
  2. package/Package.swift +28 -0
  3. package/README.md +190 -0
  4. package/android/build.gradle +59 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/com/albermonte/extendeddialog/DialogStyleOptions.java +99 -0
  7. package/android/src/main/java/com/albermonte/extendeddialog/ExtendedDialog.java +734 -0
  8. package/android/src/main/java/com/albermonte/extendeddialog/ExtendedDialogPlugin.java +207 -0
  9. package/android/src/main/java/com/albermonte/extendeddialog/FullScreenDialogFragment.java +589 -0
  10. package/android/src/main/res/.gitkeep +0 -0
  11. package/android/src/main/res/values/themes.xml +34 -0
  12. package/dist/docs.json +384 -0
  13. package/dist/esm/definitions.d.ts +101 -0
  14. package/dist/esm/definitions.js +2 -0
  15. package/dist/esm/definitions.js.map +1 -0
  16. package/dist/esm/index.d.ts +4 -0
  17. package/dist/esm/index.js +7 -0
  18. package/dist/esm/index.js.map +1 -0
  19. package/dist/esm/web.d.ts +14 -0
  20. package/dist/esm/web.js +193 -0
  21. package/dist/esm/web.js.map +1 -0
  22. package/dist/plugin.cjs.js +207 -0
  23. package/dist/plugin.cjs.js.map +1 -0
  24. package/dist/plugin.js +210 -0
  25. package/dist/plugin.js.map +1 -0
  26. package/ios/Sources/ExtendedDialogPlugin/ExtendedDialog.swift +497 -0
  27. package/ios/Sources/ExtendedDialogPlugin/ExtendedDialogPlugin.swift +177 -0
  28. package/ios/Sources/ExtendedDialogPlugin/FullScreenDialogViewController.swift +506 -0
  29. package/ios/Tests/ExtendedDialogPluginTests/ExtendedDialogPluginTests.swift +15 -0
  30. package/package.json +80 -0
@@ -0,0 +1,17 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'CapacitorExtendedDialog'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '14.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
package/Package.swift ADDED
@@ -0,0 +1,28 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "CapacitorExtendedDialog",
6
+ platforms: [.iOS(.v15)],
7
+ products: [
8
+ .library(
9
+ name: "CapacitorExtendedDialog",
10
+ targets: ["ExtendedDialogPlugin"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "ExtendedDialogPlugin",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ ],
22
+ path: "ios/Sources/ExtendedDialogPlugin"),
23
+ .testTarget(
24
+ name: "ExtendedDialogPluginTests",
25
+ dependencies: ["ExtendedDialogPlugin"],
26
+ path: "ios/Tests/ExtendedDialogPluginTests")
27
+ ]
28
+ )
package/README.md ADDED
@@ -0,0 +1,190 @@
1
+ # capacitor-extended-dialog
2
+
3
+ Show native dialogs in Capacitor with Material 3 and Liquid Glass UI
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install capacitor-extended-dialog
9
+ npx cap sync
10
+ ```
11
+
12
+ ## API
13
+
14
+ <docgen-index>
15
+
16
+ * [`alert(...)`](#alert)
17
+ * [`confirm(...)`](#confirm)
18
+ * [`prompt(...)`](#prompt)
19
+ * [`singleSelect(...)`](#singleselect)
20
+ * [`multiSelect(...)`](#multiselect)
21
+ * [Interfaces](#interfaces)
22
+
23
+ </docgen-index>
24
+
25
+ <docgen-api>
26
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
27
+
28
+ ### alert(...)
29
+
30
+ ```typescript
31
+ alert(options: AlertOptions) => any
32
+ ```
33
+
34
+ | Param | Type |
35
+ | ------------- | ----------------------------------------------------- |
36
+ | **`options`** | <code><a href="#alertoptions">AlertOptions</a></code> |
37
+
38
+ **Returns:** <code>any</code>
39
+
40
+ --------------------
41
+
42
+
43
+ ### confirm(...)
44
+
45
+ ```typescript
46
+ confirm(options: ConfirmOptions) => any
47
+ ```
48
+
49
+ | Param | Type |
50
+ | ------------- | --------------------------------------------------------- |
51
+ | **`options`** | <code><a href="#confirmoptions">ConfirmOptions</a></code> |
52
+
53
+ **Returns:** <code>any</code>
54
+
55
+ --------------------
56
+
57
+
58
+ ### prompt(...)
59
+
60
+ ```typescript
61
+ prompt(options: PromptOptions) => any
62
+ ```
63
+
64
+ | Param | Type |
65
+ | ------------- | ------------------------------------------------------- |
66
+ | **`options`** | <code><a href="#promptoptions">PromptOptions</a></code> |
67
+
68
+ **Returns:** <code>any</code>
69
+
70
+ --------------------
71
+
72
+
73
+ ### singleSelect(...)
74
+
75
+ ```typescript
76
+ singleSelect(options: SingleSelectOptions) => any
77
+ ```
78
+
79
+ | Param | Type |
80
+ | ------------- | ------------------------------------------------------------------- |
81
+ | **`options`** | <code><a href="#singleselectoptions">SingleSelectOptions</a></code> |
82
+
83
+ **Returns:** <code>any</code>
84
+
85
+ --------------------
86
+
87
+
88
+ ### multiSelect(...)
89
+
90
+ ```typescript
91
+ multiSelect(options: MultiSelectOptions) => any
92
+ ```
93
+
94
+ | Param | Type |
95
+ | ------------- | ----------------------------------------------------------------- |
96
+ | **`options`** | <code><a href="#multiselectoptions">MultiSelectOptions</a></code> |
97
+
98
+ **Returns:** <code>any</code>
99
+
100
+ --------------------
101
+
102
+
103
+ ### Interfaces
104
+
105
+
106
+ #### AlertOptions
107
+
108
+ | Prop | Type |
109
+ | ----------------- | ------------------- |
110
+ | **`buttonTitle`** | <code>string</code> |
111
+
112
+
113
+ #### ConfirmOptions
114
+
115
+ | Prop | Type |
116
+ | ----------------------- | ------------------- |
117
+ | **`okButtonTitle`** | <code>string</code> |
118
+ | **`cancelButtonTitle`** | <code>string</code> |
119
+
120
+
121
+ #### ConfirmResult
122
+
123
+ | Prop | Type |
124
+ | ----------- | -------------------- |
125
+ | **`value`** | <code>boolean</code> |
126
+
127
+
128
+ #### PromptOptions
129
+
130
+ | Prop | Type | Description | Default |
131
+ | ----------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
132
+ | **`okButtonTitle`** | <code>string</code> | | |
133
+ | **`cancelButtonTitle`** | <code>string</code> | | |
134
+ | **`inputPlaceholder`** | <code>string</code> | | |
135
+ | **`inputText`** | <code>string</code> | | |
136
+ | **`focusInput`** | <code>boolean</code> | Whether to automatically focus the input field and open the keyboard when the dialog appears. Note: On iOS, basic (non-fullscreen) dialogs always auto-focus the input field due to UIAlertController's built-in behavior. This option only takes effect on iOS when using fullscreen mode (`mode: 'fullscreen'`). On Android and web, this works for all modes. | <code>false</code> |
137
+
138
+
139
+ #### PromptResult
140
+
141
+ | Prop | Type |
142
+ | --------------- | -------------------- |
143
+ | **`value`** | <code>string</code> |
144
+ | **`cancelled`** | <code>boolean</code> |
145
+
146
+
147
+ #### SingleSelectOptions
148
+
149
+ | Prop | Type |
150
+ | ----------------------- | ------------------- |
151
+ | **`options`** | <code>{}</code> |
152
+ | **`selectedValue`** | <code>string</code> |
153
+ | **`okButtonTitle`** | <code>string</code> |
154
+ | **`cancelButtonTitle`** | <code>string</code> |
155
+
156
+
157
+ #### SelectOption
158
+
159
+ | Prop | Type |
160
+ | ----------- | ------------------- |
161
+ | **`label`** | <code>string</code> |
162
+ | **`value`** | <code>string</code> |
163
+
164
+
165
+ #### SingleSelectResult
166
+
167
+ | Prop | Type |
168
+ | --------------- | --------------------------- |
169
+ | **`value`** | <code>string \| null</code> |
170
+ | **`cancelled`** | <code>boolean</code> |
171
+
172
+
173
+ #### MultiSelectOptions
174
+
175
+ | Prop | Type |
176
+ | ----------------------- | ------------------- |
177
+ | **`options`** | <code>{}</code> |
178
+ | **`selectedValues`** | <code>{}</code> |
179
+ | **`okButtonTitle`** | <code>string</code> |
180
+ | **`cancelButtonTitle`** | <code>string</code> |
181
+
182
+
183
+ #### MultiSelectResult
184
+
185
+ | Prop | Type |
186
+ | --------------- | -------------------- |
187
+ | **`values`** | <code>{}</code> |
188
+ | **`cancelled`** | <code>boolean</code> |
189
+
190
+ </docgen-api>
@@ -0,0 +1,59 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.7.2'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ namespace "com.albermonte.extendeddialog"
22
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
23
+ defaultConfig {
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
26
+ versionCode 1
27
+ versionName "1.0"
28
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29
+ }
30
+ buildTypes {
31
+ release {
32
+ minifyEnabled false
33
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34
+ }
35
+ }
36
+ lintOptions {
37
+ abortOnError false
38
+ }
39
+ compileOptions {
40
+ sourceCompatibility JavaVersion.VERSION_21
41
+ targetCompatibility JavaVersion.VERSION_21
42
+ }
43
+ }
44
+
45
+ repositories {
46
+ google()
47
+ mavenCentral()
48
+ }
49
+
50
+
51
+ dependencies {
52
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
53
+ implementation project(':capacitor-android')
54
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
+ implementation 'com.google.android.material:material:1.12.0'
56
+ testImplementation "junit:junit:$junitVersion"
57
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
58
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
59
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,99 @@
1
+ package com.albermonte.extendeddialog;
2
+
3
+ import android.graphics.Color;
4
+ import android.os.Bundle;
5
+
6
+ /**
7
+ * Style options for dialog customization.
8
+ */
9
+ public class DialogStyleOptions {
10
+
11
+ private static final String KEY_BUTTON_COLOR = "buttonColor";
12
+ private static final String KEY_CANCEL_BUTTON_COLOR = "cancelButtonColor";
13
+ private static final String KEY_TITLE_COLOR = "titleColor";
14
+ private static final String KEY_MESSAGE_COLOR = "messageColor";
15
+ private static final String KEY_BACKGROUND_COLOR = "backgroundColor";
16
+ private static final String KEY_TITLE_FONT_SIZE = "titleFontSize";
17
+ private static final String KEY_MESSAGE_FONT_SIZE = "messageFontSize";
18
+ private static final String KEY_BUTTON_FONT_SIZE = "buttonFontSize";
19
+
20
+ private Integer buttonColor;
21
+ private Integer cancelButtonColor;
22
+ private Integer titleColor;
23
+ private Integer messageColor;
24
+ private Integer backgroundColor;
25
+ private Float titleFontSize;
26
+ private Float messageFontSize;
27
+ private Float buttonFontSize;
28
+
29
+ public DialogStyleOptions() {}
30
+
31
+ private static Integer parseColor(String hexColor) {
32
+ if (hexColor == null || hexColor.isEmpty()) {
33
+ return null;
34
+ }
35
+ try {
36
+ return Color.parseColor(hexColor);
37
+ } catch (IllegalArgumentException e) {
38
+ return null;
39
+ }
40
+ }
41
+
42
+ private static Float parseSize(Double size) {
43
+ return (size != null && size > 0) ? size.floatValue() : null;
44
+ }
45
+
46
+ public Integer getButtonColor() { return buttonColor; }
47
+ public void setButtonColor(String hexColor) { this.buttonColor = parseColor(hexColor); }
48
+
49
+ public Integer getCancelButtonColor() { return cancelButtonColor; }
50
+ public void setCancelButtonColor(String hexColor) { this.cancelButtonColor = parseColor(hexColor); }
51
+
52
+ public Integer getTitleColor() { return titleColor; }
53
+ public void setTitleColor(String hexColor) { this.titleColor = parseColor(hexColor); }
54
+
55
+ public Integer getMessageColor() { return messageColor; }
56
+ public void setMessageColor(String hexColor) { this.messageColor = parseColor(hexColor); }
57
+
58
+ public Integer getBackgroundColor() { return backgroundColor; }
59
+ public void setBackgroundColor(String hexColor) { this.backgroundColor = parseColor(hexColor); }
60
+
61
+ public Float getTitleFontSize() { return titleFontSize; }
62
+ public void setTitleFontSize(Double size) { this.titleFontSize = parseSize(size); }
63
+
64
+ public Float getMessageFontSize() { return messageFontSize; }
65
+ public void setMessageFontSize(Double size) { this.messageFontSize = parseSize(size); }
66
+
67
+ public Float getButtonFontSize() { return buttonFontSize; }
68
+ public void setButtonFontSize(Double size) { this.buttonFontSize = parseSize(size); }
69
+
70
+ public boolean hasStyles() {
71
+ return buttonColor != null || cancelButtonColor != null || titleColor != null ||
72
+ messageColor != null || backgroundColor != null || titleFontSize != null ||
73
+ messageFontSize != null || buttonFontSize != null;
74
+ }
75
+
76
+ public void writeToBundle(Bundle bundle) {
77
+ if (buttonColor != null) bundle.putInt(KEY_BUTTON_COLOR, buttonColor);
78
+ if (cancelButtonColor != null) bundle.putInt(KEY_CANCEL_BUTTON_COLOR, cancelButtonColor);
79
+ if (titleColor != null) bundle.putInt(KEY_TITLE_COLOR, titleColor);
80
+ if (messageColor != null) bundle.putInt(KEY_MESSAGE_COLOR, messageColor);
81
+ if (backgroundColor != null) bundle.putInt(KEY_BACKGROUND_COLOR, backgroundColor);
82
+ if (titleFontSize != null) bundle.putFloat(KEY_TITLE_FONT_SIZE, titleFontSize);
83
+ if (messageFontSize != null) bundle.putFloat(KEY_MESSAGE_FONT_SIZE, messageFontSize);
84
+ if (buttonFontSize != null) bundle.putFloat(KEY_BUTTON_FONT_SIZE, buttonFontSize);
85
+ }
86
+
87
+ public static DialogStyleOptions readFromBundle(Bundle bundle) {
88
+ DialogStyleOptions options = new DialogStyleOptions();
89
+ options.buttonColor = bundle.containsKey(KEY_BUTTON_COLOR) ? bundle.getInt(KEY_BUTTON_COLOR) : null;
90
+ options.cancelButtonColor = bundle.containsKey(KEY_CANCEL_BUTTON_COLOR) ? bundle.getInt(KEY_CANCEL_BUTTON_COLOR) : null;
91
+ options.titleColor = bundle.containsKey(KEY_TITLE_COLOR) ? bundle.getInt(KEY_TITLE_COLOR) : null;
92
+ options.messageColor = bundle.containsKey(KEY_MESSAGE_COLOR) ? bundle.getInt(KEY_MESSAGE_COLOR) : null;
93
+ options.backgroundColor = bundle.containsKey(KEY_BACKGROUND_COLOR) ? bundle.getInt(KEY_BACKGROUND_COLOR) : null;
94
+ options.titleFontSize = bundle.containsKey(KEY_TITLE_FONT_SIZE) ? bundle.getFloat(KEY_TITLE_FONT_SIZE) : null;
95
+ options.messageFontSize = bundle.containsKey(KEY_MESSAGE_FONT_SIZE) ? bundle.getFloat(KEY_MESSAGE_FONT_SIZE) : null;
96
+ options.buttonFontSize = bundle.containsKey(KEY_BUTTON_FONT_SIZE) ? bundle.getFloat(KEY_BUTTON_FONT_SIZE) : null;
97
+ return options;
98
+ }
99
+ }