mirror of
https://github.com/status-im/react-native.git
synced 2025-01-12 18:44:25 +00:00
Add Voice Over related change to AccessibilityManager.
Reviewed By: @hedgerwang Differential Revision: D2491520
This commit is contained in:
parent
626b551ff2
commit
8221c33650
@ -21,6 +21,8 @@ extern NSString *const RCTAccessibilityManagerDidUpdateMultiplierNotification; /
|
||||
/// map from UIKit categories to multipliers
|
||||
@property (nonatomic, copy) NSDictionary *multipliers;
|
||||
|
||||
@property (nonatomic, assign) BOOL isVoiceOverEnabled;
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTBridge (RCTAccessibilityManager)
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
#import "RCTAccessibilityManager.h"
|
||||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTEventDispatcher.h"
|
||||
#import "RCTLog.h"
|
||||
|
||||
NSString *const RCTAccessibilityManagerDidUpdateMultiplierNotification = @"RCTAccessibilityManagerDidUpdateMultiplierNotification";
|
||||
@ -24,6 +26,7 @@ NSString *const RCTAccessibilityManagerDidUpdateMultiplierNotification = @"RCTAc
|
||||
|
||||
@synthesize bridge = _bridge;
|
||||
@synthesize multipliers = _multipliers;
|
||||
@synthesize isVoiceOverEnabled = _isVoiceOverEnabled;
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
@ -61,7 +64,14 @@ RCT_EXPORT_MODULE()
|
||||
selector:@selector(didReceiveNewContentSizeCategory:)
|
||||
name:UIContentSizeCategoryDidChangeNotification
|
||||
object:[UIApplication sharedApplication]];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didReceiveNewVoiceOverStatus:)
|
||||
name:UIAccessibilityVoiceOverStatusChanged
|
||||
object:nil];
|
||||
|
||||
self.contentSizeCategory = [UIApplication sharedApplication].preferredContentSizeCategory;
|
||||
_isVoiceOverEnabled = UIAccessibilityIsVoiceOverRunning();
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -76,6 +86,16 @@ RCT_EXPORT_MODULE()
|
||||
self.contentSizeCategory = note.userInfo[UIContentSizeCategoryNewValueKey];
|
||||
}
|
||||
|
||||
- (void)didReceiveNewVoiceOverStatus:(NSNotification *)notification
|
||||
{
|
||||
BOOL newIsVoiceOverEnabled = UIAccessibilityIsVoiceOverRunning();
|
||||
if (_isVoiceOverEnabled != newIsVoiceOverEnabled) {
|
||||
_isVoiceOverEnabled = newIsVoiceOverEnabled;
|
||||
[_bridge.eventDispatcher sendDeviceEventWithName:@"voiceOverDidChange"
|
||||
body:@(_isVoiceOverEnabled)];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setContentSizeCategory:(NSString *)contentSizeCategory
|
||||
{
|
||||
if (_contentSizeCategory != contentSizeCategory) {
|
||||
@ -145,6 +165,12 @@ RCT_EXPORT_METHOD(getMultiplier:(RCTResponseSenderBlock)callback)
|
||||
}
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(getCurrentVoiceOverState:(RCTResponseSenderBlock)callback
|
||||
error:(__unused RCTResponseSenderBlock)error)
|
||||
{
|
||||
callback(@[@(_isVoiceOverEnabled)]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTBridge (RCTAccessibilityManager)
|
||||
|
Loading…
x
Reference in New Issue
Block a user