Skip to content

Commit

Permalink
review edits
Browse files Browse the repository at this point in the history
  • Loading branch information
jmagman committed May 14, 2024
1 parent aa33ded commit 4927970
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions shell/platform/darwin/ios/framework/Source/SemanticsObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ CGPoint ConvertPointToGlobal(SemanticsObject* reference, CGPoint local_point) {
// `rect` is in the physical pixel coordinate system. iOS expects the accessibility frame in
// the logical pixel coordinate system. Therefore, we divide by the `scale` (pixel ratio) to
// convert.
UIScreen* screen = [reference.bridge->view() window].screen;
UIScreen* screen = reference.bridge->view().window.screen;
// Screen can be nil if the FlutterView is covered by another native view.
CGFloat scale = screen == nil ? UIScreen.mainScreen.scale : screen.scale;
CGFloat scale = (screen ?: UIScreen.mainScreen).scale;
auto result = CGPointMake(point.x() / scale, point.y() / scale);
return [reference.bridge->view() convertPoint:result toView:nil];
}
Expand All @@ -82,9 +82,9 @@ CGRect ConvertRectToGlobal(SemanticsObject* reference, CGRect local_rect) {
// `rect` is in the physical pixel coordinate system. iOS expects the accessibility frame in
// the logical pixel coordinate system. Therefore, we divide by the `scale` (pixel ratio) to
// convert.
UIScreen* screen = [reference.bridge->view() window].screen;
UIScreen* screen = reference.bridge->view().window.screen;
// Screen can be nil if the FlutterView is covered by another native view.
CGFloat scale = screen == nil ? UIScreen.mainScreen.scale : screen.scale;
CGFloat scale = (screen ?: UIScreen.mainScreen).scale;
auto result =
CGRectMake(rect.x() / scale, rect.y() / scale, rect.width() / scale, rect.height() / scale);
return UIAccessibilityConvertFrameToScreenCoordinates(result, reference.bridge->view());
Expand Down Expand Up @@ -126,12 +126,8 @@ - (void)forwardInvocation:(NSInvocation*)anInvocation {
}

- (NSString*)accessibilityValue {
if (self.node.HasFlag(flutter::SemanticsFlags::kIsToggled) ||
self.node.HasFlag(flutter::SemanticsFlags::kIsChecked)) {
self.nativeSwitch.on = YES;
} else {
self.nativeSwitch.on = NO;
}
self.nativeSwitch.on = self.node.HasFlag(flutter::SemanticsFlags::kIsToggled) ||
self.node.HasFlag(flutter::SemanticsFlags::kIsChecked);

if (![self isAccessibilityBridgeAlive]) {
return nil;
Expand All @@ -141,11 +137,7 @@ - (NSString*)accessibilityValue {
}

- (UIAccessibilityTraits)accessibilityTraits {
if (self.node.HasFlag(flutter::SemanticsFlags::kIsEnabled)) {
self.nativeSwitch.enabled = YES;
} else {
self.nativeSwitch.enabled = NO;
}
self.nativeSwitch.enabled = self.node.HasFlag(flutter::SemanticsFlags::kIsEnabled);

return self.nativeSwitch.accessibilityTraits;
}
Expand Down

0 comments on commit 4927970

Please sign in to comment.