Skip to content

Commit f993ed1

Browse files
committed
Apply TurboModule protocol code to RCTFocusZoneManager.mm
1 parent d909c6a commit f993ed1

3 files changed

Lines changed: 127 additions & 49 deletions

File tree

apps/fluent-tester/macos/Podfile.lock

Lines changed: 31 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,28 @@ PODS:
123123
- fmt (= 9.1.0)
124124
- glog
125125
- RCTDeprecation (0.74.37)
126+
- RCTFocusZone (0.22.1):
127+
- DoubleConversion
128+
- glog
129+
- RCT-Folly (= 2024.01.01.00)
130+
- RCTRequired
131+
- RCTTypeSafety
132+
- React
133+
- React-Codegen
134+
- React-Core
135+
- React-debug
136+
- React-Fabric
137+
- React-featureflags
138+
- React-graphics
139+
- React-ImageManager
140+
- React-jsi
141+
- React-NativeModulesApple
142+
- React-RCTFabric
143+
- React-rendererdebug
144+
- React-utils
145+
- ReactCommon/turbomodule/bridging
146+
- ReactCommon/turbomodule/core
147+
- Yoga
126148
- RCTRequired (0.74.37)
127149
- RCTTypeSafety (0.74.37):
128150
- FBLazyVector (= 0.74.37)
@@ -1237,7 +1259,6 @@ PODS:
12371259
- React-ImageManager
12381260
- React-jsi
12391261
- React-NativeModulesApple
1240-
- React-RCTAppDelegate
12411262
- React-RCTFabric
12421263
- React-rendererdebug
12431264
- React-utils
@@ -1249,48 +1270,7 @@ PODS:
12491270
- React-jsi
12501271
- ReactTestApp-Resources (1.0.0-dev)
12511272
- RNSVG (15.12.1):
1252-
- DoubleConversion
1253-
- glog
1254-
- RCT-Folly (= 2024.01.01.00)
1255-
- RCTRequired
1256-
- RCTTypeSafety
1257-
- React-Codegen
1258-
- React-Core
1259-
- React-debug
1260-
- React-Fabric
1261-
- React-featureflags
1262-
- React-graphics
1263-
- React-ImageManager
1264-
- React-jsi
1265-
- React-NativeModulesApple
1266-
- React-RCTFabric
1267-
- React-rendererdebug
1268-
- React-utils
1269-
- ReactCommon/turbomodule/bridging
1270-
- ReactCommon/turbomodule/core
1271-
- RNSVG/common (= 15.12.1)
1272-
- Yoga
1273-
- RNSVG/common (15.12.1):
1274-
- DoubleConversion
1275-
- glog
1276-
- RCT-Folly (= 2024.01.01.00)
1277-
- RCTRequired
1278-
- RCTTypeSafety
1279-
- React-Codegen
12801273
- React-Core
1281-
- React-debug
1282-
- React-Fabric
1283-
- React-featureflags
1284-
- React-graphics
1285-
- React-ImageManager
1286-
- React-jsi
1287-
- React-NativeModulesApple
1288-
- React-RCTFabric
1289-
- React-rendererdebug
1290-
- React-utils
1291-
- ReactCommon/turbomodule/bridging
1292-
- ReactCommon/turbomodule/core
1293-
- Yoga
12941274
- SocketRocket (0.7.0)
12951275
- Yoga (0.0.0)
12961276

