Commit 7a72c35 1 parent 2e864c1 commit 7a72c35 Copy full SHA for 7a72c35
File tree 7 files changed +46
-30
lines changed
Surface/SurfaceHostingView
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 14
14
#import " RCTAssert.h"
15
15
#import " RCTBridge.h"
16
16
#import " RCTBridge+Private.h"
17
+ #import " RCTConstants.h"
17
18
#import " RCTEventDispatcher.h"
18
19
#import " RCTKeyCommands.h"
19
20
#import " RCTLog.h"
33
34
#endif
34
35
35
36
NSString *const RCTContentDidAppearNotification = @" RCTContentDidAppearNotification" ;
36
- static NSString *const RCTUserInterfaceStyleDidChangeNotification = @" RCTUserInterfaceStyleDidChangeNotification" ;
37
37
38
38
@interface RCTUIManager (RCTRootView)
39
39
@@ -367,21 +367,16 @@ - (void)contentViewInvalidated
367
367
[self showLoadingView ];
368
368
}
369
369
370
- #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
371
- __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
372
370
- (void )traitCollectionDidChange : (UITraitCollection *)previousTraitCollection
373
371
{
374
372
[super traitCollectionDidChange: previousTraitCollection];
375
373
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
+ }];
383
379
}
384
- #endif
385
380
386
381
- (void )dealloc
387
382
{
Original file line number Diff line number Diff line change 7
7
8
8
#import " RCTSurfaceHostingView.h"
9
9
10
+ #import " RCTConstants.h"
10
11
#import " RCTDefines.h"
11
12
#import " RCTSurface.h"
12
13
#import " RCTSurfaceDelegate.h"
13
14
#import " RCTSurfaceView.h"
14
15
#import " RCTUtils.h"
15
16
16
- static NSString *const RCTUserInterfaceStyleDidChangeNotification = @" RCTUserInterfaceStyleDidChangeNotification" ;
17
-
18
17
@interface RCTSurfaceHostingView ()
19
18
20
19
@property (nonatomic , assign ) BOOL isActivityIndicatorViewVisible;
@@ -208,21 +207,15 @@ - (void)setActivityIndicatorViewFactory:(RCTSurfaceHostingViewActivityIndicatorV
208
207
209
208
#pragma mark - UITraitCollection updates
210
209
211
- #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
212
- __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
213
210
- (void )traitCollectionDidChange : (UITraitCollection *)previousTraitCollection
214
211
{
215
212
[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
+ }];
224
218
}
225
- #endif
226
219
227
220
#pragma mark - Private stuff
228
221
Original file line number Diff line number Diff line change 12
12
13
13
RCT_EXTERN void RCTEnableAppearancePreference (BOOL enabled);
14
14
15
- NSString *const RCTUserInterfaceStyleDidChangeNotification = @" RCTUserInterfaceStyleDidChangeNotification" ;
16
-
17
15
@interface RCTAppearance : RCTEventEmitter <RCTBridgeModule>
18
16
@end
Original file line number Diff line number Diff line change 8
8
#import " RCTAppearance.h"
9
9
10
10
#import < FBReactNativeSpec/FBReactNativeSpec.h>
11
+ #import < React/RCTConstants.h>
11
12
#import < React/RCTEventEmitter.h>
12
13
13
14
#import " CoreModulesPlugins.h"
@@ -86,7 +87,7 @@ - (void)appearanceChanged:(NSNotification *)notification
86
87
NSDictionary *userInfo = [notification userInfo ];
87
88
UITraitCollection *traitCollection = nil ;
88
89
if (userInfo) {
89
- traitCollection = userInfo[@" traitCollection " ];
90
+ traitCollection = userInfo[RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey ];
90
91
}
91
92
NSString *newColorScheme = RCTColorSchemePreference (traitCollection);
92
93
if (![_currentColorScheme isEqualToString: newColorScheme]) {
Original file line number Diff line number Diff line change 10
10
#import < FBReactNativeSpec/FBReactNativeSpec.h>
11
11
#import < React/RCTAccessibilityManager.h>
12
12
#import < React/RCTAssert.h>
13
+ #import < React/RCTConstants.h>
13
14
#import < React/RCTEventDispatcher.h>
14
15
#import < React/RCTUIUtils.h>
15
16
#import < React/RCTUtils.h>
@@ -61,9 +62,15 @@ - (void)setBridge:(RCTBridge *)bridge
61
62
_currentInterfaceDimensions = RCTExportedDimensions (_bridge);
62
63
63
64
[[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
+
67
74
#endif
68
75
}
69
76
You can’t perform that action at this time.
0 commit comments