File tree Expand file tree Collapse file tree 7 files changed +46
-30
lines changed
Surface/SurfaceHostingView Expand file tree Collapse file tree 7 files changed +46
-30
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) Facebook, Inc. and its affiliates.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE file in the root directory of this source tree.
6+ */
7+
8+ #import < React/RCTDefines.h>
9+
10+ RCT_EXTERN NSString *const RCTUserInterfaceStyleDidChangeNotification;
11+ RCT_EXTERN NSString *const RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey;
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) Facebook, Inc. and its affiliates.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE file in the root directory of this source tree.
6+ */
7+
8+ #import " RCTConstants.h"
9+
10+ NSString *const RCTUserInterfaceStyleDidChangeNotification = @" RCTUserInterfaceStyleDidChangeNotification" ;
11+ NSString *const RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey = @" traitCollection" ;
Original file line number Diff line number Diff line change 1414#import " RCTAssert.h"
1515#import " RCTBridge.h"
1616#import " RCTBridge+Private.h"
17+ #import " RCTConstants.h"
1718#import " RCTEventDispatcher.h"
1819#import " RCTKeyCommands.h"
1920#import " RCTLog.h"
3334#endif
3435
3536NSString *const RCTContentDidAppearNotification = @" RCTContentDidAppearNotification" ;
36- static NSString *const RCTUserInterfaceStyleDidChangeNotification = @" RCTUserInterfaceStyleDidChangeNotification" ;
3737
3838@interface RCTUIManager (RCTRootView)
3939
@@ -367,21 +367,16 @@ - (void)contentViewInvalidated
367367 [self showLoadingView ];
368368}
369369
370- #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
371- __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
372370- (void )traitCollectionDidChange : (UITraitCollection *)previousTraitCollection
373371{
374372 [super traitCollectionDidChange: previousTraitCollection];
375373
376- if (@available (iOS 13.0 , *)) {
377- if ([previousTraitCollection hasDifferentColorAppearanceComparedToTraitCollection: self .traitCollection]) {
378- [[NSNotificationCenter defaultCenter ] postNotificationName: RCTUserInterfaceStyleDidChangeNotification
379- object: self
380- userInfo: @{@" traitCollection" : self.traitCollection }];
381- }
382- }
374+ [[NSNotificationCenter defaultCenter ] postNotificationName: RCTUserInterfaceStyleDidChangeNotification
375+ object: self
376+ userInfo: @{
377+ RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey: self.traitCollection ,
378+ }];
383379}
384- #endif
385380
386381- (void )dealloc
387382{
Original file line number Diff line number Diff line change 77
88#import " RCTSurfaceHostingView.h"
99
10+ #import " RCTConstants.h"
1011#import " RCTDefines.h"
1112#import " RCTSurface.h"
1213#import " RCTSurfaceDelegate.h"
1314#import " RCTSurfaceView.h"
1415#import " RCTUtils.h"
1516
16- static NSString *const RCTUserInterfaceStyleDidChangeNotification = @" RCTUserInterfaceStyleDidChangeNotification" ;
17-
1817@interface RCTSurfaceHostingView ()
1918
2019@property (nonatomic , assign ) BOOL isActivityIndicatorViewVisible;
@@ -208,21 +207,15 @@ - (void)setActivityIndicatorViewFactory:(RCTSurfaceHostingViewActivityIndicatorV
208207
209208#pragma mark - UITraitCollection updates
210209
211- #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
212- __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
213210- (void )traitCollectionDidChange : (UITraitCollection *)previousTraitCollection
214211{
215212 [super traitCollectionDidChange: previousTraitCollection];
216-
217- if (@available (iOS 13.0 , *)) {
218- if ([previousTraitCollection hasDifferentColorAppearanceComparedToTraitCollection: self .traitCollection]) {
219- [[NSNotificationCenter defaultCenter ] postNotificationName: RCTUserInterfaceStyleDidChangeNotification
220- object: self
221- userInfo: @{@" traitCollection" : self.traitCollection }];
222- }
223- }
213+ [[NSNotificationCenter defaultCenter ] postNotificationName: RCTUserInterfaceStyleDidChangeNotification
214+ object: self
215+ userInfo: @{
216+ RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey: self.traitCollection ,
217+ }];
224218}
225- #endif
226219
227220#pragma mark - Private stuff
228221
Original file line number Diff line number Diff line change 1212
1313RCT_EXTERN void RCTEnableAppearancePreference (BOOL enabled);
1414
15- NSString *const RCTUserInterfaceStyleDidChangeNotification = @" RCTUserInterfaceStyleDidChangeNotification" ;
16-
1715@interface RCTAppearance : RCTEventEmitter <RCTBridgeModule>
1816@end
Original file line number Diff line number Diff line change 88#import " RCTAppearance.h"
99
1010#import < FBReactNativeSpec/FBReactNativeSpec.h>
11+ #import < React/RCTConstants.h>
1112#import < React/RCTEventEmitter.h>
1213
1314#import " CoreModulesPlugins.h"
@@ -86,7 +87,7 @@ - (void)appearanceChanged:(NSNotification *)notification
8687 NSDictionary *userInfo = [notification userInfo ];
8788 UITraitCollection *traitCollection = nil ;
8889 if (userInfo) {
89- traitCollection = userInfo[@" traitCollection " ];
90+ traitCollection = userInfo[RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey ];
9091 }
9192 NSString *newColorScheme = RCTColorSchemePreference (traitCollection);
9293 if (![_currentColorScheme isEqualToString: newColorScheme]) {
Original file line number Diff line number Diff line change 1010#import < FBReactNativeSpec/FBReactNativeSpec.h>
1111#import < React/RCTAccessibilityManager.h>
1212#import < React/RCTAssert.h>
13+ #import < React/RCTConstants.h>
1314#import < React/RCTEventDispatcher.h>
1415#import < React/RCTUIUtils.h>
1516#import < React/RCTUtils.h>
@@ -61,9 +62,15 @@ - (void)setBridge:(RCTBridge *)bridge
6162 _currentInterfaceDimensions = RCTExportedDimensions (_bridge);
6263
6364 [[NSNotificationCenter defaultCenter ] addObserver: self
64- selector: @selector (interfaceFrameDidChange )
65- name: UIApplicationDidBecomeActiveNotification
66- object: nil ];
65+ selector: @selector (interfaceFrameDidChange )
66+ name: UIApplicationDidBecomeActiveNotification
67+ object: nil ];
68+
69+ [[NSNotificationCenter defaultCenter ] addObserver: self
70+ selector: @selector (interfaceFrameDidChange )
71+ name: RCTUserInterfaceStyleDidChangeNotification
72+ object: nil ];
73+
6774#endif
6875}
6976
You can’t perform that action at this time.
0 commit comments