@@ -1309,6 +1289,7 @@ DEPENDENCIES:
13091289
- RCT-Folly (from `../node_modules/react-native-macos/third-party-podspecs/RCT-Folly.podspec`)
13101290
- RCT-Folly/Fabric (from `../node_modules/react-native-macos/third-party-podspecs/RCT-Folly.podspec`)
13111291
- RCTDeprecation (from `../node_modules/react-native-macos/ReactApple/Libraries/RCTFoundation/RCTDeprecation`)
1292+
- "RCTFocusZone (from `../node_modules/@fluentui-react-native/focus-zone`)"
13121293
- RCTRequired (from `../node_modules/react-native-macos/Libraries/Required`)
13131294
- RCTTypeSafety (from `../node_modules/react-native-macos/Libraries/TypeSafety`)
13141295
- React (from `../node_modules/react-native-macos/`)
@@ -1325,7 +1306,6 @@ DEPENDENCIES:
13251306
- React-graphics (from `../node_modules/react-native-macos/ReactCommon/react/renderer/graphics`)
13261307
- React-ImageManager (from `../node_modules/react-native-macos/ReactCommon/react/renderer/imagemanager/platform/ios`)
13271308
- React-jsc (from `../node_modules/react-native-macos/ReactCommon/jsc`)
1328-
- React-jsc/Fabric (from `../node_modules/react-native-macos/ReactCommon/jsc`)
13291309
- React-jserrorhandler (from `../node_modules/react-native-macos/ReactCommon/jserrorhandler`)
13301310
- React-jsi (from `../node_modules/react-native-macos/ReactCommon/jsi`)
13311311
- React-jsiexecutor (from `../node_modules/react-native-macos/ReactCommon/jsiexecutor`)
@@ -1393,6 +1373,8 @@ EXTERNAL SOURCES:
13931373
:podspec: "../node_modules/react-native-macos/third-party-podspecs/RCT-Folly.podspec"
13941374
RCTDeprecation:
13951375
:path: "../node_modules/react-native-macos/ReactApple/Libraries/RCTFoundation/RCTDeprecation"
1376+
RCTFocusZone:
1377+
:path: "../node_modules/@fluentui-react-native/focus-zone"
13961378
RCTRequired:
13971379
:path: "../node_modules/react-native-macos/Libraries/Required"
13981380
RCTTypeSafety:
@@ -1500,7 +1482,7 @@ SPEC CHECKSUMS:
15001482
FBLazyVector: 5f17e32a39da9146ff32e90cff4e9ebd8b5c3b54
15011483
fmt: 03574da4b7ba40de39da59677ca66610ce8c4a02
15021484
FRNAvatar: 919ae3fc7d01eee287295360e543d1d2a0432673
1503-
FRNCallout: c7ed1c5ecb31a1b4448aa733366a155c8de4fa0d
1485+
FRNCallout: 54c1ba139dbe454ec473a7fcfb9041acdfeddf33
15041486
FRNCheckbox: 3e478c3229e3a41523a563f9d8e4db5c3bd821cc
15051487
FRNMenuButton: 1cdaadd041da62cefba6d095b2a09caac99f38c7
15061488
FRNRadioButton: e0dabd91fb4bd361aa7c0b69b2bd293097bfb8b9
@@ -1509,6 +1491,7 @@ SPEC CHECKSUMS:
15091491
MicrosoftFluentUI: dde98d8ed3fc306d9ddd0a6f0bc0c1f24fe5275e
15101492
RCT-Folly: f47da9a444aae485a0528b3bccf0336156009d60
15111493
RCTDeprecation: 88f29fc8fbe38e5bff2e65223eac24450ade59ab
1494+
RCTFocusZone: 65eced20dcd7550929acd6750c7cae9783b4b68c
15121495
RCTRequired: 2736889bc024f33cd9157e06e092ee59848e7f45
15131496
RCTTypeSafety: c6f4b53a571b819ef18b3d8c5fa7f57d588102c6
15141497
React: 9ddfaba3bb7d30eb3c23b043443543b3b9db8b04
@@ -1536,9 +1519,9 @@ SPEC CHECKSUMS:
15361519
React-perflogger: cef2a86147e47618221ca9ad91c198f675235fc1
15371520
React-RCTActionSheet: 13f69488b22244acbdab4e8548b8a4e61f1aabbe
15381521
React-RCTAnimation: 96868c0a419ebf7b8e886b3bf8efd394baed6490
1539-
React-RCTAppDelegate: a01ee08e25c21519053fba7a25c644035ae38ff5
1522+
React-RCTAppDelegate: b8238819e2630a61141604dbe773a16575262a04
15401523
React-RCTBlob: 514e3899c53a76e3a12b66559172f6a6f8ccb0bf
1541-
React-RCTFabric: f07387b7d811074d6158e442cdd742bb8746f3b7
1524+
React-RCTFabric: 6f3ce25f14016ba7f75afc197dfc102e6dc4473d
15421525
React-RCTImage: 782aae7a46ccbad58f552cc92fb9379bf5a4a9f6
15431526
React-RCTLinking: 8468aad3a18280b15c8577e99c09779652935be3
15441527
React-RCTNetwork: 71c5168cfba4ee643890a7ee65db39c8184efd62
@@ -1553,10 +1536,10 @@ SPEC CHECKSUMS:
15531536
React-runtimescheduler: 259cc660010f02d35aa4675e448c194667cdafd2
15541537
React-utils: c1a7c0646cbd13a6578fdbbbfb8caca3f3d5cafe
15551538
ReactCommon: cf91cce7c7039e8a2275be58b63d5cb594c903e2
1556-
ReactNativeHost: 14d32b5744845626e6130e4d3783d3f9cd35d916
1539+
ReactNativeHost: 4296c5d13fdcafb9cb53f2f3b6ab5e427ab9a6dd
15571540
ReactTestApp-DevSupport: 52ac76197e5accf579592aa3b9aa07fd0766f211
15581541
ReactTestApp-Resources: 3c8739a3e3ed26f67f8ab68f13102fb9591301c8
1559-
RNSVG: ff30780ea0baf37801950b68a570c7102208b0e9
1542+
RNSVG: d39a9be65c439dfb061955f7615f1f71a51ecede
15601543
SocketRocket: f6c6249082c011e6de2de60ed641ef8bbe0cfac9
15611544
Yoga: 739f555df208b5fcd997a3b63e74791e27a12f34
15621545

