git.iko.soy/rowtype-yoga/purescript-yoga-react-native
on main help sign in
Disable RCTDevLoadingView to fix stuck reload progress bar
commitb78ebeb03aa35158cd049a5b1e189e3dbbde8d02 authorMark <mark.eibes@gmail.com> dateFri 13 Feb 2026, 23:23 (8 months ago) parent7a2b21f
8 files changed+68−14
example-macos/macos/YogaReactExample-macOS/AppDelegate.mm−2 example-macos/macos/YogaReactExample-macOS/RCTMacOSControlsManager.m+24−2 example-macos/macos/YogaReactExample-macOS/light_switch.riv example-macos/macos/YogaReactExample-macOS/rating_animation.riv example-macos/macos/YogaReactExample-macOS/switch_event_example.riv example-macos/macos/YogaReactExample.xcodeproj/project.pbxproj+12 example-macos/src/Main.purs+31−10 src/Yoga/React/Native/MacOS/Rive.purs+1
example-macos/macos/YogaReactExample-macOS/AppDelegate.mm−2
@@ -1,14 +1,12 @@
11#import "AppDelegate.h"
22
33#import <React/RCTBundleURLProvider.h>
4−#import <React/RCTDevLoadingViewSetEnabled.h>
54#import <ReactAppDependencyProvider/RCTAppDependencyProvider.h>
65
76@implementation AppDelegate
87
98- (void)applicationDidFinishLaunching:(NSNotification *)notification
109{
11− RCTDevLoadingViewSetEnabled(NO);
1210 self.moduleName = @"YogaReactExample";
1311 // You can add your custom initial props in the dictionary below.
1412 // They will be passed down to the ViewController used by React Native.
example-macos/macos/YogaReactExample-macOS/RCTMacOSControlsManager.m+24−2
@@ -871,6 +871,7 @@ RCT_EXPORT_MODULE(MacOSScrollView)
871871@property (nonatomic, copy) NSString *url;
872872@property (nonatomic, copy) NSString *stateMachineName;
873873@property (nonatomic, copy) NSString *artboardName;
874+@property (nonatomic, copy) NSString *fit;
874875@property (nonatomic, assign) BOOL autoplay;
875876@end
876877
@@ -879,10 +880,28 @@ RCT_EXPORT_MODULE(MacOSScrollView)
879880- (instancetype)initWithFrame:(NSRect)frame {
880881 if (self = [super initWithFrame:frame]) {
881882 _autoplay = YES;
883+ _fit = @"contain";
882884 }
883885 return self;
884886}
885887
888+- (enum RiveFit)parseFit {
889+ if ([_fit isEqualToString:@"cover"]) return cover;
890+ if ([_fit isEqualToString:@"fill"]) return fill;
891+ if ([_fit isEqualToString:@"fitWidth"]) return fitWidth;
892+ if ([_fit isEqualToString:@"fitHeight"]) return fitHeight;
893+ if ([_fit isEqualToString:@"scaleDown"]) return scaleDown;
894+ if ([_fit isEqualToString:@"noFit"]) return noFit;
895+ return contain;
896+}
897+
898+- (void)setFit:(NSString *)fit {
899+ if ([_fit isEqualToString:fit]) return;
900+ _fit = fit;
901+ if (_resourceName.length > 0) [self loadFromResource];
902+ else if (_url.length > 0) [self loadFromURL];
903+}
904+
886905- (void)setResourceName:(NSString *)resourceName {
887906 if ([_resourceName isEqualToString:resourceName]) return;
888907 _resourceName = resourceName;
@@ -904,12 +923,13 @@ RCT_EXPORT_MODULE(MacOSScrollView)
904923 BOOL ap = _autoplay;
905924 __weak typeof(self) weakSelf = self;
906925 dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
926+ enum RiveFit f = [weakSelf parseFit];
907927 RiveViewModel *vm = [[RiveViewModel alloc]
908928 initWithFileName:name
909929 extension:@"riv"
910930 in:[NSBundle mainBundle]
911931 stateMachineName:sm
912− fit:contain
932+ fit:f
913933 alignment:center
914934 autoPlay:ap
915935 artboardName:ab
@@ -933,10 +953,11 @@ RCT_EXPORT_MODULE(MacOSScrollView)
933953 BOOL ap = _autoplay;
934954 __weak typeof(self) weakSelf = self;
935955 dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
956+ enum RiveFit f = [weakSelf parseFit];
936957 RiveViewModel *vm = [[RiveViewModel alloc]
937958 initWithWebURL:u
938959 stateMachineName:sm
939− fit:contain
960+ fit:f
940961 alignment:center
941962 autoPlay:ap
942963 loadCdn:YES
@@ -986,4 +1007,5 @@ RCT_EXPORT_VIEW_PROPERTY(url, NSString)
9861007RCT_EXPORT_VIEW_PROPERTY(stateMachineName, NSString)
9871008RCT_EXPORT_VIEW_PROPERTY(artboardName, NSString)
9881009RCT_EXPORT_VIEW_PROPERTY(autoplay, BOOL)
1010+RCT_EXPORT_VIEW_PROPERTY(fit, NSString)
9891011@end
example-macos/macos/YogaReactExample-macOS/light_switch.rivnew file

Binary file not shown.

example-macos/macos/YogaReactExample-macOS/rating_animation.rivnew file

Binary file not shown.

example-macos/macos/YogaReactExample-macOS/switch_event_example.rivnew file

Binary file not shown.

example-macos/macos/YogaReactExample.xcodeproj/project.pbxproj+12
@@ -19,6 +19,9 @@
1919 BE70DEDEE32B54947FC49AFF /* libPods-YogaReactExample-macOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C3E14041CD325948C5922BE0 /* libPods-YogaReactExample-macOS.a */; };
2020 DEB487CCA36791EC34548205 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 2F264B867F71A9A4C58140DE /* PrivacyInfo.xcprivacy */; };
2121 BB0000012437B4B30078DB4F /* windy_tree.riv in Resources */ = {isa = PBXBuildFile; fileRef = BB0000002437B4B30078DB4F /* windy_tree.riv */; };
22+ BB0000032437B4B30078DB4F /* light_switch.riv in Resources */ = {isa = PBXBuildFile; fileRef = BB0000022437B4B30078DB4F /* light_switch.riv */; };
23+ BB0000052437B4B30078DB4F /* rating_animation.riv in Resources */ = {isa = PBXBuildFile; fileRef = BB0000042437B4B30078DB4F /* rating_animation.riv */; };
24+ BB0000072437B4B30078DB4F /* switch_event_example.riv in Resources */ = {isa = PBXBuildFile; fileRef = BB0000062437B4B30078DB4F /* switch_event_example.riv */; };
2225/* End PBXBuildFile section */
2326
2427/* Begin PBXFileReference section */
@@ -41,6 +44,9 @@
4144 C3E14041CD325948C5922BE0 /* libPods-YogaReactExample-macOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-YogaReactExample-macOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
4245 ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
4346 BB0000002437B4B30078DB4F /* windy_tree.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = windy_tree.riv; sourceTree = "<group>"; };
47+ BB0000022437B4B30078DB4F /* light_switch.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = light_switch.riv; sourceTree = "<group>"; };
48+ BB0000042437B4B30078DB4F /* rating_animation.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = rating_animation.riv; sourceTree = "<group>"; };
49+ BB0000062437B4B30078DB4F /* switch_event_example.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = switch_event_example.riv; sourceTree = "<group>"; };
4450/* End PBXFileReference section */
4551
4652/* Begin PBXFrameworksBuildPhase section */
@@ -86,6 +92,9 @@
8692 AA0000042437B4B30078DB4F /* RCTNativeShowcaseManager.m */,
8793 AA0000062437B4B30078DB4F /* RCTMacOSControlsManager.m */,
8894 BB0000002437B4B30078DB4F /* windy_tree.riv */,
95+ BB0000022437B4B30078DB4F /* light_switch.riv */,
96+ BB0000042437B4B30078DB4F /* rating_animation.riv */,
97+ BB0000062437B4B30078DB4F /* switch_event_example.riv */,
8998 );
9099 path = "YogaReactExample-macOS";
91100 sourceTree = "<group>";
@@ -226,6 +235,9 @@
226235 514201552437B4B40078DB4F /* Main.storyboard in Resources */,
227236 DEB487CCA36791EC34548205 /* PrivacyInfo.xcprivacy in Resources */,
228237 BB0000012437B4B30078DB4F /* windy_tree.riv in Resources */,
238+ BB0000032437B4B30078DB4F /* light_switch.riv in Resources */,
239+ BB0000052437B4B30078DB4F /* rating_animation.riv in Resources */,
240+ BB0000072437B4B30078DB4F /* switch_event_example.riv in Resources */,
229241 );
230242 runOnlyForDeploymentPostprocessing = 0;
231243 };
example-macos/src/Main.purs+31−10
@@ -315,16 +315,37 @@ browserTab = component "BrowserTab" \p -> React.do
315315riveTab :: { fg :: String, bg :: String } -> JSX
316316riveTab = component "RiveTab" \p -> React.do
317317 pure do
318− view { style: tw "flex-1 px-4" }
319− [ sectionTitle p.fg "Rive Animation"
320− , text { style: tw "text-xs mb-2" <> Style.style { color: p.fg } }
321− "Windy Tree — loaded from app bundle via native RiveRuntime"
322− , nativeRiveView_
323− { resourceName: "windy_tree"
324− , autoplay: true
325− , style: tw "flex-1" <> Style.style { minHeight: 400.0, backgroundColor: p.bg }
326− }
327− ]
318+ nativeScrollView { style: tw "flex-1" <> Style.style { backgroundColor: "transparent" } }
319+ ( view { style: tw "px-4 pb-4" }
320+ [ sectionTitle p.fg "Interactive Rive Animations"
321+ , text { style: tw "text-xs mb-2" <> Style.style { color: p.fg } }
322+ "Click the stars to rate! State machine handles interaction."
323+ , nativeRiveView_
324+ { resourceName: "rating_animation"
325+ , stateMachineName: "State Machine 1"
326+ , fit: "contain"
327+ , autoplay: true
328+ , style: Style.style { height: 200.0 }
329+ }
330+ , sectionTitle p.fg "Light Switch"
331+ , text { style: tw "text-xs mb-2" <> Style.style { color: p.fg } }
332+ "Click to toggle"
333+ , nativeRiveView_
334+ { resourceName: "switch_event_example"
335+ , stateMachineName: "State Machine 1"
336+ , fit: "contain"
337+ , autoplay: true
338+ , style: Style.style { height: 200.0 }
339+ }
340+ , sectionTitle p.fg "Windy Tree"
341+ , nativeRiveView_
342+ { resourceName: "windy_tree"
343+ , fit: "cover"
344+ , autoplay: true
345+ , style: tw "flex-1" <> Style.style { minHeight: 300.0, backgroundColor: p.bg }
346+ }
347+ ]
348+ )
328349
329350-- UI helpers
330351sectionTitle :: String -> String -> JSX
src/Yoga/React/Native/MacOS/Rive.purs+1
@@ -17,5 +17,6 @@ type NativeRiveViewAttributes = BaseAttributes
1717 , url :: String
1818 , artboardName :: String
1919 , stateMachineName :: String
20+ , fit :: String
2021 , autoplay :: Boolean
2122 )