1import { Button, Image, List, Markdown, Navigation, NavigationStack, ProgressView, QRImage, Script, Section, Text, VStack } from "scripting"
2
3function View() {
4 const dismiss = Navigation.useDismiss()
5 const url = "https://github.com"
6
7 return <NavigationStack>
8 <List
9 navigationTitle={"Image"}
10 toolbar={{
11 topBarLeading: <Button
12 title={"Close"}
13 action={dismiss}
14 />
15 }}
16 >
17
18 <Section title={"Network Image"}>
19 <Image
20 imageUrl={'https://developer.apple.com/assets/elements/icons/swiftui/swiftui-96x96_2x.png'}
21 resizable
22 scaleToFit
23 placeholder={<ProgressView
24 progressViewStyle={'circular'}
25 />}
26 />
27 </Section>
28
29 <Section title={"SF Symbol"}>
30 <Image
31 systemName={"phone"}
32 resizable
33 scaleToFit
34 frame={{
35 width: 32,
36 height: 32,
37 }}
38 foregroundStyle={"systemGreen"}
39 />
40 </Section>
41
42 <Section title={"Local Image"}>
43 <Markdown
44 content={`\`\`\`tsx
45<Image
46 filePath={Path.join(Script.directory, "test.jpg")}
47/>
48\`\`\``}
49 />
50 </Section>
51
52 <Section title={"QR Code Image"}>
53 <VStack>
54 <Text>URL: {url}</Text>
55 <QRImage
56 data={url}
57 />
58 </VStack>
59 </Section>
60 </List>
61 </NavigationStack>
62}
63
64async function run() {
65 await Navigation.present(<View />)
66 Script.exit()
67}
68
69run()