git.iko.soy/rowtype-yoga/purescript-yoga-react-native
on main help sign in
WIP: React Native bindings development
commita41f350af63f8d78d6a0e188d1dc5878634d88a8 authorMark <mark.eibes@gmail.com> dateMon 16 Feb 2026, 23:02 (7 months ago) parent33fd463
6 files changed+30−10
example-macos/src/Demo/Display.purs+2−2 example-macos/src/Demo/InputControls.purs+2−2 src/Yoga/React/Native/MacOS/Slider.js+11−1 src/Yoga/React/Native/MacOS/Slider.purs+2−2 src/Yoga/React/Native/MacOS/Switch.js+11−1 src/Yoga/React/Native/MacOS/Switch.purs+2−2
example-macos/src/Demo/Display.purs+2−2
@@ -83,7 +83,7 @@ levelIndicatorDemo = component "LevelIndicatorDemo" \dp -> React.do
8383 , minValue: 0.0
8484 , maxValue: 100.0
8585 , numberOfTickMarks: 11
86− , onChange: E.onNumber "value" setValue
86+ , onChange: setValue
8787 , style: Style.style { height: 24.0 }
8888 }
8989 , nativeLevelIndicator
@@ -109,7 +109,7 @@ progressDemo = component "ProgressDemo" \dp -> React.do
109109 , minValue: 0.0
110110 , maxValue: 100.0
111111 , numberOfTickMarks: 11
112− , onChange: E.onNumber "value" setValue
112+ , onChange: setValue
113113 , style: Style.style { height: 24.0 }
114114 }
115115 , nativeProgress
example-macos/src/Demo/InputControls.purs+2−2
@@ -76,7 +76,7 @@ switchDemo = component "SwitchDemo" \dp -> React.do
7676 [ view { style: tw "flex-row items-center" }
7777 [ nativeSwitch
7878 { on
79− , onChange: E.onBool "on" setOn
79+ , onChange: setOn
8080 , style: Style.style { height: 24.0, width: 48.0 }
8181 }
8282 , label dp.dimFg (if on then "On" else "Off")
@@ -96,7 +96,7 @@ sliderDemo = component "SliderDemo" \dp -> React.do
9696 , minValue: 0.0
9797 , maxValue: 100.0
9898 , numberOfTickMarks: 11
99− , onChange: E.onNumber "value" setValue
99+ , onChange: setValue
100100 , style: Style.style { height: 24.0 }
101101 }
102102 , label dp.dimFg ("Value: " <> show (round value) <> " / 100")
src/Yoga/React/Native/MacOS/Slider.js+11−1
@@ -1,2 +1,12 @@
1+import React from "react";
12import { requireNativeComponent } from "react-native";
2−export const sliderImpl = requireNativeComponent("NativeSlider");
3+
4+const NativeSlider = requireNativeComponent("NativeSlider");
5+
6+export const sliderImpl = React.forwardRef((props, ref) => {
7+ const nativeProps = { ...props };
8+ if (typeof props.onChange === "function") {
9+ nativeProps.onChange = (e) => props.onChange(e.nativeEvent.value ?? 0)();
10+ }
11+ return React.createElement(NativeSlider, { ...nativeProps, ref });
12+});
src/Yoga/React/Native/MacOS/Slider.purs+2−2
@@ -1,7 +1,7 @@
11module Yoga.React.Native.MacOS.Slider (nativeSlider, NativeSliderAttributes) where
22
3+import Effect (Effect)
34import React.Basic (ReactComponent)
4−import React.Basic.Events (EventHandler)
55import Yoga.React.Native.Attributes (BaseAttributes)
66import Yoga.React.Native.Internal (FFINativeComponent_, createNativeElement_)
77
@@ -16,5 +16,5 @@ type NativeSliderAttributes = BaseAttributes
1616 , maxValue :: Number
1717 , numberOfTickMarks :: Int
1818 , allowsTickMarkValuesOnly :: Boolean
19− , onChange :: EventHandler
19+ , onChange :: Number -> Effect Unit
2020 )
src/Yoga/React/Native/MacOS/Switch.js+11−1
@@ -1,2 +1,12 @@
1+import React from "react";
12import { requireNativeComponent } from "react-native";
2−export const switchImpl = requireNativeComponent("NativeSwitch");
3+
4+const NativeSwitch = requireNativeComponent("NativeSwitch");
5+
6+export const switchImpl = React.forwardRef((props, ref) => {
7+ const nativeProps = { ...props };
8+ if (typeof props.onChange === "function") {
9+ nativeProps.onChange = (e) => props.onChange(!!e.nativeEvent.on)();
10+ }
11+ return React.createElement(NativeSwitch, { ...nativeProps, ref });
12+});
src/Yoga/React/Native/MacOS/Switch.purs+2−2
@@ -1,7 +1,7 @@
11module Yoga.React.Native.MacOS.Switch (nativeSwitch, NativeSwitchAttributes) where
22
3+import Effect (Effect)
34import React.Basic (ReactComponent)
4−import React.Basic.Events (EventHandler)
55import Yoga.React.Native.Attributes (BaseAttributes)
66import Yoga.React.Native.Internal (FFINativeComponent_, createNativeElement_)
77
@@ -12,5 +12,5 @@ nativeSwitch = createNativeElement_ switchImpl
1212
1313type NativeSwitchAttributes = BaseAttributes
1414 ( on :: Boolean
15− , onChange :: EventHandler
15+ , onChange :: Boolean -> Effect Unit
1616 )