Skip to content

Commit

Permalink
[camera_avfoundation] 🐛 Fix inverted orientation strings (flutter#5261)
Browse files Browse the repository at this point in the history
- Fixes flutter/flutter#117981
- Fixes flutter/flutter#101878

Tests are also updated correspondingly.
  • Loading branch information
AlexV525 authored Oct 31, 2023
1 parent 64dbd3a commit 7dff4f1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions packages/camera/camera_avfoundation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.13+7

* Fixes inverted orientation strings.

## 0.9.13+6

* Fixes incorrect use of `NSError` that could cause crashes on launch.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ - (void)testOrientationNotifications {
expectedChannelOrientation:@"portraitUp"
cameraPlugin:cameraPlugin
messenger:mockMessenger];
[self rotate:UIDeviceOrientationLandscapeRight
[self rotate:UIDeviceOrientationLandscapeLeft
expectedChannelOrientation:@"landscapeLeft"
cameraPlugin:cameraPlugin
messenger:mockMessenger];
[self rotate:UIDeviceOrientationLandscapeLeft
[self rotate:UIDeviceOrientationLandscapeRight
expectedChannelOrientation:@"landscapeRight"
cameraPlugin:cameraPlugin
messenger:mockMessenger];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ - (void)testFLTGetVideoFormatFromString {
- (void)testFLTGetUIDeviceOrientationForString {
XCTAssertEqual(UIDeviceOrientationPortraitUpsideDown,
FLTGetUIDeviceOrientationForString(@"portraitDown"));
XCTAssertEqual(UIDeviceOrientationLandscapeRight,
FLTGetUIDeviceOrientationForString(@"landscapeLeft"));
XCTAssertEqual(UIDeviceOrientationLandscapeLeft,
FLTGetUIDeviceOrientationForString(@"landscapeLeft"));
XCTAssertEqual(UIDeviceOrientationLandscapeRight,
FLTGetUIDeviceOrientationForString(@"landscapeRight"));
XCTAssertEqual(UIDeviceOrientationPortrait, FLTGetUIDeviceOrientationForString(@"portraitUp"));
XCTAssertEqual(UIDeviceOrientationUnknown, FLTGetUIDeviceOrientationForString(@"unknown"));
Expand All @@ -96,9 +96,9 @@ - (void)testFLTGetStringForUIDeviceOrientation {
XCTAssertEqualObjects(@"portraitDown",
FLTGetStringForUIDeviceOrientation(UIDeviceOrientationPortraitUpsideDown));
XCTAssertEqualObjects(@"landscapeLeft",
FLTGetStringForUIDeviceOrientation(UIDeviceOrientationLandscapeRight));
XCTAssertEqualObjects(@"landscapeRight",
FLTGetStringForUIDeviceOrientation(UIDeviceOrientationLandscapeLeft));
XCTAssertEqualObjects(@"landscapeRight",
FLTGetStringForUIDeviceOrientation(UIDeviceOrientationLandscapeRight));
XCTAssertEqualObjects(@"portraitUp",
FLTGetStringForUIDeviceOrientation(UIDeviceOrientationPortrait));
XCTAssertEqualObjects(@"portraitUp", FLTGetStringForUIDeviceOrientation(-1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ UIDeviceOrientation FLTGetUIDeviceOrientationForString(NSString *orientation) {
if ([orientation isEqualToString:@"portraitDown"]) {
return UIDeviceOrientationPortraitUpsideDown;
} else if ([orientation isEqualToString:@"landscapeLeft"]) {
return UIDeviceOrientationLandscapeRight;
} else if ([orientation isEqualToString:@"landscapeRight"]) {
return UIDeviceOrientationLandscapeLeft;
} else if ([orientation isEqualToString:@"landscapeRight"]) {
return UIDeviceOrientationLandscapeRight;
} else if ([orientation isEqualToString:@"portraitUp"]) {
return UIDeviceOrientationPortrait;
} else {
Expand All @@ -104,9 +104,9 @@ UIDeviceOrientation FLTGetUIDeviceOrientationForString(NSString *orientation) {
switch (orientation) {
case UIDeviceOrientationPortraitUpsideDown:
return @"portraitDown";
case UIDeviceOrientationLandscapeRight:
return @"landscapeLeft";
case UIDeviceOrientationLandscapeLeft:
return @"landscapeLeft";
case UIDeviceOrientationLandscapeRight:
return @"landscapeRight";
case UIDeviceOrientationPortrait:
default:
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_avfoundation/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_avfoundation
description: iOS implementation of the camera plugin.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_avfoundation
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.9.13+6
version: 0.9.13+7

environment:
sdk: ">=2.19.0 <4.0.0"
Expand Down

0 comments on commit 7dff4f1

Please sign in to comment.