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.
- package/CapacitorExtendedDialog.podspec +17 -0
- package/Package.swift +28 -0
- package/README.md +190 -0
- package/android/build.gradle +59 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/albermonte/extendeddialog/DialogStyleOptions.java +99 -0
- package/android/src/main/java/com/albermonte/extendeddialog/ExtendedDialog.java +734 -0
- package/android/src/main/java/com/albermonte/extendeddialog/ExtendedDialogPlugin.java +207 -0
- package/android/src/main/java/com/albermonte/extendeddialog/FullScreenDialogFragment.java +589 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/android/src/main/res/values/themes.xml +34 -0
- package/dist/docs.json +384 -0
- package/dist/esm/definitions.d.ts +101 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +14 -0
- package/dist/esm/web.js +193 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +207 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +210 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/ExtendedDialogPlugin/ExtendedDialog.swift +497 -0
- package/ios/Sources/ExtendedDialogPlugin/ExtendedDialogPlugin.swift +177 -0
- package/ios/Sources/ExtendedDialogPlugin/FullScreenDialogViewController.swift +506 -0
- package/ios/Tests/ExtendedDialogPluginTests/ExtendedDialogPluginTests.swift +15 -0
- package/package.json +80 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
package com.albermonte.extendeddialog;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSArray;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import com.getcapacitor.Plugin;
|
|
6
|
+
import com.getcapacitor.PluginCall;
|
|
7
|
+
import com.getcapacitor.PluginMethod;
|
|
8
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
9
|
+
import org.json.JSONArray;
|
|
10
|
+
import org.json.JSONException;
|
|
11
|
+
|
|
12
|
+
@CapacitorPlugin(name = "ExtendedDialog")
|
|
13
|
+
public class ExtendedDialogPlugin extends Plugin {
|
|
14
|
+
|
|
15
|
+
private final ExtendedDialog implementation = new ExtendedDialog();
|
|
16
|
+
|
|
17
|
+
private DialogStyleOptions extractStyleOptions(PluginCall call) {
|
|
18
|
+
DialogStyleOptions styleOptions = new DialogStyleOptions();
|
|
19
|
+
styleOptions.setButtonColor(call.getString("buttonColor"));
|
|
20
|
+
styleOptions.setCancelButtonColor(call.getString("cancelButtonColor"));
|
|
21
|
+
styleOptions.setTitleColor(call.getString("titleColor"));
|
|
22
|
+
styleOptions.setMessageColor(call.getString("messageColor"));
|
|
23
|
+
styleOptions.setBackgroundColor(call.getString("backgroundColor"));
|
|
24
|
+
styleOptions.setTitleFontSize(call.getDouble("titleFontSize"));
|
|
25
|
+
styleOptions.setMessageFontSize(call.getDouble("messageFontSize"));
|
|
26
|
+
styleOptions.setButtonFontSize(call.getDouble("buttonFontSize"));
|
|
27
|
+
return styleOptions;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@PluginMethod
|
|
31
|
+
public void alert(PluginCall call) {
|
|
32
|
+
String title = call.getString("title");
|
|
33
|
+
String message = call.getString("message");
|
|
34
|
+
String buttonTitle = call.getString("buttonTitle");
|
|
35
|
+
String mode = call.getString("mode", "basic");
|
|
36
|
+
boolean fullscreen = "fullscreen".equals(mode);
|
|
37
|
+
DialogStyleOptions styleOptions = extractStyleOptions(call);
|
|
38
|
+
|
|
39
|
+
if (message == null) {
|
|
40
|
+
call.reject("message is required");
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
implementation.showAlert(getActivity(), title, message, buttonTitle, fullscreen, styleOptions, () -> call.resolve());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@PluginMethod
|
|
48
|
+
public void confirm(PluginCall call) {
|
|
49
|
+
String title = call.getString("title");
|
|
50
|
+
String message = call.getString("message");
|
|
51
|
+
String okButtonTitle = call.getString("okButtonTitle");
|
|
52
|
+
String cancelButtonTitle = call.getString("cancelButtonTitle");
|
|
53
|
+
String mode = call.getString("mode", "basic");
|
|
54
|
+
boolean fullscreen = "fullscreen".equals(mode);
|
|
55
|
+
DialogStyleOptions styleOptions = extractStyleOptions(call);
|
|
56
|
+
|
|
57
|
+
if (message == null) {
|
|
58
|
+
call.reject("message is required");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
implementation.showConfirm(getActivity(), title, message, okButtonTitle, cancelButtonTitle, fullscreen, styleOptions, (value) -> {
|
|
63
|
+
JSObject result = new JSObject();
|
|
64
|
+
result.put("value", value);
|
|
65
|
+
call.resolve(result);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@PluginMethod
|
|
70
|
+
public void prompt(PluginCall call) {
|
|
71
|
+
String title = call.getString("title");
|
|
72
|
+
String message = call.getString("message");
|
|
73
|
+
String okButtonTitle = call.getString("okButtonTitle");
|
|
74
|
+
String cancelButtonTitle = call.getString("cancelButtonTitle");
|
|
75
|
+
String inputPlaceholder = call.getString("inputPlaceholder");
|
|
76
|
+
String inputText = call.getString("inputText");
|
|
77
|
+
String mode = call.getString("mode", "basic");
|
|
78
|
+
boolean fullscreen = "fullscreen".equals(mode);
|
|
79
|
+
boolean focusInput = call.getBoolean("focusInput", false);
|
|
80
|
+
DialogStyleOptions styleOptions = extractStyleOptions(call);
|
|
81
|
+
|
|
82
|
+
if (message == null) {
|
|
83
|
+
call.reject("message is required");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
implementation.showPrompt(
|
|
88
|
+
getActivity(),
|
|
89
|
+
title,
|
|
90
|
+
message,
|
|
91
|
+
okButtonTitle,
|
|
92
|
+
cancelButtonTitle,
|
|
93
|
+
inputPlaceholder,
|
|
94
|
+
inputText,
|
|
95
|
+
fullscreen,
|
|
96
|
+
focusInput,
|
|
97
|
+
styleOptions,
|
|
98
|
+
(value, cancelled) -> {
|
|
99
|
+
JSObject result = new JSObject();
|
|
100
|
+
result.put("value", value != null ? value : "");
|
|
101
|
+
result.put("cancelled", cancelled);
|
|
102
|
+
call.resolve(result);
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@PluginMethod
|
|
108
|
+
public void singleSelect(PluginCall call) {
|
|
109
|
+
String title = call.getString("title");
|
|
110
|
+
String message = call.getString("message");
|
|
111
|
+
JSArray optionsArray = call.getArray("options");
|
|
112
|
+
String selectedValue = call.getString("selectedValue");
|
|
113
|
+
String okButtonTitle = call.getString("okButtonTitle");
|
|
114
|
+
String cancelButtonTitle = call.getString("cancelButtonTitle");
|
|
115
|
+
String mode = call.getString("mode", "basic");
|
|
116
|
+
boolean fullscreen = "fullscreen".equals(mode);
|
|
117
|
+
DialogStyleOptions styleOptions = extractStyleOptions(call);
|
|
118
|
+
|
|
119
|
+
if (message == null) {
|
|
120
|
+
call.reject("message is required");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (optionsArray == null) {
|
|
125
|
+
call.reject("options is required");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
try {
|
|
130
|
+
JSONArray options = new JSONArray(optionsArray.toString());
|
|
131
|
+
|
|
132
|
+
implementation.showSingleSelect(
|
|
133
|
+
getActivity(),
|
|
134
|
+
title,
|
|
135
|
+
message,
|
|
136
|
+
options,
|
|
137
|
+
selectedValue,
|
|
138
|
+
okButtonTitle,
|
|
139
|
+
cancelButtonTitle,
|
|
140
|
+
fullscreen,
|
|
141
|
+
styleOptions,
|
|
142
|
+
(value, cancelled) -> {
|
|
143
|
+
JSObject result = new JSObject();
|
|
144
|
+
result.put("value", value);
|
|
145
|
+
result.put("cancelled", cancelled);
|
|
146
|
+
call.resolve(result);
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
} catch (JSONException e) {
|
|
150
|
+
call.reject("Invalid options format");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@PluginMethod
|
|
155
|
+
public void multiSelect(PluginCall call) {
|
|
156
|
+
String title = call.getString("title");
|
|
157
|
+
String message = call.getString("message");
|
|
158
|
+
JSArray optionsArray = call.getArray("options");
|
|
159
|
+
JSArray selectedValuesArray = call.getArray("selectedValues");
|
|
160
|
+
String okButtonTitle = call.getString("okButtonTitle");
|
|
161
|
+
String cancelButtonTitle = call.getString("cancelButtonTitle");
|
|
162
|
+
String mode = call.getString("mode", "basic");
|
|
163
|
+
boolean fullscreen = "fullscreen".equals(mode);
|
|
164
|
+
DialogStyleOptions styleOptions = extractStyleOptions(call);
|
|
165
|
+
|
|
166
|
+
if (message == null) {
|
|
167
|
+
call.reject("message is required");
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (optionsArray == null) {
|
|
172
|
+
call.reject("options is required");
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
try {
|
|
177
|
+
JSONArray options = new JSONArray(optionsArray.toString());
|
|
178
|
+
JSONArray selectedValues = selectedValuesArray != null ? new JSONArray(selectedValuesArray.toString()) : null;
|
|
179
|
+
|
|
180
|
+
implementation.showMultiSelect(
|
|
181
|
+
getActivity(),
|
|
182
|
+
title,
|
|
183
|
+
message,
|
|
184
|
+
options,
|
|
185
|
+
selectedValues,
|
|
186
|
+
okButtonTitle,
|
|
187
|
+
cancelButtonTitle,
|
|
188
|
+
fullscreen,
|
|
189
|
+
styleOptions,
|
|
190
|
+
(values, cancelled) -> {
|
|
191
|
+
JSObject result = new JSObject();
|
|
192
|
+
JSArray valuesResult = new JSArray();
|
|
193
|
+
if (values != null) {
|
|
194
|
+
for (String value : values) {
|
|
195
|
+
valuesResult.put(value);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
result.put("values", valuesResult);
|
|
199
|
+
result.put("cancelled", cancelled);
|
|
200
|
+
call.resolve(result);
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
} catch (JSONException e) {
|
|
204
|
+
call.reject("Invalid options format");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|