git.iko.soy/rowtype-yoga/purescript-yoga-react-native
on main help sign in
WIP: React Native bindings development
cf94852Mark
docs/src/Docs/Pages/InputControls.purs+4−4
@@ -30,7 +30,7 @@ button = L.componentDoc "nativeButton" "Yoga.React.Native.MacOS.Button (nativeBu
30 """nativeButton
30 """nativeButton
31 { title: "Click me"
31 { title: "Click me"
32 , bezelStyle: T.push
32 , bezelStyle: T.push
33− , onPress: handler_ doSomething
33+ , onPress: doSomething
34 }"""
34 }"""
35 [ propsTable
35 [ propsTable
36 [ { name: "title", type_: "String", description: "Button label text (mutually exclusive with sfSymbol)" }
36 [ { name: "title", type_: "String", description: "Button label text (mutually exclusive with sfSymbol)" }
@@ -39,7 +39,7 @@ button = L.componentDoc "nativeButton" "Yoga.React.Native.MacOS.Button (nativeBu
39 , { name: "destructive", type_: "Boolean", description: "Red destructive styling" }
39 , { name: "destructive", type_: "Boolean", description: "Red destructive styling" }
40 , { name: "primary", type_: "Boolean", description: "Primary action button" }
40 , { name: "primary", type_: "Boolean", description: "Primary action button" }
41 , { name: "buttonEnabled", type_: "Boolean", description: "Enable/disable the button" }
41 , { name: "buttonEnabled", type_: "Boolean", description: "Enable/disable the button" }
42− , { name: "onPress", type_: "EventHandler", description: "Press callback" }
42+ , { name: "onPress", type_: "Effect Unit", description: "Press callback" }
43 ]
43 ]
44 ]
44 ]
45
45
@@ -228,8 +228,8 @@ colorWell = L.componentDoc "nativeColorWell" "Yoga.React.Native.MacOS.ColorWell
228helpButton :: Nut
228helpButton :: Nut
229helpButton = L.componentDoc "nativeHelpButton" "Yoga.React.Native.MacOS.HelpButton (nativeHelpButton)"
229helpButton = L.componentDoc "nativeHelpButton" "Yoga.React.Native.MacOS.HelpButton (nativeHelpButton)"
230 """nativeHelpButton
230 """nativeHelpButton
231− { onPress: handler_ showHelp }"""
231+ { onPress: showHelp }"""
232 [ propsTable
232 [ propsTable
233− [ { name: "onPress", type_: "EventHandler", description: "Press callback" }
233+ [ { name: "onPress", type_: "Effect Unit", description: "Press callback" }
234 ]
234 ]
235 ]
235 ]
docs/src/Docs/Pages/QuickStart.purs+1−1
@@ -57,7 +57,7 @@ import Yoga.React.Native.MacOS.Types as T
57myButton = nativeButton
57myButton = nativeButton
58 { title: "Click me"
58 { title: "Click me"
59 , bezelStyle: T.push
59 , bezelStyle: T.push
60− , onPress: handler_ doSomething
60+ , onPress: doSomething
61 , style: Style.style { height: 24.0 }
61 , style: Style.style { height: 24.0 }
62 }"""
62 }"""
63
63
example-macos/src/Demo/AiMl.purs+6−6
@@ -68,13 +68,13 @@ speechRecognitionDemo = component "SpeechRecognitionDemo" \dp -> React.do
68 [ nativeButton
68 [ nativeButton
69 { title: if speech.listening then "Listening..." else "Start"
69 { title: if speech.listening then "Listening..." else "Start"
70 , bezelStyle: T.push
70 , bezelStyle: T.push
71− , onPress: handler_ speech.start
71+ , onPress: speech.start
72 , style: Style.style { height: 24.0, width: 130.0 }
72 , style: Style.style { height: 24.0, width: 130.0 }
73 }
73 }
74 , nativeButton
74 , nativeButton
75 { title: "Stop"
75 { title: "Stop"
76 , bezelStyle: T.push
76 , bezelStyle: T.push
77− , onPress: handler_ speech.stop
77+ , onPress: speech.stop
78 , style: Style.style { height: 24.0, width: 80.0, marginLeft: 8.0 }
78 , style: Style.style { height: 24.0, width: 80.0, marginLeft: 8.0 }
79 }
79 }
80 ]
80 ]
@@ -101,7 +101,7 @@ naturalLanguageDemo = component "NaturalLanguageDemo" \dp -> React.do
101 [ nativeButton
101 [ nativeButton
102 { title: "Language"
102 { title: "Language"
103 , bezelStyle: T.push
103 , bezelStyle: T.push
104− , onPress: handler_ $ launchAff_ do
104+ , onPress: launchAff_ do
105 lang <- detectLanguage txt
105 lang <- detectLanguage txt
106 liftEffect (setResult ("Language: " <> lang))
106 liftEffect (setResult ("Language: " <> lang))
107 , style: Style.style { height: 24.0, width: 110.0 }
107 , style: Style.style { height: 24.0, width: 110.0 }
@@ -109,7 +109,7 @@ naturalLanguageDemo = component "NaturalLanguageDemo" \dp -> React.do
109 , nativeButton
109 , nativeButton
110 { title: "Sentiment"
110 { title: "Sentiment"
111 , bezelStyle: T.push
111 , bezelStyle: T.push
112− , onPress: handler_ $ launchAff_ do
112+ , onPress: launchAff_ do
113 score <- analyzeSentiment txt
113 score <- analyzeSentiment txt
114 liftEffect (setResult ("Sentiment: " <> show score))
114 liftEffect (setResult ("Sentiment: " <> show score))
115 , style: Style.style { height: 24.0, width: 110.0, marginLeft: 8.0 }
115 , style: Style.style { height: 24.0, width: 110.0, marginLeft: 8.0 }
@@ -117,7 +117,7 @@ naturalLanguageDemo = component "NaturalLanguageDemo" \dp -> React.do
117 , nativeButton
117 , nativeButton
118 { title: "Tokenize"
118 { title: "Tokenize"
119 , bezelStyle: T.push
119 , bezelStyle: T.push
120− , onPress: handler_ $ launchAff_ do
120+ , onPress: launchAff_ do
121 tokens <- tokenize txt
121 tokens <- tokenize txt
122 liftEffect (setResult ("Tokens: " <> joinWith ", " tokens))
122 liftEffect (setResult ("Tokens: " <> joinWith ", " tokens))
123 , style: Style.style { height: 24.0, width: 110.0, marginLeft: 8.0 }
123 , style: Style.style { height: 24.0, width: 110.0, marginLeft: 8.0 }
@@ -138,7 +138,7 @@ cameraDemo = component "CameraDemo" \dp -> React.do
138 , nativeButton
138 , nativeButton
139 { title: if on then "Stop" else "Start"
139 { title: if on then "Stop" else "Start"
140 , bezelStyle: T.push
140 , bezelStyle: T.push
141− , onPress: handler_ (setOn (not on))
141+ , onPress: setOn (not on)
142 , style: Style.style { height: 24.0, width: 100.0 }
142 , style: Style.style { height: 24.0, width: 100.0 }
143 }
143 }
144 ]
144 ]
example-macos/src/Demo/Chat.purs+8−9
@@ -189,7 +189,7 @@ chatDemo = component "ChatDemo" \dp -> React.do
189 , nativeButton
189 , nativeButton
190 { title: ""
190 { title: ""
191 , bezelStyle: T.toolbar
191 , bezelStyle: T.toolbar
192− , onPress: handler_ (selectRoom r.roomId)
192+ , onPress: selectRoom r.roomId
193 , style: Style.style { position: "absolute", top: 0.0, left: 0.0, right: 0.0, bottom: 0.0, opacity: 0.0 }
193 , style: Style.style { position: "absolute", top: 0.0, left: 0.0, right: 0.0, bottom: 0.0, opacity: 0.0 }
194 }
194 }
195 ]
195 ]
@@ -219,10 +219,9 @@ chatDemo = component "ChatDemo" \dp -> React.do
219 [ nativeButton
219 [ nativeButton
220 { title: "☺"
220 { title: "☺"
221 , bezelStyle: T.toolbar
221 , bezelStyle: T.toolbar
222− , onPress: handler_
222+ , onPress:
223− ( if reactPopover == Just idx then setReactPopover Nothing
223+ if reactPopover == Just idx then setReactPopover Nothing
224− else setReactPopover (Just idx)
224+ else setReactPopover (Just idx)
225− )
226 , style: Style.style { height: 20.0, width: 24.0 }
225 , style: Style.style { height: 20.0, width: 24.0 }
227 }
226 }
228 , view { style: tw "flex-row items-center p-2" <> Style.style { height: 40.0 } }
227 , view { style: tw "flex-row items-center p-2" <> Style.style { height: 40.0 } }
@@ -230,7 +229,7 @@ chatDemo = component "ChatDemo" \dp -> React.do
230 nativeButton
229 nativeButton
231 { title: emoji
230 { title: emoji
232 , bezelStyle: T.toolbar
231 , bezelStyle: T.toolbar
233− , onPress: handler_ (reactToMessage idx emoji)
232+ , onPress: reactToMessage idx emoji
234 , style: Style.style { height: 32.0, width: 32.0 }
233 , style: Style.style { height: 32.0, width: 32.0 }
235 }
234 }
236 )
235 )
@@ -253,7 +252,7 @@ chatDemo = component "ChatDemo" \dp -> React.do
253 , nativeButton
252 , nativeButton
254 { title: ""
253 { title: ""
255 , bezelStyle: T.toolbar
254 , bezelStyle: T.toolbar
256− , onPress: handler_ (scrollToMessage origIdx)
255+ , onPress: scrollToMessage origIdx
257 , style: Style.style { position: "absolute", top: 0.0, left: 0.0, right: 0.0, bottom: 0.0, opacity: 0.0 }
256 , style: Style.style { position: "absolute", top: 0.0, left: 0.0, right: 0.0, bottom: 0.0, opacity: 0.0 }
258 }
257 }
259 ]
258 ]
@@ -311,7 +310,7 @@ chatDemo = component "ChatDemo" \dp -> React.do
311 , nativeButton
310 , nativeButton
312 { title: "✕"
311 { title: "✕"
313 , bezelStyle: T.toolbar
312 , bezelStyle: T.toolbar
314− , onPress: handler_ (setReplyingTo Nothing)
313+ , onPress: setReplyingTo Nothing
315 , style: Style.style { height: 20.0, width: 24.0 }
314 , style: Style.style { height: 20.0, width: 24.0 }
316 }
315 }
317 ]
316 ]
@@ -368,7 +367,7 @@ chatDemo = component "ChatDemo" \dp -> React.do
368 , nativeButton
367 , nativeButton
369 { sfSymbol: "paperplane.fill"
368 { sfSymbol: "paperplane.fill"
370 , bezelStyle: T.toolbar
369 , bezelStyle: T.toolbar
371− , onPress: handler_ (sendMessage rid inputText)
370+ , onPress: sendMessage rid inputText
372 , style: Style.style { height: 28.0, width: 36.0, marginLeft: 8.0 }
371 , style: Style.style { height: 28.0, width: 36.0, marginLeft: 8.0 }
373 }
372 }
374 ]
373 ]
example-macos/src/Demo/InputControls.purs+2−2
@@ -52,13 +52,13 @@ buttonDemo = component "ButtonDemo" \dp -> React.do
52 { title: "Say Hello"
52 { title: "Say Hello"
53 , bezelStyle: T.push
53 , bezelStyle: T.push
54 , primary: true
54 , primary: true
55− , onPress: handler_ (setStatus "Hello from PureScript!")
55+ , onPress: setStatus "Hello from PureScript!"
56 , style: Style.style { height: 24.0, width: 140.0 }
56 , style: Style.style { height: 24.0, width: 140.0 }
57 }
57 }
58 , nativeButton
58 , nativeButton
59 { title: "Reset"
59 { title: "Reset"
60 , bezelStyle: T.push
60 , bezelStyle: T.push
61− , onPress: handler_ (setStatus "Ready")
61+ , onPress: setStatus "Ready"
62 , style: Style.style { height: 24.0, width: 100.0, marginLeft: 8.0 }
62 , style: Style.style { height: 24.0, width: 100.0, marginLeft: 8.0 }
63 }
63 }
64 , label dp.dimFg status
64 , label dp.dimFg status
example-macos/src/Demo/Overlays.purs+14−16
@@ -33,7 +33,7 @@ alertDemo = component "AlertDemo" \dp -> pure do
33 , nativeButton
33 , nativeButton
34 { title: "Show Alert"
34 { title: "Show Alert"
35 , bezelStyle: T.push
35 , bezelStyle: T.push
36− , onPress: handler_ (macosAlert { style: T.warning, title: "Are you sure?", message: "This action cannot be undone.", buttons: [ "Cancel", "OK" ] })
36+ , onPress: macosAlert { style: T.warning, title: "Are you sure?", message: "This action cannot be undone.", buttons: [ "Cancel", "OK" ] }
37 , style: Style.style { height: 24.0, width: 120.0 } <> tw "mb-4"
37 , style: Style.style { height: 24.0, width: 120.0 } <> tw "mb-4"
38 }
38 }
39 ]
39 ]
@@ -48,7 +48,7 @@ sheetDemo = component "SheetDemo" \dp -> React.do
48 , nativeButton
48 , nativeButton
49 { title: "Show Sheet"
49 { title: "Show Sheet"
50 , bezelStyle: T.push
50 , bezelStyle: T.push
51− , onPress: handler_ (setVisible true)
51+ , onPress: setVisible true
52 , style: Style.style { height: 24.0, width: 120.0 } <> tw "mb-2"
52 , style: Style.style { height: 24.0, width: 120.0 } <> tw "mb-2"
53 }
53 }
54 , nativeSheet
54 , nativeSheet
@@ -61,7 +61,7 @@ sheetDemo = component "SheetDemo" \dp -> React.do
61 , nativeButton
61 , nativeButton
62 { title: "Dismiss"
62 { title: "Dismiss"
63 , bezelStyle: T.push
63 , bezelStyle: T.push
64− , onPress: handler_ (setVisible false)
64+ , onPress: setVisible false
65 , style: Style.style { height: 24.0, width: 100.0 }
65 , style: Style.style { height: 24.0, width: 100.0 }
66 }
66 }
67 ]
67 ]
@@ -85,7 +85,7 @@ popoverDemo = component "PopoverDemo" \dp -> React.do
85 [ nativeButton
85 [ nativeButton
86 { title: if visible then "Hide Popover" else "Show Popover"
86 { title: if visible then "Hide Popover" else "Show Popover"
87 , bezelStyle: T.push
87 , bezelStyle: T.push
88− , onPress: handler_ (setVisible (not visible))
88+ , onPress: setVisible (not visible)
89 , style: Style.style { height: 24.0, width: 140.0 }
89 , style: Style.style { height: 24.0, width: 140.0 }
90 }
90 }
91 , view { style: tw "p-4" <> Style.style { width: 200.0, height: 80.0 } }
91 , view { style: tw "p-4" <> Style.style { width: 200.0, height: 80.0 } }
@@ -135,18 +135,16 @@ menuDemo = component "MenuDemo" \dp -> React.do
135 [ nativeButton
135 [ nativeButton
136 { title: "Show Menu"
136 { title: "Show Menu"
137 , bezelStyle: T.push
137 , bezelStyle: T.push
138− , onPress: handler_
139− ( macosShowMenu
138+ , onPress: macosShowMenu
140− { items:
139+ { items:
141− [ { title: "New File", id: "new" }
140+ [ { title: "New File", id: "new" }
142− , { title: "Open...", id: "open" }
141+ , { title: "Open...", id: "open" }
143− , { title: "-", id: "sep" }
142+ , { title: "-", id: "sep" }
144− , { title: "Save", id: "save" }
143+ , { title: "Save", id: "save" }
145− , { title: "Save As...", id: "saveAs" }
144+ , { title: "Save As...", id: "saveAs" }
146− ]
145+ ]
147− , onSelectItem: \itemId -> setResult ("Menu: " <> itemId)
146+ , onSelectItem: \itemId -> setResult ("Menu: " <> itemId)
148− }
147+ }
149− )
150 , style: Style.style { height: 24.0, width: 120.0 }
148 , style: Style.style { height: 24.0, width: 120.0 }
151 }
149 }
152 , if result == "" then mempty
150 , if result == "" then mempty
example-macos/src/Demo/SystemServices.purs+27−29
@@ -14,14 +14,13 @@ import Prelude
14
14
15import Demo.Shared (DemoProps, desc, scrollWrap, sectionTitle)
15import Demo.Shared (DemoProps, desc, scrollWrap, sectionTitle)
16import React.Basic (JSX)
16import React.Basic (JSX)
17−import React.Basic.Events (handler_)
17+
18import React.Basic.Hooks (useState', (/\))
18import React.Basic.Hooks (useState', (/\))
19import React.Basic.Hooks as React
19import React.Basic.Hooks as React
20import Yoga.React (component)
20import Yoga.React (component)
21import Yoga.React.Native (tw, view)
21import Yoga.React.Native (tw, view)
22import Yoga.React.Native.MacOS.Button (nativeButton)
22import Yoga.React.Native.MacOS.Button (nativeButton)
23import Yoga.React.Native.MacOS.ColorPanel (macosShowColorPanel)
23import Yoga.React.Native.MacOS.ColorPanel (macosShowColorPanel)
24−import Yoga.React.Native.MacOS.Events as E
25import Yoga.React.Native.MacOS.FontPanel (macosShowFontPanel)
24import Yoga.React.Native.MacOS.FontPanel (macosShowFontPanel)
26import Yoga.React.Native.MacOS.Pasteboard (copyToClipboard)
25import Yoga.React.Native.MacOS.Pasteboard (copyToClipboard)
27import Yoga.React.Native.MacOS.QuickLook (macosQuickLook)
26import Yoga.React.Native.MacOS.QuickLook (macosQuickLook)
@@ -43,7 +42,7 @@ clipboardDemo = component "ClipboardDemo" \dp -> pure do
43 [ nativeButton
42 [ nativeButton
44 { title: "Copy 'Hello'"
43 { title: "Copy 'Hello'"
45 , bezelStyle: T.push
44 , bezelStyle: T.push
46− , onPress: handler_ (copyToClipboard "Hello from PureScript!")
45+ , onPress: copyToClipboard "Hello from PureScript!"
47 , style: Style.style { height: 24.0, width: 120.0 }
46 , style: Style.style { height: 24.0, width: 120.0 }
48 }
47 }
49 ]
48 ]
@@ -57,7 +56,7 @@ shareDemo = component "ShareDemo" \dp -> pure do
57 , nativeButton
56 , nativeButton
58 { title: "Share Text"
57 { title: "Share Text"
59 , bezelStyle: T.push
58 , bezelStyle: T.push
60− , onPress: handler_ (macosShare [ "Hello from PureScript React Native!" ])
59+ , onPress: macosShare [ "Hello from PureScript React Native!" ]
61 , style: Style.style { height: 24.0, width: 120.0 } <> tw "mb-2"
60 , style: Style.style { height: 24.0, width: 120.0 } <> tw "mb-2"
62 }
61 }
63 ]
62 ]
@@ -70,7 +69,7 @@ notificationsDemo = component "NotificationsDemo" \dp -> pure do
70 , nativeButton
69 , nativeButton
71 { title: "Send Notification"
70 { title: "Send Notification"
72 , bezelStyle: T.push
71 , 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!" }
74 , style: Style.style { height: 24.0, width: 160.0 } <> tw "mb-2"
73 , style: Style.style { height: 24.0, width: 160.0 } <> tw "mb-2"
75 }
74 }
76 ]
75 ]
@@ -84,19 +83,19 @@ soundDemo = component "SoundDemo" \dp -> pure do
84 [ nativeButton
83 [ nativeButton
85 { title: "Glass"
84 { title: "Glass"
86 , bezelStyle: T.push
85 , bezelStyle: T.push
87− , onPress: handler_ (macosPlaySound "Glass")
86+ , onPress: macosPlaySound "Glass"
88 , style: Style.style { height: 24.0, width: 80.0 }
87 , style: Style.style { height: 24.0, width: 80.0 }
89 }
88 }
90 , nativeButton
89 , nativeButton
91 { title: "Ping"
90 { title: "Ping"
92 , bezelStyle: T.push
91 , bezelStyle: T.push
93− , onPress: handler_ (macosPlaySound "Ping")
92+ , onPress: macosPlaySound "Ping"
94 , style: Style.style { height: 24.0, width: 80.0, marginLeft: 8.0 }
93 , style: Style.style { height: 24.0, width: 80.0, marginLeft: 8.0 }
95 }
94 }
96 , nativeButton
95 , nativeButton
97 { title: "Beep"
96 { title: "Beep"
98 , bezelStyle: T.push
97 , bezelStyle: T.push
99− , onPress: handler_ macosBeep
98+ , onPress: macosBeep
100 , style: Style.style { height: 24.0, width: 80.0, marginLeft: 8.0 }
99 , style: Style.style { height: 24.0, width: 80.0, marginLeft: 8.0 }
101 }
100 }
102 ]
101 ]
@@ -113,22 +112,21 @@ statusBarDemo = component "StatusBarDemo" \dp -> React.do
113 [ nativeButton
112 [ nativeButton
114 { title: if active then "Remove" else "Add to Menu Bar"
113 { title: if active then "Remove" else "Add to Menu Bar"
115 , bezelStyle: T.push
114 , bezelStyle: T.push
116− , onPress: handler_
115+ , onPress:
117− ( if active then do
116+ if active then do
118− macosRemoveStatusBarItem
117+ macosRemoveStatusBarItem
119− setActive false
118+ setActive false
120− else do
119+ else do
121− macosSetStatusBarItem
120+ macosSetStatusBarItem
122− { title: ""
121+ { title: ""
123− , sfSymbol: "swift"
122+ , sfSymbol: "swift"
124− , menuItems:
123+ , menuItems:
125− [ { id: "about", title: "About PureScript RN" }
124+ [ { id: "about", title: "About PureScript RN" }
126− , { id: "sep", title: "-" }
125+ , { id: "sep", title: "-" }
127− , { id: "quit", title: "Quit" }
126+ , { id: "quit", title: "Quit" }
128− ]
127+ ]
129− }
128+ }
130− setActive true
129+ setActive true
131− )
132 , style: Style.style { height: 24.0, width: 180.0 }
130 , style: Style.style { height: 24.0, width: 180.0 }
133 }
131 }
134 ]
132 ]
@@ -143,7 +141,7 @@ quickLookDemo = component "QuickLookDemo" \dp -> pure do
143 [ nativeButton
141 [ nativeButton
144 { title: "Preview /etc/hosts"
142 { title: "Preview /etc/hosts"
145 , bezelStyle: T.push
143 , bezelStyle: T.push
146− , onPress: handler_ (macosQuickLook "/etc/hosts")
144+ , onPress: macosQuickLook "/etc/hosts"
147 , style: Style.style { height: 24.0, width: 180.0 }
145 , style: Style.style { height: 24.0, width: 180.0 }
148 }
146 }
149 ]
147 ]
@@ -158,7 +156,7 @@ colorPanelDemo = component "ColorPanelDemo" \dp -> pure do
158 [ nativeButton
156 [ nativeButton
159 { title: "Show Color Panel"
157 { title: "Show Color Panel"
160 , bezelStyle: T.push
158 , bezelStyle: T.push
161− , onPress: handler_ macosShowColorPanel
159+ , onPress: macosShowColorPanel
162 , style: Style.style { height: 24.0, width: 180.0 }
160 , style: Style.style { height: 24.0, width: 180.0 }
163 }
161 }
164 ]
162 ]
@@ -173,7 +171,7 @@ fontPanelDemo = component "FontPanelDemo" \dp -> pure do
173 [ nativeButton
171 [ nativeButton
174 { title: "Show Font Panel"
172 { title: "Show Font Panel"
175 , bezelStyle: T.push
173 , bezelStyle: T.push
176− , onPress: handler_ macosShowFontPanel
174+ , onPress: macosShowFontPanel
177 , style: Style.style { height: 24.0, width: 180.0 }
175 , style: Style.style { height: 24.0, width: 180.0 }
178 }
176 }
179 ]
177 ]
@@ -196,13 +194,13 @@ speechDemo = component "SpeechDemo" \dp -> React.do
196 [ nativeButton
194 [ nativeButton
197 { title: "Speak"
195 { title: "Speak"
198 , bezelStyle: T.push
196 , bezelStyle: T.push
199− , onPress: handler_ (say txt)
197+ , onPress: say txt
200 , style: Style.style { height: 24.0, width: 100.0 }
198 , style: Style.style { height: 24.0, width: 100.0 }
201 }
199 }
202 , nativeButton
200 , nativeButton
203 { title: "Stop"
201 { title: "Stop"
204 , bezelStyle: T.push
202 , bezelStyle: T.push
205− , onPress: handler_ stopSpeaking
203+ , onPress: stopSpeaking
206 , style: Style.style { height: 24.0, width: 100.0, marginLeft: 8.0 }
204 , style: Style.style { height: 24.0, width: 100.0, marginLeft: 8.0 }
207 }
205 }
208 ]
206 ]
example-macos/src/Demo/TextEditing.purs−1
@@ -8,7 +8,6 @@ import React.Basic.Hooks (useState', (/\))
8import React.Basic.Hooks as React
8import React.Basic.Hooks as React
9import Yoga.React (component)
9import Yoga.React (component)
10import Yoga.React.Native (tw, view)
10import Yoga.React.Native (tw, view)
11−import Yoga.React.Native.MacOS.Events as E
12import Yoga.React.Native.MacOS.TextField (nativeTextField)
11import Yoga.React.Native.MacOS.TextField (nativeTextField)
13import Yoga.React.Native.MacOS.TextEditor (nativeTextEditor)
12import Yoga.React.Native.MacOS.TextEditor (nativeTextEditor)
14import Yoga.React.Native.Style as Style
13import Yoga.React.Native.Style as Style
src/Yoga/React/Native/MacOS/Alert.purs+2−1
@@ -8,6 +8,7 @@ import Prelude
8import Effect (Effect)
8import Effect (Effect)
9import Effect.Uncurried (EffectFn1, runEffectFn1)
9import Effect.Uncurried (EffectFn1, runEffectFn1)
10import Prim.Row (class Union)
10import Prim.Row (class Union)
11+import Unsafe.Coerce (unsafeCoerce)
11import Yoga.React.Native.MacOS.Types (AlertStyle)
12import Yoga.React.Native.MacOS.Types (AlertStyle)
12
13
13type AlertProps =
14type AlertProps =
@@ -24,4 +25,4 @@ macosAlert
24 . Union given missing AlertProps
25 . Union given missing AlertProps
25 => { | given }
26 => { | given }
26 -> Effect Unit
27 -> Effect Unit
27−macosAlert = runEffectFn1 alertImpl
28+macosAlert r = runEffectFn1 alertImpl (unsafeCoerce r)
src/Yoga/React/Native/MacOS/Button.js+9−1
@@ -1,2 +1,10 @@
1+import React from "react";
1import { requireNativeComponent } from "react-native";
2import { requireNativeComponent } from "react-native";
3+const NativeButton = requireNativeComponent("NativeButton");
2−export const buttonImpl = requireNativeComponent("NativeButton");
4+export const buttonImpl = React.forwardRef((props, ref) => {
5+ const nativeProps = { ...props };
6+ if (typeof props.onPress === "function") {
7+ nativeProps.onPress = () => props.onPress();
8+ }
9+ return React.createElement(NativeButton, { ...nativeProps, ref });
10+});
src/Yoga/React/Native/MacOS/Button.purs+3−2
@@ -1,7 +1,8 @@
1module Yoga.React.Native.MacOS.Button (nativeButton, NativeButtonAttributes) where
1module Yoga.React.Native.MacOS.Button (nativeButton, NativeButtonAttributes) where
2
2
3+import Prelude
4+import Effect (Effect)
3import React.Basic (ReactComponent)
5import React.Basic (ReactComponent)
4−import React.Basic.Events (EventHandler)
5import Yoga.React.Native.Attributes (BaseAttributes)
6import Yoga.React.Native.Attributes (BaseAttributes)
6import Yoga.React.Native.Internal (FFINativeComponent_, createNativeElement_)
7import Yoga.React.Native.Internal (FFINativeComponent_, createNativeElement_)
7import Yoga.React.Native.MacOS.Types (BezelStyle)
8import Yoga.React.Native.MacOS.Types (BezelStyle)
@@ -18,5 +19,5 @@ type NativeButtonAttributes = BaseAttributes
18 , destructive :: Boolean
19 , destructive :: Boolean
19 , primary :: Boolean
20 , primary :: Boolean
20 , buttonEnabled :: Boolean
21 , buttonEnabled :: Boolean
21− , onPress :: EventHandler
22+ , onPress :: Effect Unit
22 )
23 )
src/Yoga/React/Native/MacOS/HelpButton.js+9−1
@@ -1,2 +1,10 @@
1+import React from "react";
1import { requireNativeComponent } from "react-native";
2import { requireNativeComponent } from "react-native";
2−export const helpButtonImpl = requireNativeComponent("MacOSHelpButton");
3+const NativeHelpButton = requireNativeComponent("MacOSHelpButton");
4+export const helpButtonImpl = React.forwardRef((props, ref) => {
5+ const nativeProps = { ...props };
6+ if (typeof props.onPress === "function") {
7+ nativeProps.onPress = () => props.onPress();
8+ }
9+ return React.createElement(NativeHelpButton, { ...nativeProps, ref });
10+});
src/Yoga/React/Native/MacOS/HelpButton.purs+3−2
@@ -3,8 +3,9 @@ module Yoga.React.Native.MacOS.HelpButton
3 , NativeHelpButtonAttributes
3 , NativeHelpButtonAttributes
4 ) where
4 ) where
5
5
6+import Prelude
7+import Effect (Effect)
6import React.Basic (ReactComponent)
8import React.Basic (ReactComponent)
7−import React.Basic.Events (EventHandler)
8import Yoga.React.Native.Attributes (BaseAttributes)
9import Yoga.React.Native.Attributes (BaseAttributes)
9import Yoga.React.Native.Internal (FFINativeComponent_, createNativeElement_)
10import Yoga.React.Native.Internal (FFINativeComponent_, createNativeElement_)
10
11
@@ -14,5 +15,5 @@ nativeHelpButton :: FFINativeComponent_ NativeHelpButtonAttributes
14nativeHelpButton = createNativeElement_ helpButtonImpl
15nativeHelpButton = createNativeElement_ helpButtonImpl
15
16
16type NativeHelpButtonAttributes = BaseAttributes
17type NativeHelpButtonAttributes = BaseAttributes
17− ( onPress :: EventHandler
18+ ( onPress :: Effect Unit
18 )
19 )
src/Yoga/React/Native/MacOS/Slider.purs+1
@@ -1,5 +1,6 @@
1module Yoga.React.Native.MacOS.Slider (nativeSlider, NativeSliderAttributes) where
1module Yoga.React.Native.MacOS.Slider (nativeSlider, NativeSliderAttributes) where
2
2
3+import Prelude
3import Effect (Effect)
4import Effect (Effect)
4import React.Basic (ReactComponent)
5import React.Basic (ReactComponent)
5import Yoga.React.Native.Attributes (BaseAttributes)
6import Yoga.React.Native.Attributes (BaseAttributes)
src/Yoga/React/Native/MacOS/Switch.purs+1
@@ -1,5 +1,6 @@
1module Yoga.React.Native.MacOS.Switch (nativeSwitch, NativeSwitchAttributes) where
1module Yoga.React.Native.MacOS.Switch (nativeSwitch, NativeSwitchAttributes) where
2
2
3+import Prelude
3import Effect (Effect)
4import Effect (Effect)
4import React.Basic (ReactComponent)
5import React.Basic (ReactComponent)
5import Yoga.React.Native.Attributes (BaseAttributes)
6import Yoga.React.Native.Attributes (BaseAttributes)
src/Yoga/React/Native/MacOS/TextField.purs+1
@@ -1,5 +1,6 @@
1module Yoga.React.Native.MacOS.TextField (nativeTextField, NativeTextFieldAttributes) where
1module Yoga.React.Native.MacOS.TextField (nativeTextField, NativeTextFieldAttributes) where
2
2
3+import Prelude
3import Effect (Effect)
4import Effect (Effect)
4import React.Basic (ReactComponent)
5import React.Basic (ReactComponent)
5import Yoga.React.Native.Attributes (BaseAttributes)
6import Yoga.React.Native.Attributes (BaseAttributes)
src/Yoga/React/Native/MacOS/UserNotification.purs+2−1
@@ -8,6 +8,7 @@ import Prelude
8import Effect (Effect)
8import Effect (Effect)
9import Effect.Uncurried (EffectFn1, runEffectFn1)
9import Effect.Uncurried (EffectFn1, runEffectFn1)
10import Prim.Row (class Union)
10import Prim.Row (class Union)
11+import Unsafe.Coerce (unsafeCoerce)
11
12
12type NotifyProps =
13type NotifyProps =
13 ( title :: String
14 ( title :: String
@@ -21,4 +22,4 @@ macosNotify
21 . Union given missing NotifyProps
22 . Union given missing NotifyProps
22 => { | given }
23 => { | given }
23 -> Effect Unit
24 -> Effect Unit
24−macosNotify = runEffectFn1 notifyImpl
25+macosNotify r = runEffectFn1 notifyImpl (unsafeCoerce r)