git.iko.soy/rowtype-yoga/purescript-yoga-react-native
on main help sign in
WIP: React Native bindings development
commit401dc038f229782c553f2e246f0023e211f9262f authorMark <mark.eibes@gmail.com> dateMon 16 Feb 2026, 22:49 (7 months ago) parent286cdf2
4 files changed+35−16
docs/src/Docs/Pages/Overlays.purs+11−10 example-macos/src/Demo/Overlays.purs+1−1 src/Yoga/React/Native/MacOS/Alert.js+6−1 src/Yoga/React/Native/MacOS/Alert.purs+17−4
docs/src/Docs/Pages/Overlays.purs+11−10
@@ -19,16 +19,17 @@ page =
1919
2020alert :: Nut
2121alert = L.componentDoc "macosAlert" "Yoga.React.Native.MacOS.Alert (macosAlert)"
22− """-- Imperative function with 4 positional args
23−macosAlert T.critical "Delete file?" "This cannot be undone." ["Delete", "Cancel"]
24− # liftEffect"""
25− [ D.p [ DA.klass_ "text-sm text-gray-400 mt-2" ]
26− [ D.text_ "Signature: AlertStyle -> String -> String -> Array String -> Effect Unit" ]
27− , propsTable
28− [ { name: "arg 1", type_: "AlertStyle", description: "informational | warning | critical" }
29− , { name: "arg 2", type_: "String", description: "Alert title" }
30− , { name: "arg 3", type_: "String", description: "Alert message body" }
31− , { name: "arg 4", type_: "Array String", description: "Button labels (first is default)" }
22+ """macosAlert
23+ { style: T.critical
24+ , title: "Delete file?"
25+ , message: "This cannot be undone."
26+ , buttons: ["Delete", "Cancel"]
27+ }"""
28+ [ propsTable
29+ [ { name: "style", type_: "AlertStyle", description: "informational | warning | critical" }
30+ , { name: "title", type_: "String", description: "Alert title" }
31+ , { name: "message", type_: "String", description: "Alert message body" }
32+ , { name: "buttons", type_: "Array String", description: "Button labels (default: [\"OK\"])" }
3233 ]
3334 ]
3435
example-macos/src/Demo/Overlays.purs+1−1
@@ -33,7 +33,7 @@ alertDemo = component "AlertDemo" \dp -> pure do
3333 , nativeButton
3434 { title: "Show Alert"
3535 , bezelStyle: T.push
36− , onPress: handler_ (macosAlert T.warning "Are you sure?" "This action cannot be undone." [ "Cancel", "OK" ])
36+ , onPress: handler_ (macosAlert { style: T.warning, title: "Are you sure?", message: "This action cannot be undone.", buttons: [ "Cancel", "OK" ] })
3737 , style: Style.style { height: 24.0, width: 120.0 } <> tw "mb-4"
3838 }
3939 ]
src/Yoga/React/Native/MacOS/Alert.js+6−1
@@ -1,6 +1,11 @@
11import { NativeModules, Platform } from "react-native";
22
3−export const alertImpl = (style, title, message, buttons) => {
3+export const alertImpl = ({
4+ style = "warning",
5+ title = "",
6+ message = "",
7+ buttons = ["OK"],
8+}) => {
49 if (Platform.OS !== "macos") return;
510 const mod = NativeModules.MacOSAlertModule;
611 if (mod && mod.show) {
src/Yoga/React/Native/MacOS/Alert.purs+17−4
@@ -1,14 +1,27 @@
11module Yoga.React.Native.MacOS.Alert
22 ( macosAlert
3+ , AlertProps
34 ) where
45
56import Prelude
67
78import Effect (Effect)
8−import Effect.Uncurried (EffectFn4, runEffectFn4)
9+import Effect.Uncurried (EffectFn1, runEffectFn1)
10+import Prim.Row (class Union)
911import Yoga.React.Native.MacOS.Types (AlertStyle)
1012
11−foreign import alertImpl :: EffectFn4 AlertStyle String String (Array String) Unit
13+type AlertProps =
14+ ( style :: AlertStyle
15+ , title :: String
16+ , message :: String
17+ , buttons :: Array String
18+ )
1219
13−macosAlert :: AlertStyle -> String -> String -> Array String -> Effect Unit
14−macosAlert = runEffectFn4 alertImpl
20+foreign import alertImpl :: EffectFn1 (Record AlertProps) Unit
21+
22+macosAlert
23+ :: forall given missing
24+ . Union given missing AlertProps
25+ => { | given }
26+ -> Effect Unit
27+macosAlert = runEffectFn1 alertImpl