@@ -14,14 +14,13 @@ import Prelude
1414
1515import Demo.Shared (DemoProps, desc, scrollWrap, sectionTitle)
1616import React.Basic (JSX)
17−import React.Basic.Events (handler_)
17+
1818import React.Basic.Hooks (useState', (/\))
1919import React.Basic.Hooks as React
2020import Yoga.React (component)
2121import Yoga.React.Native (tw, view)
2222import Yoga.React.Native.MacOS.Button (nativeButton)
2323import Yoga.React.Native.MacOS.ColorPanel (macosShowColorPanel)
24−import Yoga.React.Native.MacOS.Events as E
2524import Yoga.React.Native.MacOS.FontPanel (macosShowFontPanel)
2625import Yoga.React.Native.MacOS.Pasteboard (copyToClipboard)
2726import Yoga.React.Native.MacOS.QuickLook (macosQuickLook)
@@ -43,7 +42,7 @@ clipboardDemo = component "ClipboardDemo" \dp -> pure do
4342 [ nativeButton
4443 { title: "Copy 'Hello'"
4544 , bezelStyle: T.push
46− , onPress: handler_ (copyToClipboard "Hello from PureScript!")
45+ , onPress: copyToClipboard "Hello from PureScript!"
4746 , style: Style.style { height: 24.0, width: 120.0 }
4847 }
4948 ]
@@ -57,7 +56,7 @@ shareDemo = component "ShareDemo" \dp -> pure do
5756 , nativeButton
5857 { title: "Share Text"
5958 , bezelStyle: T.push
60− , onPress: handler_ (macosShare [ "Hello from PureScript React Native!" ])
59+ , onPress: macosShare [ "Hello from PureScript React Native!" ]
6160 , style: Style.style { height: 24.0, width: 120.0 } <> tw "mb-2"
6261 }
6362 ]
@@ -70,7 +69,7 @@ notificationsDemo = component "NotificationsDemo" \dp -> pure do
7069 , nativeButton
7170 { title: "Send Notification"
7271 , bezelStyle: T.push
73− , onPress: handler_ (macosNotify { title: "PureScript", body: "Hello from React Native macOS!" })
72+ , onPress: macosNotify { title: "PureScript", body: "Hello from React Native macOS!" }
7473 , style: Style.style { height: 24.0, width: 160.0 } <> tw "mb-2"
7574 }
7675 ]
@@ -84,19 +83,19 @@ soundDemo = component "SoundDemo" \dp -> pure do
8483 [ nativeButton
8584 { title: "Glass"
8685 , bezelStyle: T.push
87− , onPress: handler_ (macosPlaySound "Glass")
86+ , onPress: macosPlaySound "Glass"
8887 , style: Style.style { height: 24.0, width: 80.0 }
8988 }
9089 , nativeButton
9190 { title: "Ping"
9291 , bezelStyle: T.push
93− , onPress: handler_ (macosPlaySound "Ping")
92+ , onPress: macosPlaySound "Ping"
9493 , style: Style.style { height: 24.0, width: 80.0, marginLeft: 8.0 }
9594 }
9695 , nativeButton
9796 { title: "Beep"
9897 , bezelStyle: T.push
99− , onPress: handler_ macosBeep
98+ , onPress: macosBeep
10099 , style: Style.style { height: 24.0, width: 80.0, marginLeft: 8.0 }
101100 }
102101 ]
@@ -113,22 +112,21 @@ statusBarDemo = component "StatusBarDemo" \dp -> React.do
113112 [ nativeButton
114113 { title: if active then "Remove" else "Add to Menu Bar"
115114 , bezelStyle: T.push
116− , onPress: handler_
117− ( if active then do
118− macosRemoveStatusBarItem
119− setActive false
120− else do
121− macosSetStatusBarItem
122− { title: ""
123− , sfSymbol: "swift"
124− , menuItems:
125− [ { id: "about", title: "About PureScript RN" }
126− , { id: "sep", title: "-" }
127− , { id: "quit", title: "Quit" }
128− ]
129− }
130− setActive true
131− )
115+ , onPress:
116+ if active then do
117+ macosRemoveStatusBarItem
118+ setActive false
119+ else do
120+ macosSetStatusBarItem
121+ { title: ""
122+ , sfSymbol: "swift"
123+ , menuItems:
124+ [ { id: "about", title: "About PureScript RN" }
125+ , { id: "sep", title: "-" }
126+ , { id: "quit", title: "Quit" }
127+ ]
128+ }
129+ setActive true
132130 , style: Style.style { height: 24.0, width: 180.0 }
133131 }
134132 ]
@@ -143,7 +141,7 @@ quickLookDemo = component "QuickLookDemo" \dp -> pure do
143141 [ nativeButton
144142 { title: "Preview /etc/hosts"
145143 , bezelStyle: T.push
146− , onPress: handler_ (macosQuickLook "/etc/hosts")
144+ , onPress: macosQuickLook "/etc/hosts"
147145 , style: Style.style { height: 24.0, width: 180.0 }
148146 }
149147 ]
@@ -158,7 +156,7 @@ colorPanelDemo = component "ColorPanelDemo" \dp -> pure do
158156 [ nativeButton
159157 { title: "Show Color Panel"
160158 , bezelStyle: T.push
161− , onPress: handler_ macosShowColorPanel
159+ , onPress: macosShowColorPanel
162160 , style: Style.style { height: 24.0, width: 180.0 }
163161 }
164162 ]
@@ -173,7 +171,7 @@ fontPanelDemo = component "FontPanelDemo" \dp -> pure do
173171 [ nativeButton
174172 { title: "Show Font Panel"
175173 , bezelStyle: T.push
176− , onPress: handler_ macosShowFontPanel
174+ , onPress: macosShowFontPanel
177175 , style: Style.style { height: 24.0, width: 180.0 }
178176 }
179177 ]
@@ -196,13 +194,13 @@ speechDemo = component "SpeechDemo" \dp -> React.do
196194 [ nativeButton
197195 { title: "Speak"
198196 , bezelStyle: T.push
199− , onPress: handler_ (say txt)
197+ , onPress: say txt
200198 , style: Style.style { height: 24.0, width: 100.0 }
201199 }
202200 , nativeButton
203201 { title: "Stop"
204202 , bezelStyle: T.push
205− , onPress: handler_ stopSpeaking
203+ , onPress: stopSpeaking
206204 , style: Style.style { height: 24.0, width: 100.0, marginLeft: 8.0 }
207205 }
208206 ]