@capawesome/capacitor-action-sheet 0.0.1 → 0.1.0
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/README.md +53 -2
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -21,9 +21,14 @@ Capacitor plugin for native action sheets.
|
|
|
21
21
|
|
|
22
22
|
Missing a feature? Just [open an issue](https://github.com/capawesome-team/capacitor-plugins/issues) and we'll take a look!
|
|
23
23
|
|
|
24
|
-
##
|
|
24
|
+
## Use Cases
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
The Action Sheet plugin is typically used to let the user choose between several actions in a native way, for example:
|
|
27
|
+
|
|
28
|
+
- **Contextual item actions**: Show options such as upload, share, or delete when the user taps an item in a list.
|
|
29
|
+
- **Destructive confirmations**: Highlight irreversible actions like deleting a photo using the destructive button style.
|
|
30
|
+
- **Photo source selection**: Ask the user whether to take a new photo or pick an existing one before opening the camera.
|
|
31
|
+
- **Cancelable flows**: Pin a cancel button to the sheet so the user can always back out of an action.
|
|
27
32
|
|
|
28
33
|
## Compatibility
|
|
29
34
|
|
|
@@ -71,6 +76,12 @@ No configuration required for this plugin.
|
|
|
71
76
|
|
|
72
77
|
## Usage
|
|
73
78
|
|
|
79
|
+
The following example shows how to present a native action sheet and read the selected button.
|
|
80
|
+
|
|
81
|
+
### Show an action sheet
|
|
82
|
+
|
|
83
|
+
Present a native action sheet with a title, a message, and a list of buttons. Use `ActionSheetButtonStyle.Destructive` to highlight irreversible actions and `ActionSheetButtonStyle.Cancel` to pin a cancel button. The result contains the zero-based index of the selected button and whether the sheet was canceled. Only available on Android and iOS:
|
|
84
|
+
|
|
74
85
|
```typescript
|
|
75
86
|
import { ActionSheet, ActionSheetButtonStyle } from '@capawesome/capacitor-action-sheet';
|
|
76
87
|
|
|
@@ -176,6 +187,46 @@ This plugin is API-compatible with the official [`@capacitor/action-sheet`](http
|
|
|
176
187
|
| `message` and button styles ignored on Android | `message` and button styles rendered on Android |
|
|
177
188
|
| `cancelable` not available | `cancelable` (default `true`) |
|
|
178
189
|
|
|
190
|
+
## FAQ
|
|
191
|
+
|
|
192
|
+
### How is this plugin different from other similar plugins?
|
|
193
|
+
|
|
194
|
+
It presents the platform's own native action sheet on Android and iOS through a fully typed API, rendering the title, message, and button styles — including destructive and cancel styles — consistently on both platforms, and automatically anchoring as a popover on iPad. The result reports the selected button index along with a `canceled` flag, and the `cancelable` option controls dismissal, all using only official platform APIs. Actively maintained against the latest Capacitor version, it lets a single dependency cover the whole action-sheet story.
|
|
195
|
+
|
|
196
|
+
### On which platforms can I show an action sheet?
|
|
197
|
+
|
|
198
|
+
The `showActions(...)` method is only available on Android and iOS, where it presents the native action sheet of the respective platform. On iPad, the action sheet is automatically anchored as a popover.
|
|
199
|
+
|
|
200
|
+
### How do I know which button the user selected?
|
|
201
|
+
|
|
202
|
+
The result of `showActions(...)` contains the zero-based `index` of the selected button in the `options` array and a `canceled` flag. If the action sheet was canceled without a cancel button, the index is `-1`.
|
|
203
|
+
|
|
204
|
+
### Can the user dismiss the action sheet without selecting a button?
|
|
205
|
+
|
|
206
|
+
Yes. On Android, the action sheet can be dismissed by tapping outside of it or pressing the back button unless you set the `cancelable` option to `false`. On iOS, the action sheet can always be dismissed by tapping outside of it, which is a system behavior.
|
|
207
|
+
|
|
208
|
+
### How is this plugin different from the official Capacitor Action Sheet plugin?
|
|
209
|
+
|
|
210
|
+
This plugin is API-compatible with the official `@capacitor/action-sheet` plugin and uses the same `ActionSheetButtonStyle` enum values. In addition, it renders the message and button styles on Android, returns a `canceled` flag, and supports the `cancelable` option. See the [migration section](#migrating-from-capacitoraction-sheet) for a detailed comparison.
|
|
211
|
+
|
|
212
|
+
### Can I use this plugin together with the Capawesome Dialog plugin?
|
|
213
|
+
|
|
214
|
+
Yes, the plugin is designed to work alongside the [Dialog](https://capawesome.io/docs/sdks/capacitor/dialog/) plugin. Use an action sheet when the user has to choose between several actions, and a dialog for alerts, confirmations, and text input.
|
|
215
|
+
|
|
216
|
+
### Can I use this plugin with Ionic, React, Vue or Angular?
|
|
217
|
+
|
|
218
|
+
Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.
|
|
219
|
+
|
|
220
|
+
## Related Plugins
|
|
221
|
+
|
|
222
|
+
- [Dialog](https://capawesome.io/docs/sdks/capacitor/dialog/): Display native alert, confirm, and prompt dialogs.
|
|
223
|
+
- [Toast](https://capawesome.io/docs/sdks/capacitor/toast/): Show native toast notifications.
|
|
224
|
+
- [Haptics](https://capawesome.io/docs/sdks/capacitor/haptics/): Provide haptic feedback such as impacts, notifications, and vibrations.
|
|
225
|
+
|
|
226
|
+
## Newsletter
|
|
227
|
+
|
|
228
|
+
Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).
|
|
229
|
+
|
|
179
230
|
## Changelog
|
|
180
231
|
|
|
181
232
|
See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/action-sheet/CHANGELOG.md).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capawesome/capacitor-action-sheet",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "Capacitor plugin for native action sheets.",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Capacitor plugin for native action sheets on Android and iOS.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/esm/index.d.ts",
|
|
@@ -40,7 +40,13 @@
|
|
|
40
40
|
"native",
|
|
41
41
|
"action-sheet",
|
|
42
42
|
"action sheet",
|
|
43
|
-
"bottom sheet"
|
|
43
|
+
"bottom sheet",
|
|
44
|
+
"capacitor-plugin",
|
|
45
|
+
"native action sheet",
|
|
46
|
+
"context menu",
|
|
47
|
+
"popover",
|
|
48
|
+
"destructive button",
|
|
49
|
+
"cancel button"
|
|
44
50
|
],
|
|
45
51
|
"scripts": {
|
|
46
52
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|