Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial support for visionOS #572

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Objective-C/TOCropViewController/TOCropViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ - (void)viewWillAppear:(BOOL)animated
// so we can manually control the status bar fade out timing
if (animated) {
self.inTransition = YES;
#if TARGET_OS_IOS
[self setNeedsStatusBarAppearanceUpdate];
#endif
}

// If this controller is pushed onto a navigation stack, set flags noting the
Expand Down Expand Up @@ -186,7 +188,9 @@ - (void)viewDidAppear:(BOOL)animated
// Now that the presentation animation will have finished, animate
// the status bar fading out, and if present, the title label fading in
void (^updateContentBlock)(void) = ^{
#if TARGET_OS_IOS
[self setNeedsStatusBarAppearanceUpdate];
#endif
self.titleLabel.alpha = 1.0f;
};

Expand Down Expand Up @@ -214,8 +218,10 @@ - (void)viewWillDisappear:(BOOL)animated

// Set the transition flag again so we can defer the status bar
self.inTransition = YES;
#if TARGET_OS_IOS
[UIView animateWithDuration:0.5f animations:^{ [self setNeedsStatusBarAppearanceUpdate]; }];

#endif

// Restore the navigation controller to its state before we were presented
if (self.navigationController && self.hidesNavigationBar) {
[self.navigationController setNavigationBarHidden:self.navigationBarHidden animated:animated];
Expand All @@ -229,7 +235,9 @@ - (void)viewDidDisappear:(BOOL)animated

// Reset the state once the view has gone offscreen
self.inTransition = NO;
#if TARGET_OS_IOS
[self setNeedsStatusBarAppearanceUpdate];
#endif
}

#pragma mark - Status Bar -
Expand Down
2 changes: 1 addition & 1 deletion Objective-C/TOCropViewController/Views/TOCropOverlayView.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ - (void)layoutLines
}

//grid lines - horizontal
CGFloat thickness = 1.0f / [[UIScreen mainScreen] scale];
CGFloat thickness = 1.0f / self.traitCollection.displayScale;
NSInteger numberOfLines = self.horizontalGridLines.count;
CGFloat padding = (CGRectGetHeight(self.bounds) - (thickness*numberOfLines)) / (numberOfLines + 1);
for (NSInteger i = 0; i < numberOfLines; i++) {
Expand Down
4 changes: 4 additions & 0 deletions Objective-C/TOCropViewControllerExample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,17 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking

//If profile picture, push onto the same navigation stack
if (self.croppingStyle == TOCropViewCroppingStyleCircular) {
#if TARGET_OS_IOS
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
[picker dismissViewControllerAnimated:YES completion:^{
[self presentViewController:cropController animated:YES completion:nil];
}];
} else {
#endif
[picker pushViewController:cropController animated:YES];
#if TARGET_OS_IOS
}
#endif
}
else { //otherwise dismiss, and then present from the main controller
[picker dismissViewControllerAnimated:YES completion:^{
Expand Down
30 changes: 28 additions & 2 deletions TOCropViewControllerExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,10 @@
PRODUCT_BUNDLE_IDENTIFIER = dev.tim.TOCropViewController;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = YES;
TARGETED_DEVICE_FAMILY = "1,2,7";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -1042,6 +1046,10 @@
PRODUCT_BUNDLE_IDENTIFIER = dev.tim.TOCropViewController;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = YES;
TARGETED_DEVICE_FAMILY = "1,2,7";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -1067,6 +1075,9 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "com.timoliver.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
TARGETED_DEVICE_FAMILY = "1,2,7";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TOCropViewControllerExample.app/TOCropViewControllerExample";
};
name = Debug;
Expand All @@ -1087,6 +1098,9 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "com.timoliver.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
TARGETED_DEVICE_FAMILY = "1,2,7";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TOCropViewControllerExample.app/TOCropViewControllerExample";
};
name = Release;
Expand Down Expand Up @@ -1223,7 +1237,9 @@
);
PRODUCT_BUNDLE_IDENTIFIER = dev.tim.TOCropViewControllerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Debug;
};
Expand All @@ -1246,7 +1262,9 @@
);
PRODUCT_BUNDLE_IDENTIFIER = dev.tim.TOCropViewControllerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Release;
};
Expand Down Expand Up @@ -1342,8 +1360,10 @@
PRODUCT_BUNDLE_IDENTIFIER = dev.tim.CropViewController;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,7";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -1385,8 +1405,10 @@
PRODUCT_BUNDLE_IDENTIFIER = dev.tim.CropViewController;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_COMPILATION_MODE = wholemodule;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,7";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -1419,7 +1441,9 @@
PRODUCT_BUNDLE_IDENTIFIER = "dev.tim.TOCropViewControllerExample.TOCropViewController-ShareExtension";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Debug;
};
Expand All @@ -1446,7 +1470,9 @@
PRODUCT_BUNDLE_IDENTIFIER = "dev.tim.TOCropViewControllerExample.TOCropViewController-ShareExtension";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Release;
};
Expand Down