Skip to content

Commit 8601e07

Browse files
feat: Add way to test new action sheet feature (#776)
* chore: update pwa-elements to latest version * feat: Add action sheet screen to test new feature * tmp: Use dev build of action-sheet plugin References: - ionic-team/capacitor-plugins#2285 - https://outsystemsrd.atlassian.net/browse/RMET-3576 * chore: point to stable action-sheet version * chore: fix lint issues * chore: Use capacitor 8.2.0 * fix: Remove iOS check for cancelable toggle We may look into introducing cancelable for iOS, so this helps test it better * chore: update action-sheet dependency to latest * chore: fix merge conflict
1 parent 3704a20 commit 8601e07

File tree

4 files changed

+63
-54
lines changed

4 files changed

+63
-54
lines changed

package-lock.json

Lines changed: 8 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@
2525
]
2626
},
2727
"dependencies": {
28-
"@capacitor/action-sheet": "^8.0.0",
29-
"@capacitor/android": "^8.0.0",
28+
"@capacitor/action-sheet": "^8.1.1",
29+
"@capacitor/android": "^8.2.0",
3030
"@capacitor/app": "^8.0.0",
3131
"@capacitor/app-launcher": "^8.0.0",
3232
"@capacitor/browser": "^8.0.0",
3333
"@capacitor/camera": "^8.0.0",
3434
"@capacitor/clipboard": "^8.0.0",
35-
"@capacitor/core": "^8.0.0",
35+
"@capacitor/core": "^8.2.0",
3636
"@capacitor/device": "^8.0.0",
3737
"@capacitor/dialog": "^8.0.0",
3838
"@capacitor/filesystem": "^8.0.0",
3939
"@capacitor/geolocation": "^8.0.0",
4040
"@capacitor/haptics": "^8.0.0",
41-
"@capacitor/ios": "^8.0.0",
41+
"@capacitor/ios": "^8.2.0",
4242
"@capacitor/keyboard": "^8.0.0",
4343
"@capacitor/local-notifications": "^8.0.0",
4444
"@capacitor/motion": "^8.0.0",
@@ -52,7 +52,7 @@
5252
"@capacitor/status-bar": "^8.0.0",
5353
"@capacitor/text-zoom": "^8.0.0",
5454
"@capacitor/toast": "^8.0.0",
55-
"@ionic/pwa-elements": "^3.1.1",
55+
"@ionic/pwa-elements": "^3.4.0",
5656
"@ionic/react": "^7.0.0",
5757
"@ionic/react-router": "^7.0.0",
5858
"@types/jest": "^26.0.20",
@@ -68,7 +68,7 @@
6868
"react-router-dom": "^5.3.4"
6969
},
7070
"devDependencies": {
71-
"@capacitor/cli": "^8.0.0",
71+
"@capacitor/cli": "^8.2.0",
7272
"@testing-library/jest-dom": "^5.16.5",
7373
"@testing-library/react": "^14.0.0",
7474
"@testing-library/user-event": "^14.4.3",

src/pages/ActionSheet.tsx

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,54 @@ import {
77
IonMenuButton,
88
IonTitle,
99
IonToolbar,
10+
IonToggle,
11+
IonItem,
12+
IonLabel,
1013
} from '@ionic/react';
11-
import React from 'react';
14+
import React, { useState } from 'react';
1215
import { ActionSheet, ActionSheetButtonStyle } from '@capacitor/action-sheet';
1316

1417
const ActionSheetPage: React.FC = () => {
18+
const [cancelable, setCancelable] = useState(true);
19+
1520
const showActions = async () => {
16-
let promptRet = await ActionSheet.showActions({
21+
const result = await ActionSheet.showActions({
1722
title: 'Photo Options',
1823
message: 'Select an option to perform',
1924
options: [
20-
{
21-
title: 'Upload',
22-
},
23-
{
24-
title: 'Share',
25-
},
25+
{ title: 'Upload' },
26+
{ title: 'Share' },
2627
{
2728
title: 'Remove',
2829
style: ActionSheetButtonStyle.Destructive,
2930
},
3031
],
32+
cancelable: cancelable,
3133
});
32-
console.log('You selected', promptRet);
34+
35+
console.log('Normal sheet:', result);
36+
alert('Normal sheet: ' + JSON.stringify(result));
3337
};
38+
39+
const showActionsWithCancel = async () => {
40+
const result = await ActionSheet.showActions({
41+
title: 'Photo Options',
42+
message: 'Select an option to perform',
43+
options: [
44+
{ title: 'Upload' },
45+
{ title: 'Share' },
46+
{
47+
title: 'Cancel',
48+
style: ActionSheetButtonStyle.Cancel,
49+
},
50+
],
51+
cancelable: cancelable,
52+
});
53+
54+
console.log('Cancel sheet:', result);
55+
alert('Cancel sheet: ' + JSON.stringify(result));
56+
};
57+
3458
return (
3559
<IonPage>
3660
<IonHeader>
@@ -41,9 +65,22 @@ const ActionSheetPage: React.FC = () => {
4165
<IonTitle>Action Sheet</IonTitle>
4266
</IonToolbar>
4367
</IonHeader>
68+
4469
<IonContent>
70+
<IonItem>
71+
<IonLabel>Cancelable</IonLabel>
72+
<IonToggle
73+
checked={cancelable}
74+
onIonChange={e => setCancelable(e.detail.checked)}
75+
/>
76+
</IonItem>
77+
4578
<IonButton expand="block" onClick={showActions}>
46-
Show Actions
79+
Show Actions (Destructive)
80+
</IonButton>
81+
82+
<IonButton expand="block" onClick={showActionsWithCancel}>
83+
Show Actions (With Cancel)
4784
</IonButton>
4885
</IonContent>
4986
</IonPage>

src/pages/Home.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ const Home: React.FC = () => {
5050
style={{
5151
fontSize: '30px',
5252
fontFamily: 'monospace',
53-
}}>
53+
}}
54+
>
5455
App Resolution: {dimensions.width} × {dimensions.height}
5556
</div>
5657
<h1>Counter</h1>

0 commit comments

Comments
 (0)