packages/components/FocusZone/macos/RCTFocusZoneManager.mm

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,98 @@ - (RCTView *)view
5656
}
5757

5858
@end
59+
60+
#ifdef RCT_NEW_ARCH_ENABLED
61+
62+
#include <react/renderer/components/RCTFocusZoneSpec/ComponentDescriptors.h>
63+
#include <react/renderer/components/RCTFocusZoneSpec/Props.h>
64+
#include <react/renderer/components/RCTFocusZoneSpec/RCTComponentViewHelpers.h>
65+
66+
#import <React/RCTFabricComponentsPlugins.h>
67+
68+
using namespace facebook::react;
69+
70+
@interface FocusZoneComponentView : RCTViewComponentView
71+
@end
72+
73+
@implementation FocusZoneComponentView {
74+
RCTFocusZone *_focusZoneView;
75+
}
76+
77+
+ (ComponentDescriptorProvider)componentDescriptorProvider
78+
{
79+
return concreteComponentDescriptorProvider<RCTFocusZoneComponentDescriptor>();
80+
}
81+
82+
- (instancetype)initWithFrame:(CGRect)frame
83+
{
84+
if (self = [super initWithFrame:frame]) {
85+
_focusZoneView = [RCTFocusZone new];
86+
self.contentView = _focusZoneView;
87+
}
88+
return self;
89+
}
90+
91+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
92+
{
93+
const auto &newProps = static_cast<const RCTFocusZoneProps &>(*props);
94+
95+
_focusZoneView.disabled = newProps.disabled;
96+
_focusZoneView.navigationOrderInRenderOrder = newProps.navigationOrderInRenderOrder;
97+
98+
switch (newProps.navigateAtEnd) {
99+
case RCTFocusZoneNavigateAtEnd::NavigateWrap:
100+
_focusZoneView.navigateAtEnd = @"NavigateWrap";
101+
break;
102+
case RCTFocusZoneNavigateAtEnd::NavigateContinue:
103+
_focusZoneView.navigateAtEnd = @"NavigateContinue";
104+
break;
105+
case RCTFocusZoneNavigateAtEnd::NavigateStopAtEnds:
106+
_focusZoneView.navigateAtEnd = @"NavigateStopAtEnds";
107+
break;
108+
}
109+
110+
switch (newProps.focusZoneDirection) {
111+
case RCTFocusZoneFocusZoneDirection::Bidirectional:
112+
_focusZoneView.focusZoneDirection = FocusZoneDirectionBidirectional;
113+
break;
114+
case RCTFocusZoneFocusZoneDirection::Vertical:
115+
_focusZoneView.focusZoneDirection = FocusZoneDirectionVertical;
116+
break;
117+
case RCTFocusZoneFocusZoneDirection::Horizontal:
118+
_focusZoneView.focusZoneDirection = FocusZoneDirectionHorizontal;
119+
break;
120+
case RCTFocusZoneFocusZoneDirection::None:
121+
_focusZoneView.focusZoneDirection = FocusZoneDirectionNone;
122+
break;
123+
}
124+
125+
switch (newProps.tabKeyNavigation) {
126+
case RCTFocusZoneTabKeyNavigation::None:
127+
_focusZoneView.tabKeyNavigation = @"None";
128+
break;
129+
case RCTFocusZoneTabKeyNavigation::NavigateWrap:
130+
_focusZoneView.tabKeyNavigation = @"NavigateWrap";
131+
break;
132+
case RCTFocusZoneTabKeyNavigation::NavigateStopAtEnds:
133+
_focusZoneView.tabKeyNavigation = @"NavigateStopAtEnds";
134+
break;
135+
case RCTFocusZoneTabKeyNavigation::Normal:
136+
_focusZoneView.tabKeyNavigation = @"Normal";
137+
break;
138+
}
139+
140+
// defaultTabbableElement is not handled here: resolving a view by React tag
141+
// requires the legacy UIManager and is not supported in the Fabric renderer.
142+
143+
[super updateProps:props oldProps:oldProps];
144+
}
145+
146+
@end
147+
148+
Class<RCTComponentViewProtocol> RCTFocusZoneCls(void)
149+
{
150+
return FocusZoneComponentView.class;
151+
}
152+
153+
#endif // RCT_NEW_ARCH_ENABLED

packages/components/FocusZone/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"codegenConfig": {
8686
"name": "RCTFocusZoneSpec",
8787
"type": "components",
88-
"jsSrcsDir": "lib"
88+
"jsSrcsDir": "src"
8989
},
9090
"rnx-kit": {
9191
"kitType": "library",

0 commit comments

Comments
 (0)