@capawesome/capacitor-action-sheet 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/CapawesomeCapacitorActionSheet.podspec +17 -0
- package/LICENSE +21 -0
- package/Package.swift +28 -0
- package/README.md +185 -0
- package/android/build.gradle +60 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/actionsheet/ActionSheet.java +144 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/actionsheet/ActionSheetPlugin.java +71 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/actionsheet/classes/CustomException.java +20 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/actionsheet/classes/CustomExceptions.java +8 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/actionsheet/classes/options/ActionSheetButton.java +45 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/actionsheet/classes/options/ShowActionsOptions.java +62 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/actionsheet/classes/results/ShowActionsResult.java +25 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/actionsheet/interfaces/Callback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/actionsheet/interfaces/NonEmptyResultCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/actionsheet/interfaces/Result.java +7 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +258 -0
- package/dist/esm/definitions.d.ts +116 -0
- package/dist/esm/definitions.js +29 -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 +5 -0
- package/dist/esm/web.js +7 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +50 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +53 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/ActionSheet.swift +59 -0
- package/ios/Plugin/ActionSheetPlugin.swift +47 -0
- package/ios/Plugin/Classes/Options/ActionSheetButton.swift +19 -0
- package/ios/Plugin/Classes/Options/ShowActionsOptions.swift +23 -0
- package/ios/Plugin/Classes/Results/ShowActionsResult.swift +19 -0
- package/ios/Plugin/Enums/CustomError.swift +31 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Protocols/Result.swift +5 -0
- package/package.json +94 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.actionsheet.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.actionsheet.interfaces.Result;
|
|
6
|
+
|
|
7
|
+
public class ShowActionsResult implements Result {
|
|
8
|
+
|
|
9
|
+
private final boolean canceled;
|
|
10
|
+
private final int index;
|
|
11
|
+
|
|
12
|
+
public ShowActionsResult(int index, boolean canceled) {
|
|
13
|
+
this.index = index;
|
|
14
|
+
this.canceled = canceled;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Override
|
|
18
|
+
@NonNull
|
|
19
|
+
public JSObject toJSObject() {
|
|
20
|
+
JSObject result = new JSObject();
|
|
21
|
+
result.put("canceled", canceled);
|
|
22
|
+
result.put("index", index);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "ActionSheetPlugin",
|
|
4
|
+
"slug": "actionsheetplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "showActions",
|
|
10
|
+
"signature": "(options: ShowActionsOptions) => Promise<ShowActionsResult>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "ShowActionsOptions"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<ShowActionsResult>",
|
|
19
|
+
"tags": [
|
|
20
|
+
{
|
|
21
|
+
"name": "since",
|
|
22
|
+
"text": "0.1.0"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"docs": "Show an action sheet with a list of buttons.\n\nOnly available on Android and iOS.",
|
|
26
|
+
"complexTypes": [
|
|
27
|
+
"ShowActionsResult",
|
|
28
|
+
"ShowActionsOptions"
|
|
29
|
+
],
|
|
30
|
+
"slug": "showactions"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"properties": []
|
|
34
|
+
},
|
|
35
|
+
"interfaces": [
|
|
36
|
+
{
|
|
37
|
+
"name": "ShowActionsResult",
|
|
38
|
+
"slug": "showactionsresult",
|
|
39
|
+
"docs": "",
|
|
40
|
+
"tags": [
|
|
41
|
+
{
|
|
42
|
+
"text": "0.1.0",
|
|
43
|
+
"name": "since"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"methods": [],
|
|
47
|
+
"properties": [
|
|
48
|
+
{
|
|
49
|
+
"name": "canceled",
|
|
50
|
+
"tags": [
|
|
51
|
+
{
|
|
52
|
+
"text": "0.1.0",
|
|
53
|
+
"name": "since"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"text": "false",
|
|
57
|
+
"name": "example"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"docs": "Whether the action sheet was canceled by selecting a cancel button or by\ndismissing the action sheet.",
|
|
61
|
+
"complexTypes": [],
|
|
62
|
+
"type": "boolean"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "index",
|
|
66
|
+
"tags": [
|
|
67
|
+
{
|
|
68
|
+
"text": "0.1.0",
|
|
69
|
+
"name": "since"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"text": "0",
|
|
73
|
+
"name": "example"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"docs": "The index of the selected button in the `options` array (zero-based).\n\nIf the action sheet was canceled without a cancel button, the index is `-1`.",
|
|
77
|
+
"complexTypes": [],
|
|
78
|
+
"type": "number"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "ShowActionsOptions",
|
|
84
|
+
"slug": "showactionsoptions",
|
|
85
|
+
"docs": "",
|
|
86
|
+
"tags": [
|
|
87
|
+
{
|
|
88
|
+
"text": "0.1.0",
|
|
89
|
+
"name": "since"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"methods": [],
|
|
93
|
+
"properties": [
|
|
94
|
+
{
|
|
95
|
+
"name": "cancelable",
|
|
96
|
+
"tags": [
|
|
97
|
+
{
|
|
98
|
+
"text": "0.1.0",
|
|
99
|
+
"name": "since"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"text": "true",
|
|
103
|
+
"name": "default"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"text": "true",
|
|
107
|
+
"name": "example"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"docs": "Whether the action sheet can be dismissed by tapping outside of it or\npressing the back button (Android).\n\nOn iOS, the action sheet can always be dismissed by tapping outside of it\n(a system behavior).",
|
|
111
|
+
"complexTypes": [],
|
|
112
|
+
"type": "boolean | undefined"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "message",
|
|
116
|
+
"tags": [
|
|
117
|
+
{
|
|
118
|
+
"text": "0.1.0",
|
|
119
|
+
"name": "since"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"text": "'This action cannot be undone.'",
|
|
123
|
+
"name": "example"
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
"docs": "The message to display below the title.",
|
|
127
|
+
"complexTypes": [],
|
|
128
|
+
"type": "string | undefined"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "options",
|
|
132
|
+
"tags": [
|
|
133
|
+
{
|
|
134
|
+
"text": "0.1.0",
|
|
135
|
+
"name": "since"
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"docs": "The buttons to display in the action sheet.",
|
|
139
|
+
"complexTypes": [
|
|
140
|
+
"ActionSheetButton"
|
|
141
|
+
],
|
|
142
|
+
"type": "ActionSheetButton[]"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"name": "title",
|
|
146
|
+
"tags": [
|
|
147
|
+
{
|
|
148
|
+
"text": "0.1.0",
|
|
149
|
+
"name": "since"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"text": "'Photo Options'",
|
|
153
|
+
"name": "example"
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"docs": "The title of the action sheet.",
|
|
157
|
+
"complexTypes": [],
|
|
158
|
+
"type": "string | undefined"
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"name": "ActionSheetButton",
|
|
164
|
+
"slug": "actionsheetbutton",
|
|
165
|
+
"docs": "",
|
|
166
|
+
"tags": [
|
|
167
|
+
{
|
|
168
|
+
"text": "0.1.0",
|
|
169
|
+
"name": "since"
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
"methods": [],
|
|
173
|
+
"properties": [
|
|
174
|
+
{
|
|
175
|
+
"name": "style",
|
|
176
|
+
"tags": [
|
|
177
|
+
{
|
|
178
|
+
"text": "0.1.0",
|
|
179
|
+
"name": "since"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"text": "ActionSheetButtonStyle.Default",
|
|
183
|
+
"name": "default"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"text": "ActionSheetButtonStyle.Destructive",
|
|
187
|
+
"name": "example"
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
"docs": "The style of the button.",
|
|
191
|
+
"complexTypes": [
|
|
192
|
+
"ActionSheetButtonStyle"
|
|
193
|
+
],
|
|
194
|
+
"type": "ActionSheetButtonStyle"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"name": "title",
|
|
198
|
+
"tags": [
|
|
199
|
+
{
|
|
200
|
+
"text": "0.1.0",
|
|
201
|
+
"name": "since"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"text": "'Delete'",
|
|
205
|
+
"name": "example"
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
"docs": "The title of the button.",
|
|
209
|
+
"complexTypes": [],
|
|
210
|
+
"type": "string"
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
"enums": [
|
|
216
|
+
{
|
|
217
|
+
"name": "ActionSheetButtonStyle",
|
|
218
|
+
"slug": "actionsheetbuttonstyle",
|
|
219
|
+
"members": [
|
|
220
|
+
{
|
|
221
|
+
"name": "Cancel",
|
|
222
|
+
"value": "'CANCEL'",
|
|
223
|
+
"tags": [
|
|
224
|
+
{
|
|
225
|
+
"text": "0.1.0",
|
|
226
|
+
"name": "since"
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
"docs": "A button that cancels the action sheet.\n\nIt should be the last button in the `options` array."
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": "Default",
|
|
233
|
+
"value": "'DEFAULT'",
|
|
234
|
+
"tags": [
|
|
235
|
+
{
|
|
236
|
+
"text": "0.1.0",
|
|
237
|
+
"name": "since"
|
|
238
|
+
}
|
|
239
|
+
],
|
|
240
|
+
"docs": "A button with the default style."
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"name": "Destructive",
|
|
244
|
+
"value": "'DESTRUCTIVE'",
|
|
245
|
+
"tags": [
|
|
246
|
+
{
|
|
247
|
+
"text": "0.1.0",
|
|
248
|
+
"name": "since"
|
|
249
|
+
}
|
|
250
|
+
],
|
|
251
|
+
"docs": "A button that indicates a destructive action."
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
],
|
|
256
|
+
"typeAliases": [],
|
|
257
|
+
"pluginConfigs": []
|
|
258
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export interface ActionSheetPlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Show an action sheet with a list of buttons.
|
|
4
|
+
*
|
|
5
|
+
* Only available on Android and iOS.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.1.0
|
|
8
|
+
*/
|
|
9
|
+
showActions(options: ShowActionsOptions): Promise<ShowActionsResult>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @since 0.1.0
|
|
13
|
+
*/
|
|
14
|
+
export interface ShowActionsOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Whether the action sheet can be dismissed by tapping outside of it or
|
|
17
|
+
* pressing the back button (Android).
|
|
18
|
+
*
|
|
19
|
+
* On iOS, the action sheet can always be dismissed by tapping outside of it
|
|
20
|
+
* (a system behavior).
|
|
21
|
+
*
|
|
22
|
+
* @since 0.1.0
|
|
23
|
+
* @default true
|
|
24
|
+
* @example true
|
|
25
|
+
*/
|
|
26
|
+
cancelable?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The message to display below the title.
|
|
29
|
+
*
|
|
30
|
+
* @since 0.1.0
|
|
31
|
+
* @example 'This action cannot be undone.'
|
|
32
|
+
*/
|
|
33
|
+
message?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The buttons to display in the action sheet.
|
|
36
|
+
*
|
|
37
|
+
* @since 0.1.0
|
|
38
|
+
*/
|
|
39
|
+
options: ActionSheetButton[];
|
|
40
|
+
/**
|
|
41
|
+
* The title of the action sheet.
|
|
42
|
+
*
|
|
43
|
+
* @since 0.1.0
|
|
44
|
+
* @example 'Photo Options'
|
|
45
|
+
*/
|
|
46
|
+
title?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @since 0.1.0
|
|
50
|
+
*/
|
|
51
|
+
export interface ActionSheetButton {
|
|
52
|
+
/**
|
|
53
|
+
* The style of the button.
|
|
54
|
+
*
|
|
55
|
+
* @since 0.1.0
|
|
56
|
+
* @default ActionSheetButtonStyle.Default
|
|
57
|
+
* @example ActionSheetButtonStyle.Destructive
|
|
58
|
+
*/
|
|
59
|
+
style?: ActionSheetButtonStyle;
|
|
60
|
+
/**
|
|
61
|
+
* The title of the button.
|
|
62
|
+
*
|
|
63
|
+
* @since 0.1.0
|
|
64
|
+
* @example 'Delete'
|
|
65
|
+
*/
|
|
66
|
+
title: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @since 0.1.0
|
|
70
|
+
*/
|
|
71
|
+
export interface ShowActionsResult {
|
|
72
|
+
/**
|
|
73
|
+
* Whether the action sheet was canceled by selecting a cancel button or by
|
|
74
|
+
* dismissing the action sheet.
|
|
75
|
+
*
|
|
76
|
+
* @since 0.1.0
|
|
77
|
+
* @example false
|
|
78
|
+
*/
|
|
79
|
+
canceled: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The index of the selected button in the `options` array (zero-based).
|
|
82
|
+
*
|
|
83
|
+
* If the action sheet was canceled without a cancel button, the index is `-1`.
|
|
84
|
+
*
|
|
85
|
+
* @since 0.1.0
|
|
86
|
+
* @example 0
|
|
87
|
+
*/
|
|
88
|
+
index: number;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The style of an action sheet button.
|
|
92
|
+
*
|
|
93
|
+
* @since 0.1.0
|
|
94
|
+
*/
|
|
95
|
+
export declare enum ActionSheetButtonStyle {
|
|
96
|
+
/**
|
|
97
|
+
* A button that cancels the action sheet.
|
|
98
|
+
*
|
|
99
|
+
* It should be the last button in the `options` array.
|
|
100
|
+
*
|
|
101
|
+
* @since 0.1.0
|
|
102
|
+
*/
|
|
103
|
+
Cancel = "CANCEL",
|
|
104
|
+
/**
|
|
105
|
+
* A button with the default style.
|
|
106
|
+
*
|
|
107
|
+
* @since 0.1.0
|
|
108
|
+
*/
|
|
109
|
+
Default = "DEFAULT",
|
|
110
|
+
/**
|
|
111
|
+
* A button that indicates a destructive action.
|
|
112
|
+
*
|
|
113
|
+
* @since 0.1.0
|
|
114
|
+
*/
|
|
115
|
+
Destructive = "DESTRUCTIVE"
|
|
116
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The style of an action sheet button.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.1.0
|
|
5
|
+
*/
|
|
6
|
+
export var ActionSheetButtonStyle;
|
|
7
|
+
(function (ActionSheetButtonStyle) {
|
|
8
|
+
/**
|
|
9
|
+
* A button that cancels the action sheet.
|
|
10
|
+
*
|
|
11
|
+
* It should be the last button in the `options` array.
|
|
12
|
+
*
|
|
13
|
+
* @since 0.1.0
|
|
14
|
+
*/
|
|
15
|
+
ActionSheetButtonStyle["Cancel"] = "CANCEL";
|
|
16
|
+
/**
|
|
17
|
+
* A button with the default style.
|
|
18
|
+
*
|
|
19
|
+
* @since 0.1.0
|
|
20
|
+
*/
|
|
21
|
+
ActionSheetButtonStyle["Default"] = "DEFAULT";
|
|
22
|
+
/**
|
|
23
|
+
* A button that indicates a destructive action.
|
|
24
|
+
*
|
|
25
|
+
* @since 0.1.0
|
|
26
|
+
*/
|
|
27
|
+
ActionSheetButtonStyle["Destructive"] = "DESTRUCTIVE";
|
|
28
|
+
})(ActionSheetButtonStyle || (ActionSheetButtonStyle = {}));
|
|
29
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA6FA;;;;GAIG;AACH,MAAM,CAAN,IAAY,sBAqBX;AArBD,WAAY,sBAAsB;IAChC;;;;;;OAMG;IACH,2CAAiB,CAAA;IACjB;;;;OAIG;IACH,6CAAmB,CAAA;IACnB;;;;OAIG;IACH,qDAA2B,CAAA;AAC7B,CAAC,EArBW,sBAAsB,KAAtB,sBAAsB,QAqBjC","sourcesContent":["export interface ActionSheetPlugin {\n /**\n * Show an action sheet with a list of buttons.\n *\n * Only available on Android and iOS.\n *\n * @since 0.1.0\n */\n showActions(options: ShowActionsOptions): Promise<ShowActionsResult>;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface ShowActionsOptions {\n /**\n * Whether the action sheet can be dismissed by tapping outside of it or\n * pressing the back button (Android).\n *\n * On iOS, the action sheet can always be dismissed by tapping outside of it\n * (a system behavior).\n *\n * @since 0.1.0\n * @default true\n * @example true\n */\n cancelable?: boolean;\n /**\n * The message to display below the title.\n *\n * @since 0.1.0\n * @example 'This action cannot be undone.'\n */\n message?: string;\n /**\n * The buttons to display in the action sheet.\n *\n * @since 0.1.0\n */\n options: ActionSheetButton[];\n /**\n * The title of the action sheet.\n *\n * @since 0.1.0\n * @example 'Photo Options'\n */\n title?: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface ActionSheetButton {\n /**\n * The style of the button.\n *\n * @since 0.1.0\n * @default ActionSheetButtonStyle.Default\n * @example ActionSheetButtonStyle.Destructive\n */\n style?: ActionSheetButtonStyle;\n /**\n * The title of the button.\n *\n * @since 0.1.0\n * @example 'Delete'\n */\n title: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface ShowActionsResult {\n /**\n * Whether the action sheet was canceled by selecting a cancel button or by\n * dismissing the action sheet.\n *\n * @since 0.1.0\n * @example false\n */\n canceled: boolean;\n /**\n * The index of the selected button in the `options` array (zero-based).\n *\n * If the action sheet was canceled without a cancel button, the index is `-1`.\n *\n * @since 0.1.0\n * @example 0\n */\n index: number;\n}\n\n/**\n * The style of an action sheet button.\n *\n * @since 0.1.0\n */\nexport enum ActionSheetButtonStyle {\n /**\n * A button that cancels the action sheet.\n *\n * It should be the last button in the `options` array.\n *\n * @since 0.1.0\n */\n Cancel = 'CANCEL',\n /**\n * A button with the default style.\n *\n * @since 0.1.0\n */\n Default = 'DEFAULT',\n /**\n * A button that indicates a destructive action.\n *\n * @since 0.1.0\n */\n Destructive = 'DESTRUCTIVE',\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const ActionSheet = registerPlugin('ActionSheet', {
|
|
3
|
+
web: () => import('./web').then(m => new m.ActionSheetWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { ActionSheet };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,WAAW,GAAG,cAAc,CAAoB,aAAa,EAAE;IACnE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;CAC7D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { ActionSheetPlugin } from './definitions';\n\nconst ActionSheet = registerPlugin<ActionSheetPlugin>('ActionSheet', {\n web: () => import('./web').then(m => new m.ActionSheetWeb()),\n});\n\nexport * from './definitions';\nexport { ActionSheet };\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { ActionSheetPlugin, ShowActionsOptions, ShowActionsResult } from './definitions';
|
|
3
|
+
export declare class ActionSheetWeb extends WebPlugin implements ActionSheetPlugin {
|
|
4
|
+
showActions(_options: ShowActionsOptions): Promise<ShowActionsResult>;
|
|
5
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQ5C,MAAM,OAAO,cAAe,SAAQ,SAAS;IAC3C,KAAK,CAAC,WAAW,CAAC,QAA4B;QAC5C,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n ActionSheetPlugin,\n ShowActionsOptions,\n ShowActionsResult,\n} from './definitions';\n\nexport class ActionSheetWeb extends WebPlugin implements ActionSheetPlugin {\n async showActions(_options: ShowActionsOptions): Promise<ShowActionsResult> {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The style of an action sheet button.
|
|
7
|
+
*
|
|
8
|
+
* @since 0.1.0
|
|
9
|
+
*/
|
|
10
|
+
exports.ActionSheetButtonStyle = void 0;
|
|
11
|
+
(function (ActionSheetButtonStyle) {
|
|
12
|
+
/**
|
|
13
|
+
* A button that cancels the action sheet.
|
|
14
|
+
*
|
|
15
|
+
* It should be the last button in the `options` array.
|
|
16
|
+
*
|
|
17
|
+
* @since 0.1.0
|
|
18
|
+
*/
|
|
19
|
+
ActionSheetButtonStyle["Cancel"] = "CANCEL";
|
|
20
|
+
/**
|
|
21
|
+
* A button with the default style.
|
|
22
|
+
*
|
|
23
|
+
* @since 0.1.0
|
|
24
|
+
*/
|
|
25
|
+
ActionSheetButtonStyle["Default"] = "DEFAULT";
|
|
26
|
+
/**
|
|
27
|
+
* A button that indicates a destructive action.
|
|
28
|
+
*
|
|
29
|
+
* @since 0.1.0
|
|
30
|
+
*/
|
|
31
|
+
ActionSheetButtonStyle["Destructive"] = "DESTRUCTIVE";
|
|
32
|
+
})(exports.ActionSheetButtonStyle || (exports.ActionSheetButtonStyle = {}));
|
|
33
|
+
|
|
34
|
+
const ActionSheet = core.registerPlugin('ActionSheet', {
|
|
35
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ActionSheetWeb()),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
class ActionSheetWeb extends core.WebPlugin {
|
|
39
|
+
async showActions(_options) {
|
|
40
|
+
throw this.unimplemented('Not implemented on web.');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
45
|
+
__proto__: null,
|
|
46
|
+
ActionSheetWeb: ActionSheetWeb
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
exports.ActionSheet = ActionSheet;
|
|
50
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * The style of an action sheet button.\n *\n * @since 0.1.0\n */\nexport var ActionSheetButtonStyle;\n(function (ActionSheetButtonStyle) {\n /**\n * A button that cancels the action sheet.\n *\n * It should be the last button in the `options` array.\n *\n * @since 0.1.0\n */\n ActionSheetButtonStyle[\"Cancel\"] = \"CANCEL\";\n /**\n * A button with the default style.\n *\n * @since 0.1.0\n */\n ActionSheetButtonStyle[\"Default\"] = \"DEFAULT\";\n /**\n * A button that indicates a destructive action.\n *\n * @since 0.1.0\n */\n ActionSheetButtonStyle[\"Destructive\"] = \"DESTRUCTIVE\";\n})(ActionSheetButtonStyle || (ActionSheetButtonStyle = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst ActionSheet = registerPlugin('ActionSheet', {\n web: () => import('./web').then(m => new m.ActionSheetWeb()),\n});\nexport * from './definitions';\nexport { ActionSheet };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ActionSheetWeb extends WebPlugin {\n async showActions(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ActionSheetButtonStyle","registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACWA;AACX,CAAC,UAAU,sBAAsB,EAAE;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,sBAAsB,CAAC,QAAQ,CAAC,GAAG,QAAQ;AAC/C;AACA;AACA;AACA;AACA;AACA,IAAI,sBAAsB,CAAC,SAAS,CAAC,GAAG,SAAS;AACjD;AACA;AACA;AACA;AACA;AACA,IAAI,sBAAsB,CAAC,aAAa,CAAC,GAAG,aAAa;AACzD,CAAC,EAAEA,8BAAsB,KAAKA,8BAAsB,GAAG,EAAE,CAAC,CAAC;;AC1BtD,MAAC,WAAW,GAAGC,mBAAc,CAAC,aAAa,EAAE;AAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;AAChE,CAAC;;ACFM,MAAM,cAAc,SAASC,cAAS,CAAC;AAC9C,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;AAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var capacitorActionSheet = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The style of an action sheet button.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.1.0
|
|
8
|
+
*/
|
|
9
|
+
exports.ActionSheetButtonStyle = void 0;
|
|
10
|
+
(function (ActionSheetButtonStyle) {
|
|
11
|
+
/**
|
|
12
|
+
* A button that cancels the action sheet.
|
|
13
|
+
*
|
|
14
|
+
* It should be the last button in the `options` array.
|
|
15
|
+
*
|
|
16
|
+
* @since 0.1.0
|
|
17
|
+
*/
|
|
18
|
+
ActionSheetButtonStyle["Cancel"] = "CANCEL";
|
|
19
|
+
/**
|
|
20
|
+
* A button with the default style.
|
|
21
|
+
*
|
|
22
|
+
* @since 0.1.0
|
|
23
|
+
*/
|
|
24
|
+
ActionSheetButtonStyle["Default"] = "DEFAULT";
|
|
25
|
+
/**
|
|
26
|
+
* A button that indicates a destructive action.
|
|
27
|
+
*
|
|
28
|
+
* @since 0.1.0
|
|
29
|
+
*/
|
|
30
|
+
ActionSheetButtonStyle["Destructive"] = "DESTRUCTIVE";
|
|
31
|
+
})(exports.ActionSheetButtonStyle || (exports.ActionSheetButtonStyle = {}));
|
|
32
|
+
|
|
33
|
+
const ActionSheet = core.registerPlugin('ActionSheet', {
|
|
34
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ActionSheetWeb()),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
class ActionSheetWeb extends core.WebPlugin {
|
|
38
|
+
async showActions(_options) {
|
|
39
|
+
throw this.unimplemented('Not implemented on web.');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
44
|
+
__proto__: null,
|
|
45
|
+
ActionSheetWeb: ActionSheetWeb
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
exports.ActionSheet = ActionSheet;
|
|
49
|
+
|
|
50
|
+
return exports;
|
|
51
|
+
|
|
52
|
+
})({}, capacitorExports);
|
|
53
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * The style of an action sheet button.\n *\n * @since 0.1.0\n */\nexport var ActionSheetButtonStyle;\n(function (ActionSheetButtonStyle) {\n /**\n * A button that cancels the action sheet.\n *\n * It should be the last button in the `options` array.\n *\n * @since 0.1.0\n */\n ActionSheetButtonStyle[\"Cancel\"] = \"CANCEL\";\n /**\n * A button with the default style.\n *\n * @since 0.1.0\n */\n ActionSheetButtonStyle[\"Default\"] = \"DEFAULT\";\n /**\n * A button that indicates a destructive action.\n *\n * @since 0.1.0\n */\n ActionSheetButtonStyle[\"Destructive\"] = \"DESTRUCTIVE\";\n})(ActionSheetButtonStyle || (ActionSheetButtonStyle = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst ActionSheet = registerPlugin('ActionSheet', {\n web: () => import('./web').then(m => new m.ActionSheetWeb()),\n});\nexport * from './definitions';\nexport { ActionSheet };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ActionSheetWeb extends WebPlugin {\n async showActions(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ActionSheetButtonStyle","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;AACWA;IACX,CAAC,UAAU,sBAAsB,EAAE;IACnC;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,sBAAsB,CAAC,QAAQ,CAAC,GAAG,QAAQ;IAC/C;IACA;IACA;IACA;IACA;IACA,IAAI,sBAAsB,CAAC,SAAS,CAAC,GAAG,SAAS;IACjD;IACA;IACA;IACA;IACA;IACA,IAAI,sBAAsB,CAAC,aAAa,CAAC,GAAG,aAAa;IACzD,CAAC,EAAEA,8BAAsB,KAAKA,8BAAsB,GAAG,EAAE,CAAC,CAAC;;AC1BtD,UAAC,WAAW,GAAGC,mBAAc,CAAC,aAAa,EAAE;IAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;IAChE,CAAC;;ICFM,MAAM,cAAc,SAASC,cAAS,CAAC;IAC9C,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;IAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import UIKit
|
|
4
|
+
|
|
5
|
+
@objc public class ActionSheet: NSObject, UIPopoverPresentationControllerDelegate {
|
|
6
|
+
private let plugin: ActionSheetPlugin
|
|
7
|
+
private var pendingCompletion: ((ShowActionsResult?, Error?) -> Void)?
|
|
8
|
+
|
|
9
|
+
init(plugin: ActionSheetPlugin) {
|
|
10
|
+
self.plugin = plugin
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@objc public func showActions(_ options: ShowActionsOptions, completion: @escaping (ShowActionsResult?, Error?) -> Void) {
|
|
14
|
+
DispatchQueue.main.async {
|
|
15
|
+
self.pendingCompletion = completion
|
|
16
|
+
let alertController = UIAlertController(title: options.title, message: options.message, preferredStyle: .actionSheet)
|
|
17
|
+
for (index, button) in options.buttons.enumerated() {
|
|
18
|
+
let action = UIAlertAction(title: button.title, style: self.alertActionStyle(for: button.style)) { _ in
|
|
19
|
+
self.resolve(index: index, canceled: button.style == ActionSheetButton.styleCancel)
|
|
20
|
+
}
|
|
21
|
+
alertController.addAction(action)
|
|
22
|
+
}
|
|
23
|
+
if let popoverController = alertController.popoverPresentationController, let view = self.plugin.bridge?.viewController?.view {
|
|
24
|
+
popoverController.delegate = self
|
|
25
|
+
popoverController.sourceView = view
|
|
26
|
+
popoverController.sourceRect = CGRect(x: view.bounds.midX, y: view.bounds.midY, width: 0, height: 0)
|
|
27
|
+
popoverController.permittedArrowDirections = []
|
|
28
|
+
}
|
|
29
|
+
self.present(alertController)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public func popoverPresentationControllerDidDismissPopover(_ popoverPresentationController: UIPopoverPresentationController) {
|
|
34
|
+
resolve(index: -1, canceled: true)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private func alertActionStyle(for style: String) -> UIAlertAction.Style {
|
|
38
|
+
switch style {
|
|
39
|
+
case ActionSheetButton.styleCancel:
|
|
40
|
+
return .cancel
|
|
41
|
+
case ActionSheetButton.styleDestructive:
|
|
42
|
+
return .destructive
|
|
43
|
+
default:
|
|
44
|
+
return .default
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private func present(_ alertController: UIAlertController) {
|
|
49
|
+
plugin.bridge?.viewController?.present(alertController, animated: true)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private func resolve(index: Int, canceled: Bool) {
|
|
53
|
+
guard let completion = pendingCompletion else {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
pendingCompletion = nil
|
|
57
|
+
completion(ShowActionsResult(index: index, canceled: canceled), nil)
|
|
58
|
+
}
|
|
59
|
+
}
|