Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 4927970

Browse files
committed
review edits
1 parent aa33ded commit 4927970

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

shell/platform/darwin/ios/framework/Source/SemanticsObject.mm

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ CGPoint ConvertPointToGlobal(SemanticsObject* reference, CGPoint local_point) {
5454
// `rect` is in the physical pixel coordinate system. iOS expects the accessibility frame in
5555
// the logical pixel coordinate system. Therefore, we divide by the `scale` (pixel ratio) to
5656
// convert.
57-
UIScreen* screen = [reference.bridge->view() window].screen;
57+
UIScreen* screen = reference.bridge->view().window.screen;
5858
// Screen can be nil if the FlutterView is covered by another native view.
59-
CGFloat scale = screen == nil ? UIScreen.mainScreen.scale : screen.scale;
59+
CGFloat scale = (screen ?: UIScreen.mainScreen).scale;
6060
auto result = CGPointMake(point.x() / scale, point.y() / scale);
6161
return [reference.bridge->view() convertPoint:result toView:nil];
6262
}
@@ -82,9 +82,9 @@ CGRect ConvertRectToGlobal(SemanticsObject* reference, CGRect local_rect) {
8282
// `rect` is in the physical pixel coordinate system. iOS expects the accessibility frame in
8383
// the logical pixel coordinate system. Therefore, we divide by the `scale` (pixel ratio) to
8484
// convert.
85-
UIScreen* screen = [reference.bridge->view() window].screen;
85+
UIScreen* screen = reference.bridge->view().window.screen;
8686
// Screen can be nil if the FlutterView is covered by another native view.
87-
CGFloat scale = screen == nil ? UIScreen.mainScreen.scale : screen.scale;
87+
CGFloat scale = (screen ?: UIScreen.mainScreen).scale;
8888
auto result =
8989
CGRectMake(rect.x() / scale, rect.y() / scale, rect.width() / scale, rect.height() / scale);
9090
return UIAccessibilityConvertFrameToScreenCoordinates(result, reference.bridge->view());
@@ -126,12 +126,8 @@ - (void)forwardInvocation:(NSInvocation*)anInvocation {
126126
}
127127

128128
- (NSString*)accessibilityValue {
129-
if (self.node.HasFlag(flutter::SemanticsFlags::kIsToggled) ||
130-
self.node.HasFlag(flutter::SemanticsFlags::kIsChecked)) {
131-
self.nativeSwitch.on = YES;
132-
} else {
133-
self.nativeSwitch.on = NO;
134-
}
129+
self.nativeSwitch.on = self.node.HasFlag(flutter::SemanticsFlags::kIsToggled) ||
130+
self.node.HasFlag(flutter::SemanticsFlags::kIsChecked);
135131

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

143139
- (UIAccessibilityTraits)accessibilityTraits {
144-
if (self.node.HasFlag(flutter::SemanticsFlags::kIsEnabled)) {
145-
self.nativeSwitch.enabled = YES;
146-
} else {
147-
self.nativeSwitch.enabled = NO;
148-
}
140+
self.nativeSwitch.enabled = self.node.HasFlag(flutter::SemanticsFlags::kIsEnabled);
149141

150142
return self.nativeSwitch.accessibilityTraits;
151143
}

0 commit comments

Comments
 (0)