Example

1import { Button, Device, List, Navigation, NavigationStack, Script, Text, VStack } from "scripting"
2
3 function Example() {
4  const dismiss = Navigation.useDismiss()
5
6  const details: {
7    name: string
8    value: string | boolean | number
9  }[] = [
10      {
11        name: "Device.isiPhone",
12        value: Device.isiPhone
13      },
14      {
15        name: "Device.isiPad",
16        value: Device.isiPad,
17      },
18      {
19        name: "Device.systemVersion",
20        value: Device.systemVersion,
21      },
22      {
23        name: "Device.systemName",
24        value: Device.systemName,
25      },
26      {
27        name: "Device.isPortrait",
28        value: Device.isPortrait,
29      },
30      {
31        name: "Device.isLandscape",
32        value: Device.isLandscape,
33      },
34      {
35        name: "Device.isFlat",
36        value: Device.isFlat,
37      },
38      {
39        name: "Device.batteryLevel",
40        value: Device.batteryLevel,
41      },
42      {
43        name: "Device.batteryState",
44        value: Device.batteryState,
45      }
46    ]
47
48  return <NavigationStack>
49    <List
50      navigationTitle={"Device"}
51      toolbar={{
52        cancellationAction: <Button
53          title={"Done"}
54          action={dismiss}
55        />
56      }}
57    >
58      {details.map(item =>
59        <VStack
60          badge={item.value.toString()}
61          alignment={"leading"}
62        >
63          <Text font={"headline"}>{item.name}</Text>
64          <Text font={"caption"}>{typeof item.value}</Text>
65        </VStack>
66      )}
67    </List>
68  </NavigationStack>
69}
70
71async function run() {
72  await Navigation.present({
73    element: <Example />
74  })
75
76  Script.exit()
77}
78
79run()