77#include " flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h"
88#include " flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h"
99
10- @interface InactiveTextPosition : UITextPosition
11-
12- @property (nonatomic , readonly ) NSUInteger index;
13-
14- + (instancetype )positionWithIndex : (NSUInteger )index ;
15- - (instancetype )initWithIndex : (NSUInteger )index ;
16-
17- @end
18-
19- @implementation InactiveTextPosition
20-
21- + (instancetype )positionWithIndex : (NSUInteger )index {
22- return [[[InactiveTextPosition alloc ] initWithIndex: index] autorelease ];
23- }
24-
25- - (instancetype )initWithIndex : (NSUInteger )index {
26- self = [super init ];
27- if (self) {
28- _index = index;
29- }
30- return self;
31- }
32-
33- @end
34-
35- @interface InactiveTextRange : UITextRange <NSCopying >
36-
37- @property (nonatomic , readonly ) NSRange range;
38-
39- + (instancetype )rangeWithNSRange : (NSRange )range ;
40-
41- @end
42-
43- @implementation InactiveTextRange
44-
45- + (instancetype )rangeWithNSRange : (NSRange )range {
46- return [[[InactiveTextRange alloc ] initWithNSRange: range] autorelease ];
47- }
48-
49- - (instancetype )initWithNSRange : (NSRange )range {
50- self = [super init ];
51- if (self) {
52- _range = range;
53- }
54- return self;
55- }
56-
57- - (UITextPosition*)start {
58- return [InactiveTextPosition positionWithIndex: self .range.location];
59- }
60-
61- - (UITextPosition*)end {
62- return [InactiveTextPosition positionWithIndex: self .range.location + self .range.length];
63- }
64-
65- - (BOOL )isEmpty {
66- return self.range .length == 0 ;
67- }
68-
69- - (id )copyWithZone : (NSZone *)zone {
70- return [[InactiveTextRange allocWithZone: zone] initWithNSRange: self .range];
71- }
72-
73- @end
74-
7510@implementation FlutterInactiveTextInput {
7611}
7712
@@ -88,7 +23,7 @@ - (BOOL)hasText {
8823}
8924
9025- (NSString *)textInRange : (UITextRange*)range {
91- NSRange textRange = ((InactiveTextRange *)range).range ;
26+ NSRange textRange = ((FlutterTextRange *)range).range ;
9227 return [self .text substringWithRange: textRange];
9328}
9429
@@ -112,9 +47,9 @@ - (void)unmarkText {
11247
11348- (UITextRange*)textRangeFromPosition : (UITextPosition*)fromPosition
11449 toPosition : (UITextPosition*)toPosition {
115- NSUInteger fromIndex = ((InactiveTextPosition *)fromPosition).index ;
116- NSUInteger toIndex = ((InactiveTextPosition *)toPosition).index ;
117- return [InactiveTextRange rangeWithNSRange: NSMakeRange (fromIndex, toIndex - fromIndex)];
50+ NSUInteger fromIndex = ((FlutterTextPosition *)fromPosition).index ;
51+ NSUInteger toIndex = ((FlutterTextPosition *)toPosition).index ;
52+ return [FlutterTextRange rangeWithNSRange: NSMakeRange (fromIndex, toIndex - fromIndex)];
11853}
11954
12055- (UITextPosition*)positionFromPosition : (UITextPosition*)position offset : (NSInteger )offset {
0 commit comments