1import { Button, Group, List, Menu, Navigation, NavigationStack, Script, ScrollView, Section, Text, VStack } from "scripting"
2
3function Example() {
4
5 return <NavigationStack>
6 <List
7 navigationTitle={"Menu"}
8 navigationBarTitleDisplayMode={"inline"}
9 >
10
11 <Section
12 header={
13 <Text>Menu</Text>
14 }
15 >
16 <Menu
17 title={"Open Menu"}
18 >
19 <Button
20 title="Rename"
21 action={() => console.log("Rename")}
22 />
23 <Button
24 title="Delete"
25 role={"destructive"}
26 action={() => console.log("Delete")}
27 />
28 <Menu title="Copy">
29 <Button
30 title="Copy"
31 action={() => console.log("Copy")}
32 />
33 <Button
34 title="Copy Formated"
35 action={() => console.log("Copy fomatted")}
36 />
37 </Menu>
38 </Menu>
39 </Section>
40
41 <Section
42 header={
43 <Text>ContextMenu</Text>
44 }
45 >
46 <Text
47 foregroundStyle={"link"}
48 contextMenu={{
49 menuItems: <Group>
50 <Button
51 title="Add"
52 action={() => {
53 // Add
54 }}
55 />
56 <Button
57 title="Delete"
58 role="destructive"
59 action={() => {
60 // Delete
61 }}
62 />
63 </Group>
64 }}
65 >Long Press to open context menu</Text>
66 </Section>
67 </List>
68 </NavigationStack>
69}
70
71async function run() {
72 await Navigation.present({
73 element: <Example />
74 })
75
76 Script.exit()
77}
78
79run()