1import { Button, List, Navigation, NavigationStack, Script, Section, Text } from "scripting"
2
3function Example() {
4 return <NavigationStack>
5 <List
6 navigationTitle={"QRCode"}
7 navigationBarTitleDisplayMode={"inline"}
8 >
9 <Section
10 footer={
11 <Text>Open the QRCode scan page and scan.</Text>
12 }
13 >
14 <Button
15 title={"QRCode.scan"}
16 action={async () => {
17 const result = await QRCode.scan()
18 if (result) {
19 Dialog.alert({
20 message: "Result: " + result
21 })
22 } else {
23 Dialog.alert({
24 message: "Cancelled"
25 })
26 }
27 }}
28 />
29 </Section>
30
31 <Section
32 footer={
33 <Text>Parse QRCode file to a string.</Text>
34 }
35 >
36 <Button
37 title={"QRCode.parse"}
38 action={async () => {
39 const result = await DocumentPicker.pickFiles({
40 allowsMultipleSelection: false
41 })
42 if (result.length) {
43 const code = await QRCode.parse(result[0])
44 Dialog.alert({
45 message: "Parse reuslt: " + code
46 })
47 }
48 }}
49 />
50 </Section>
51 </List>
52 </NavigationStack>
53}
54
55async function run() {
56 await Navigation.present({
57 element: <Example />
58 })
59
60 Script.exit()
61}
62
63run()