|
16 | 16 | @implementation RCTDeviceInfo {
|
17 | 17 | #if !TARGET_OS_TV
|
18 | 18 | UIInterfaceOrientation _currentInterfaceOrientation;
|
| 19 | + NSDictionary *_currentInterfaceDimensions; |
19 | 20 | #endif
|
20 | 21 | }
|
21 | 22 |
|
@@ -48,6 +49,13 @@ - (void)setBridge:(RCTBridge *)bridge
|
48 | 49 | selector:@selector(interfaceOrientationDidChange)
|
49 | 50 | name:UIApplicationDidChangeStatusBarOrientationNotification
|
50 | 51 | object:nil];
|
| 52 | + |
| 53 | + _currentInterfaceDimensions = RCTExportedDimensions(_bridge); |
| 54 | + |
| 55 | + [[NSNotificationCenter defaultCenter] addObserver:self |
| 56 | + selector:@selector(interfaceFrameDidChange) |
| 57 | + name:UIApplicationDidBecomeActiveNotification |
| 58 | + object:nil]; |
51 | 59 | #endif
|
52 | 60 | }
|
53 | 61 |
|
@@ -160,6 +168,31 @@ - (void)_interfaceOrientationDidChange
|
160 | 168 | _currentInterfaceOrientation = nextOrientation;
|
161 | 169 | }
|
162 | 170 |
|
| 171 | + |
| 172 | +- (void)interfaceFrameDidChange |
| 173 | +{ |
| 174 | + __weak typeof(self) weakSelf = self; |
| 175 | + RCTExecuteOnMainQueue(^{ |
| 176 | + [weakSelf _interfaceFrameDidChange]; |
| 177 | + }); |
| 178 | +} |
| 179 | + |
| 180 | + |
| 181 | +- (void)_interfaceFrameDidChange |
| 182 | +{ |
| 183 | + NSDictionary *nextInterfaceDimensions = RCTExportedDimensions(_bridge); |
| 184 | + |
| 185 | + if (!([nextInterfaceDimensions isEqual:_currentInterfaceDimensions])) { |
| 186 | +#pragma clang diagnostic push |
| 187 | +#pragma clang diagnostic ignored "-Wdeprecated-declarations" |
| 188 | + [_bridge.eventDispatcher sendDeviceEventWithName:@"didUpdateDimensions" |
| 189 | + body:RCTExportedDimensions(_bridge)]; |
| 190 | +#pragma clang diagnostic pop |
| 191 | + } |
| 192 | + |
| 193 | + _currentInterfaceDimensions = nextInterfaceDimensions; |
| 194 | +} |
| 195 | + |
163 | 196 | #endif // TARGET_OS_TV
|
164 | 197 |
|
165 | 198 |
|
|
0 commit comments