react-native-a11y-order 0.8.2 → 0.9.1-rc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -152
- package/android/build.gradle +0 -18
- package/android/src/main/java/com/a11yorder/services/focus/A11yFocusDelegate.java +10 -32
- package/android/src/main/java/com/a11yorder/services/order/A11yOrderService.java +70 -65
- package/android/src/main/java/com/a11yorder/services/order/linking/A11yLinkingQueue.java +37 -63
- package/android/src/main/java/com/a11yorder/services/order/linking/A11yOrderLinking.java +11 -14
- package/android/src/main/java/com/a11yorder/services/order/linking/WeakTreeMap.java +53 -31
- package/android/src/main/java/com/a11yorder/utils/A11yHelper.java +39 -59
- package/android/src/main/java/com/a11yorder/utils/ChoreographerUtils.java +7 -12
- package/android/src/main/java/com/a11yorder/utils/FragmentUtils.java +8 -48
- package/android/src/main/java/com/a11yorder/views/A11yIndexView/A11yIndexView.java +1 -1
- package/android/src/main/java/com/a11yorder/views/A11yLockView/A11yLockViewManager.java +5 -0
- package/android/src/main/java/com/a11yorder/views/A11yView/A11yView.java +1 -1
- package/android/src/oldarch/A11yLockViewManagerSpec.java +2 -0
- package/ios/delegates/RNAOViewItemDelegate/RNAOViewItemDelegate.mm +1 -1
- package/ios/extensions/RCTModalHostViewComponentView+RNAOA11yOrder.mm +21 -21
- package/ios/extensions/UIView+RNAOA11yOrder.mm +17 -20
- package/ios/extensions/UIViewController+RNAOA11yOrder.mm +8 -8
- package/ios/helpers/RNAOSwizzleInstall.h +30 -0
- package/ios/services/RNAOA11yItemDelegate/RNAOA11yItemDelegate.h +4 -6
- package/ios/services/RNAOA11yItemDelegate/RNAOA11yItemDelegate.mm +98 -87
- package/ios/services/RNAOA11yOrderLinking/RNAOA11yOrderLinking.h +5 -3
- package/ios/services/RNAOA11yOrderLinking/RNAOA11yOrderLinking.mm +49 -49
- package/ios/services/RNAOA11yRelationship/RNAOA11yRelationship.h +1 -0
- package/ios/services/RNAOA11yRelationship/RNAOA11yRelationship.mm +42 -36
- package/ios/services/RNAOSortedMap/RNAOSortedMap.h +2 -1
- package/ios/services/RNAOSortedMap/RNAOSortedMap.mm +48 -47
- package/ios/views/RNAOA11yLockView/RNAOA11yLockView.h +4 -2
- package/ios/views/RNAOA11yLockView/RNAOA11yLockView.mm +89 -3
- package/ios/views/RNAOA11yLockView/RNAOA11yLockViewManager.mm +3 -0
- package/lib/commonjs/components/A11yLock/A11yBaseLock/A11yBaseLock.js +18 -2
- package/lib/commonjs/components/A11yLock/A11yBaseLock/A11yBaseLock.js.map +1 -1
- package/lib/commonjs/components/A11yLock/A11yFocusTrap/A11yFocusTrap.js +23 -7
- package/lib/commonjs/components/A11yLock/A11yFocusTrap/A11yFocusTrap.js.map +1 -1
- package/lib/commonjs/nativeSpecs/A11yLockNativeComponent.ts +1 -0
- package/lib/module/components/A11yLock/A11yBaseLock/A11yBaseLock.js +17 -2
- package/lib/module/components/A11yLock/A11yBaseLock/A11yBaseLock.js.map +1 -1
- package/lib/module/components/A11yLock/A11yFocusTrap/A11yFocusTrap.js +23 -7
- package/lib/module/components/A11yLock/A11yFocusTrap/A11yFocusTrap.js.map +1 -1
- package/lib/module/nativeSpecs/A11yLockNativeComponent.ts +1 -0
- package/lib/typescript/src/components/A11yLock/A11yBaseLock/A11yBaseLock.d.ts +2 -1
- package/lib/typescript/src/components/A11yLock/A11yBaseLock/A11yBaseLock.d.ts.map +1 -1
- package/lib/typescript/src/components/A11yLock/A11yFocusTrap/A11yFocusTrap.d.ts +1 -1
- package/lib/typescript/src/components/A11yLock/A11yFocusTrap/A11yFocusTrap.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/nativeSpecs/A11yLockNativeComponent.d.ts +1 -0
- package/lib/typescript/src/nativeSpecs/A11yLockNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/types/A11yLock.types.d.ts +1 -0
- package/lib/typescript/src/types/A11yLock.types.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/components/A11yLock/A11yBaseLock/A11yBaseLock.tsx +20 -3
- package/src/components/A11yLock/A11yFocusTrap/A11yFocusTrap.tsx +24 -5
- package/src/nativeSpecs/A11yLockNativeComponent.ts +1 -0
- package/src/types/A11yLock.types.ts +1 -0
- package/lib/commonjs/components/A11yLock/A11yBaseLock/A11yBaseLock.android.js +0 -23
- package/lib/commonjs/components/A11yLock/A11yBaseLock/A11yBaseLock.android.js.map +0 -1
- package/lib/module/components/A11yLock/A11yBaseLock/A11yBaseLock.android.js +0 -18
- package/lib/module/components/A11yLock/A11yBaseLock/A11yBaseLock.android.js.map +0 -1
- package/lib/typescript/src/components/A11yLock/A11yBaseLock/A11yBaseLock.android.d.ts +0 -4
- package/lib/typescript/src/components/A11yLock/A11yBaseLock/A11yBaseLock.android.d.ts.map +0 -1
- package/src/components/A11yLock/A11yBaseLock/A11yBaseLock.android.tsx +0 -16
|
@@ -12,13 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
@interface RNAOA11yItemDelegate : NSObject
|
|
14
14
|
|
|
15
|
-
- (instancetype _Nonnull)initWithView:
|
|
16
|
-
(UIView<RNAOViewItemProtocol> *_Nonnull)delegate;
|
|
15
|
+
- (instancetype _Nonnull)initWithView:(UIView<RNAOViewItemProtocol> *_Nonnull)delegate;
|
|
17
16
|
|
|
18
17
|
@property (nonatomic, weak) UIView *linkView;
|
|
19
|
-
@property (
|
|
20
|
-
@property NSString*
|
|
21
|
-
@property NSNumber*
|
|
18
|
+
@property (nonatomic, strong) NSNumber *position;
|
|
19
|
+
@property (nonatomic, copy) NSString *orderKey;
|
|
20
|
+
@property (nonatomic, strong) NSNumber *orderFocusType;
|
|
22
21
|
|
|
23
22
|
- (void)willRemoveSubview:(UIView *)subview;
|
|
24
23
|
- (void)didAddSubview:(UIView *)subview;
|
|
@@ -27,5 +26,4 @@
|
|
|
27
26
|
|
|
28
27
|
@end
|
|
29
28
|
|
|
30
|
-
|
|
31
29
|
#endif /* RNAOA11yItemDelegate_h */
|
|
@@ -8,146 +8,157 @@
|
|
|
8
8
|
#import <Foundation/Foundation.h>
|
|
9
9
|
#import "RNAOA11yItemDelegate.h"
|
|
10
10
|
#import "RNAOA11yOrderLinking.h"
|
|
11
|
-
#import "RNAOA11yItemProtocol.h"
|
|
12
11
|
|
|
13
12
|
typedef NS_ENUM(NSInteger, A11yOrderType) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
A11yOrderTypeDefault = 0,
|
|
14
|
+
A11yOrderTypeChild = 1,
|
|
15
|
+
A11yOrderTypeLegacy = 2,
|
|
17
16
|
};
|
|
18
17
|
|
|
19
|
-
|
|
20
18
|
@implementation RNAOA11yItemDelegate {
|
|
21
19
|
__weak UIView<RNAOViewItemProtocol> *_delegate;
|
|
20
|
+
__weak UIView *_focusDelegateView;
|
|
22
21
|
BOOL _isLinked;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
- (instancetype _Nonnull)initWithView:
|
|
26
|
-
(UIView<RNAOA11yItemProtocol, RNAOViewItemProtocol> *_Nonnull)delegate {
|
|
24
|
+
- (instancetype _Nonnull)initWithView:(UIView<RNAOViewItemProtocol> *_Nonnull)delegate {
|
|
27
25
|
self = [super init];
|
|
28
26
|
if (self) {
|
|
29
27
|
_delegate = delegate;
|
|
30
|
-
_isLinked =
|
|
28
|
+
_isLinked = NO;
|
|
31
29
|
}
|
|
32
30
|
return self;
|
|
33
31
|
}
|
|
34
32
|
|
|
33
|
+
#pragma mark - Prop setters
|
|
34
|
+
|
|
35
35
|
- (void)setPosition:(NSNumber *)position {
|
|
36
|
-
NSNumber *
|
|
36
|
+
NSNumber *lastPosition = _position;
|
|
37
37
|
_position = position;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
[self relink: position lastPosition: _lastPostion];
|
|
38
|
+
if (lastPosition != nil && ![lastPosition isEqualToNumber:position]) {
|
|
39
|
+
[self relink:position lastPosition:lastPosition];
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
- (void)
|
|
45
|
-
if(
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
- (void)setOrderKey:(NSString *)orderKey {
|
|
44
|
+
if ([_orderKey isEqualToString:orderKey]) return;
|
|
45
|
+
NSString *prevKey = _orderKey;
|
|
46
|
+
_orderKey = orderKey;
|
|
47
|
+
if (_isLinked) {
|
|
48
|
+
// Atomic: remove from old group and register in new group in one call.
|
|
49
|
+
// _isLinked = YES guarantees _position and _linkView are non-nil.
|
|
50
|
+
[[RNAOA11yOrderLinking sharedInstance] updateOrderKey:prevKey next:orderKey position:_position withView:_linkView];
|
|
51
|
+
_isLinked = (orderKey != nil);
|
|
48
52
|
} else {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
- (void)finalizeUpdates {
|
|
54
|
-
if(!_delegate) return;
|
|
55
|
-
if(_delegate.subviews.count > 0) {
|
|
56
|
-
[self setLinkView: _delegate.subviews[0]];
|
|
53
|
+
// Not yet registered — try now (handles old arch prop-arrival ordering).
|
|
54
|
+
[self link];
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
- (void)
|
|
61
|
-
if(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
[self
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
58
|
+
- (void)setOrderFocusType:(NSNumber *)orderFocusType {
|
|
59
|
+
if ([_orderFocusType isEqualToNumber:orderFocusType]) return;
|
|
60
|
+
_orderFocusType = orderFocusType;
|
|
61
|
+
if (!_isLinked || _delegate.subviews.count == 0) return;
|
|
62
|
+
UIView *newView = [self getFocusView:_delegate.subviews[0]];
|
|
63
|
+
if (newView == nil || newView == _linkView) return;
|
|
64
|
+
[self clear];
|
|
65
|
+
[self setLinkView:newView];
|
|
69
66
|
}
|
|
70
67
|
|
|
68
|
+
#pragma mark - Subview lifecycle
|
|
71
69
|
|
|
72
70
|
- (void)didAddSubview:(UIView *)subview {
|
|
73
|
-
if(!_linkView) {
|
|
74
|
-
_isLinked =
|
|
75
|
-
|
|
76
|
-
[self setLinkView: view];
|
|
71
|
+
if (!_linkView) {
|
|
72
|
+
_isLinked = NO;
|
|
73
|
+
[self setLinkView:[self getFocusView:subview]];
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
76
|
|
|
80
77
|
- (void)willRemoveSubview:(UIView *)subview {
|
|
81
|
-
if(_linkView == subview) {
|
|
78
|
+
if (_linkView == subview) {
|
|
82
79
|
[self clear];
|
|
83
|
-
UIView* firstAccessible = [self findFirstAccessibleChild: _delegate];
|
|
84
|
-
if(firstAccessible) {
|
|
85
|
-
[_delegate onFocusItemRemoved: subview];
|
|
86
|
-
}
|
|
87
80
|
}
|
|
88
81
|
}
|
|
89
82
|
|
|
90
|
-
- (void)
|
|
91
|
-
if(!_delegate) return;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
83
|
+
- (void)finalizeUpdates {
|
|
84
|
+
if (!_delegate || _delegate.subviews.count == 0) return;
|
|
85
|
+
[self setLinkView:[self getFocusView:_delegate.subviews[0]]];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
#pragma mark - Registration
|
|
89
|
+
|
|
90
|
+
- (void)setLinkView:(UIView *)view {
|
|
91
|
+
if (_isLinked) return;
|
|
92
|
+
_linkView = view;
|
|
93
|
+
[self link];
|
|
97
94
|
}
|
|
98
95
|
|
|
99
96
|
- (void)link {
|
|
100
|
-
if(!_delegate) return;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
97
|
+
if (!_delegate) return;
|
|
98
|
+
if (_position && _orderKey && _linkView && !_isLinked) {
|
|
99
|
+
[[RNAOA11yOrderLinking sharedInstance] add:_position withOrderKey:_orderKey withObject:_linkView];
|
|
100
|
+
_isLinked = YES;
|
|
101
|
+
[self registerFocusDelegate];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
- (void)registerFocusDelegate {
|
|
106
|
+
UIView *firstAccessible = [self findFirstAccessibleChild:_delegate];
|
|
107
|
+
UIView *focusView = firstAccessible ?: _linkView;
|
|
108
|
+
if (focusView) {
|
|
109
|
+
_focusDelegateView = focusView;
|
|
110
|
+
[_delegate onFocusItemLinked:focusView];
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
113
|
|
|
114
|
+
- (void)relink:(NSNumber *)position lastPosition:(NSNumber *)lastPosition {
|
|
115
|
+
if (!_delegate || !_isLinked || !_orderKey || !position) return;
|
|
116
|
+
UIView *view = _delegate.subviews.count > 0
|
|
117
|
+
? [self getFocusView:_delegate.subviews[0]]
|
|
118
|
+
: _linkView;
|
|
119
|
+
if (!view) return;
|
|
120
|
+
[[RNAOA11yOrderLinking sharedInstance] update:position lastPosition:lastPosition withOrderKey:_orderKey withView:view];
|
|
121
|
+
}
|
|
122
|
+
|
|
109
123
|
- (void)clear {
|
|
110
|
-
if(!_delegate) return;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
124
|
+
if (!_delegate) return;
|
|
125
|
+
if (_focusDelegateView) {
|
|
126
|
+
[_delegate onFocusItemRemoved:_focusDelegateView];
|
|
127
|
+
_focusDelegateView = nil;
|
|
128
|
+
}
|
|
129
|
+
_isLinked = NO;
|
|
130
|
+
if (_position && _orderKey) {
|
|
131
|
+
[[RNAOA11yOrderLinking sharedInstance] remove:_position withOrderKey:_orderKey];
|
|
114
132
|
}
|
|
115
133
|
}
|
|
116
134
|
|
|
135
|
+
#pragma mark - Focus view resolution
|
|
136
|
+
|
|
117
137
|
- (UIView *)getFocusView:(UIView *)subview {
|
|
118
|
-
if(!_delegate) return nil;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
138
|
+
if (!_delegate) return nil;
|
|
139
|
+
switch ([_orderFocusType intValue]) {
|
|
140
|
+
case A11yOrderTypeChild:
|
|
141
|
+
return [self findFirstAccessibleChild:_delegate];
|
|
142
|
+
case A11yOrderTypeLegacy:
|
|
143
|
+
return subview;
|
|
144
|
+
case A11yOrderTypeDefault:
|
|
145
|
+
default:
|
|
146
|
+
return _delegate;
|
|
147
|
+
}
|
|
129
148
|
}
|
|
130
149
|
|
|
131
150
|
- (UIView *)findFirstAccessibleChild:(UIView *)parentView {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
UIView *accessibleChild = [self findFirstAccessibleChild:child];
|
|
142
|
-
if (accessibleChild != nil) {
|
|
143
|
-
return accessibleChild;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return nil;
|
|
151
|
+
if (!parentView) return nil;
|
|
152
|
+
for (UIView *child in parentView.subviews) {
|
|
153
|
+
if ([self isAccessibleView:child]) return child;
|
|
154
|
+
UIView *found = [self findFirstAccessibleChild:child];
|
|
155
|
+
if (found) return found;
|
|
156
|
+
}
|
|
157
|
+
return nil;
|
|
148
158
|
}
|
|
149
159
|
|
|
150
160
|
- (BOOL)isAccessibleView:(UIView *)view {
|
|
151
|
-
|
|
161
|
+
return view.isAccessibilityElement && !view.hidden && view.alpha > 0;
|
|
152
162
|
}
|
|
163
|
+
|
|
153
164
|
@end
|
|
@@ -15,10 +15,12 @@
|
|
|
15
15
|
|
|
16
16
|
- (void)add:(NSNumber*)position withOrderKey:(NSString*)orderKey withObject:(NSObject*)obj;
|
|
17
17
|
- (void)remove:(NSNumber*)position withOrderKey:(NSString*)orderKey;
|
|
18
|
-
- (void)setContainer:(NSString*)orderKey withView:(UIView*)
|
|
19
|
-
- (void)setContainer:(NSString*)orderKey withView:(UIView*)
|
|
18
|
+
- (void)setContainer:(NSString*)orderKey withView:(UIView*)view;
|
|
19
|
+
- (void)setContainer:(NSString*)orderKey withView:(UIView*)view withDebounce:(BOOL)debounced;
|
|
20
|
+
- (void)update:(NSNumber*)position lastPosition:(NSNumber*)lastPosition withOrderKey:(NSString*)orderKey withView:(UIView*)view;
|
|
21
|
+
- (void)updateOrderKey:(NSString*)prev next:(NSString*)next position:(NSNumber*)position withView:(UIView*)view;
|
|
20
22
|
- (void)removeContainer:(NSString*)orderKey;
|
|
21
|
-
|
|
23
|
+
|
|
22
24
|
@end
|
|
23
25
|
|
|
24
26
|
#endif /* RNAOA11yOrderLinking_h */
|
|
@@ -11,80 +11,80 @@
|
|
|
11
11
|
#import "RNAOA11yRelationship.h"
|
|
12
12
|
|
|
13
13
|
@implementation RNAOA11yOrderLinking {
|
|
14
|
-
|
|
14
|
+
NSMutableDictionary<NSString *, RNAOA11yRelationship *> *_relationships;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
+ (instancetype)sharedInstance {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
static RNAOA11yOrderLinking *sharedInstance = nil;
|
|
19
|
+
static dispatch_once_t onceToken;
|
|
20
|
+
dispatch_once(&onceToken, ^{
|
|
21
|
+
sharedInstance = [[self alloc] init];
|
|
22
|
+
});
|
|
23
|
+
return sharedInstance;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
- (id)init {
|
|
27
27
|
if (self = [super init]) {
|
|
28
|
-
|
|
28
|
+
_relationships = [NSMutableDictionary dictionary];
|
|
29
29
|
}
|
|
30
|
-
|
|
31
30
|
return self;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
- (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
- (RNAOA11yRelationship *)relationshipForKey:(NSString *)orderKey {
|
|
34
|
+
RNAOA11yRelationship *relationship = _relationships[orderKey];
|
|
35
|
+
if (relationship == nil) {
|
|
36
|
+
relationship = [[RNAOA11yRelationship alloc] init];
|
|
37
|
+
_relationships[orderKey] = relationship;
|
|
38
|
+
}
|
|
39
|
+
return relationship;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
-(void)
|
|
44
|
-
|
|
45
|
-
if(relationship != nil) {
|
|
46
|
-
[relationship remove:position];
|
|
47
|
-
}
|
|
42
|
+
- (void)add:(NSNumber *)position withOrderKey:(NSString *)orderKey withObject:(NSObject *)obj {
|
|
43
|
+
[[self relationshipForKey:orderKey] add:position withObject:obj];
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
-(void)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
[relationship setContainer:view withDebounce: debounced];
|
|
46
|
+
- (void)remove:(NSNumber *)position withOrderKey:(NSString *)orderKey {
|
|
47
|
+
RNAOA11yRelationship *relationship = _relationships[orderKey];
|
|
48
|
+
if (relationship == nil) return;
|
|
49
|
+
[relationship remove:position];
|
|
50
|
+
if ([relationship isEmpty]) {
|
|
51
|
+
[_relationships removeObjectForKey:orderKey];
|
|
52
|
+
}
|
|
58
53
|
}
|
|
59
54
|
|
|
60
|
-
- (void)setContainer:(NSString*)orderKey withView:(UIView*)view {
|
|
61
|
-
[self
|
|
55
|
+
- (void)setContainer:(NSString *)orderKey withView:(UIView *)view withDebounce:(BOOL)debounced {
|
|
56
|
+
[[self relationshipForKey:orderKey] setContainer:view withDebounce:debounced];
|
|
62
57
|
}
|
|
63
58
|
|
|
64
|
-
- (void)
|
|
65
|
-
|
|
66
|
-
if(relationship != nil) {
|
|
67
|
-
[relationship update:lastPosition withPosition:position withObject:view];
|
|
68
|
-
}
|
|
59
|
+
- (void)setContainer:(NSString *)orderKey withView:(UIView *)view {
|
|
60
|
+
[self setContainer:orderKey withView:view withDebounce:NO];
|
|
69
61
|
}
|
|
70
62
|
|
|
71
|
-
- (void)
|
|
72
|
-
|
|
73
|
-
if(relationship != nil) {
|
|
74
|
-
[_relationships removeObjectForKey:orderKey];
|
|
75
|
-
[relationship clear];
|
|
76
|
-
}
|
|
77
|
-
[self setAccessibilityElements: nil];
|
|
63
|
+
- (void)update:(NSNumber *)position lastPosition:(NSNumber *)lastPosition withOrderKey:(NSString *)orderKey withView:(UIView *)view {
|
|
64
|
+
[_relationships[orderKey] update:lastPosition withPosition:position withObject:view];
|
|
78
65
|
}
|
|
79
66
|
|
|
80
|
-
-(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
67
|
+
- (void)updateOrderKey:(NSString *)prev next:(NSString *)next position:(NSNumber *)position withView:(UIView *)view {
|
|
68
|
+
if (prev != nil) {
|
|
69
|
+
RNAOA11yRelationship *old = _relationships[prev];
|
|
70
|
+
[old remove:position];
|
|
71
|
+
if ([old isEmpty]) {
|
|
72
|
+
[_relationships removeObjectForKey:prev];
|
|
84
73
|
}
|
|
85
|
-
|
|
86
|
-
|
|
74
|
+
}
|
|
75
|
+
if (next != nil) {
|
|
76
|
+
[[self relationshipForKey:next] add:position withObject:view];
|
|
77
|
+
}
|
|
87
78
|
}
|
|
88
79
|
|
|
80
|
+
- (void)removeContainer:(NSString *)orderKey {
|
|
81
|
+
RNAOA11yRelationship *relationship = _relationships[orderKey];
|
|
82
|
+
if (relationship != nil) {
|
|
83
|
+
UIView *container = [relationship getContainer];
|
|
84
|
+
[_relationships removeObjectForKey:orderKey];
|
|
85
|
+
[relationship clear];
|
|
86
|
+
[container setAccessibilityElements:nil];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
89
|
|
|
90
90
|
@end
|
|
@@ -12,63 +12,69 @@
|
|
|
12
12
|
#import "RNAODebouncer.h"
|
|
13
13
|
|
|
14
14
|
@implementation RNAOA11yRelationship {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
BOOL _debounced;
|
|
15
|
+
__weak UIView *_container;
|
|
16
|
+
RNAOSortedMap *_positions;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
- (instancetype)init {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
self.debouncer = [[RNAODebouncer alloc] initWithInterval: 0.01];
|
|
27
|
-
}
|
|
28
|
-
return self;
|
|
20
|
+
self = [super init];
|
|
21
|
+
if (self) {
|
|
22
|
+
_positions = [[RNAOSortedMap alloc] init];
|
|
23
|
+
}
|
|
24
|
+
return self;
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
- (void)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
[self updateAccessibilityElements];
|
|
36
|
-
}];
|
|
37
|
-
}
|
|
27
|
+
- (void)updateAccessibilityElements {
|
|
28
|
+
if (_container != nil) {
|
|
29
|
+
[_container setAccessibilityElements:[_positions getValues]];
|
|
30
|
+
}
|
|
38
31
|
}
|
|
39
32
|
|
|
40
|
-
- (void)
|
|
41
|
-
if(
|
|
42
|
-
[
|
|
33
|
+
- (void)scheduleAccessibilityUpdate {
|
|
34
|
+
if (self.debouncer) {
|
|
35
|
+
[self.debouncer debounceAction:^{ [self updateAccessibilityElements]; }];
|
|
36
|
+
} else {
|
|
37
|
+
[self updateAccessibilityElements];
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
40
|
|
|
46
|
-
-(void)
|
|
47
|
-
|
|
41
|
+
- (void)add:(NSNumber *)position withObject:(NSObject *)obj {
|
|
42
|
+
[_positions put:position withObject:obj];
|
|
43
|
+
[self scheduleAccessibilityUpdate];
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
-(void)
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
- (void)remove:(NSNumber *)position {
|
|
47
|
+
[_positions remove:position];
|
|
48
|
+
[self scheduleAccessibilityUpdate];
|
|
53
49
|
}
|
|
54
50
|
|
|
55
|
-
- (void)
|
|
56
|
-
[
|
|
57
|
-
|
|
51
|
+
- (void)update:(NSNumber *)lastPosition withPosition:(NSNumber *)position withObject:(NSObject *)obj {
|
|
52
|
+
[_positions update:lastPosition withPosition:position withObject:obj];
|
|
53
|
+
[self scheduleAccessibilityUpdate];
|
|
58
54
|
}
|
|
59
55
|
|
|
60
|
-
- (void)
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
- (void)setContainer:(UIView *)view {
|
|
57
|
+
_container = view;
|
|
58
|
+
[self updateAccessibilityElements];
|
|
63
59
|
}
|
|
64
60
|
|
|
65
|
-
-(void)
|
|
66
|
-
|
|
61
|
+
- (void)setContainer:(UIView *)view withDebounce:(BOOL)debounced {
|
|
62
|
+
if (debounced && !self.debouncer) {
|
|
63
|
+
self.debouncer = [[RNAODebouncer alloc] initWithInterval:0.01];
|
|
64
|
+
}
|
|
65
|
+
[self setContainer:view];
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
-(
|
|
70
|
-
|
|
68
|
+
- (void)clear {
|
|
69
|
+
[_positions clear];
|
|
71
70
|
}
|
|
72
71
|
|
|
72
|
+
- (UIView *)getContainer {
|
|
73
|
+
return _container;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
- (BOOL)isEmpty {
|
|
77
|
+
return [_positions isEmpty];
|
|
78
|
+
}
|
|
73
79
|
|
|
74
80
|
@end
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
|
|
14
14
|
- (void)put:(NSNumber*)position withObject:(NSObject*)obj;
|
|
15
15
|
- (void)remove:(NSNumber*)position;
|
|
16
|
-
- (void)update:(NSNumber*)
|
|
16
|
+
- (void)update:(NSNumber*)lastPosition withPosition:(NSNumber*)position withObject:(NSObject*)obj;
|
|
17
17
|
- (void)clear;
|
|
18
18
|
- (NSArray*)getValues;
|
|
19
|
+
- (BOOL)isEmpty;
|
|
19
20
|
|
|
20
21
|
@end
|
|
21
22
|
|