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

Initial visionOS support #59

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
64 changes: 52 additions & 12 deletions Tatsi.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -19,8 +19,8 @@
0C5B61491F0D2293005A25CE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C5B61481F0D2293005A25CE /* ViewController.swift */; };
0C5B614E1F0D2293005A25CE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0C5B614D1F0D2293005A25CE /* Assets.xcassets */; };
0C5B61611F0D231E005A25CE /* Tatsi.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C5B615F1F0D231D005A25CE /* Tatsi.h */; settings = {ATTRIBUTES = (Public, ); }; };
0C5B61641F0D231E005A25CE /* Tatsi.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0C5B615D1F0D231D005A25CE /* Tatsi.framework */; };
0C5B61651F0D231E005A25CE /* Tatsi.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 0C5B615D1F0D231D005A25CE /* Tatsi.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
0C5B61641F0D231E005A25CE /* Tatsi.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0C5B615D1F0D231D005A25CE /* Tatsi.framework */; platformFilter = ios; };
0C5B61651F0D231E005A25CE /* Tatsi.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 0C5B615D1F0D231D005A25CE /* Tatsi.framework */; platformFilter = ios; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
0C5B61781F0D250F005A25CE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0C5B61741F0D250F005A25CE /* LaunchScreen.storyboard */; };
0C5B61791F0D250F005A25CE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0C5B61761F0D250F005A25CE /* Main.storyboard */; };
0C5B617B1F0E302C005A25CE /* TatsiPickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C5B617A1F0E302C005A25CE /* TatsiPickerViewController.swift */; };
Expand Down Expand Up @@ -558,6 +558,7 @@
};
0C5B61631F0D231E005A25CE /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
platformFilter = ios;
target = 0C5B615C1F0D231D005A25CE /* Tatsi */;
targetProxy = 0C5B61621F0D231E005A25CE /* PBXContainerItemProxy */;
};
Expand Down Expand Up @@ -589,10 +590,17 @@
DEVELOPMENT_TEAM = N4KR5KV52L;
INFOPLIST_FILE = TatsiTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = co.awkward.TatsiTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,7";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Tatsi Example.app/Tatsi Example";
};
name = Debug;
Expand All @@ -603,10 +611,17 @@
DEVELOPMENT_TEAM = N4KR5KV52L;
INFOPLIST_FILE = TatsiTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = co.awkward.TatsiTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,7";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Tatsi Example.app/Tatsi Example";
};
name = Release;
Expand Down Expand Up @@ -717,7 +732,8 @@
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -730,10 +746,16 @@
DEVELOPMENT_TEAM = N4KR5KV52L;
INFOPLIST_FILE = Example/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "co.awkward.tatsi-example";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,7";
};
name = Debug;
};
Expand All @@ -745,10 +767,16 @@
DEVELOPMENT_TEAM = N4KR5KV52L;
INFOPLIST_FILE = Example/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "co.awkward.tatsi-example";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,7";
};
name = Release;
};
Expand All @@ -766,13 +794,19 @@
INFOPLIST_FILE = Tatsi/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = co.awkward.tatsi;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,7";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -792,12 +826,18 @@
INFOPLIST_FILE = Tatsi/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = co.awkward.tatsi;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,7";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down
7 changes: 6 additions & 1 deletion Tatsi/Extensions/PHAssetCollectionExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ extension PHAssetCollection {
let requestOptions = PHImageRequestOptions()
requestOptions.isSynchronous = false
requestOptions.resizeMode = PHImageRequestOptionsResizeMode.exact
PHImageManager.default().requestImage(for: asset, targetSize: targetSize.scaled(with: UIScreen.main.scale), contentMode: PHImageContentMode.aspectFill, options: requestOptions, resultHandler: { (image, _) in
#if !os(visionOS)
let scale = UIScreen.main.scale
#else
let scale = CGFloat(1)
#endif
PHImageManager.default().requestImage(for: asset, targetSize: targetSize.scaled(with: scale), contentMode: PHImageContentMode.aspectFill, options: requestOptions, resultHandler: { (image, _) in
DispatchQueue.main.async {
completionHandler(image, asset)
}
Expand Down
9 changes: 7 additions & 2 deletions Tatsi/UIElements/AlbumImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ final internal class AlbumImageView: UIView {
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func draw(_ rect: CGRect) {
#if !os(visionOS)
let scale = UIScreen.main.scale
#else
let scale = CGFloat(1)
#endif
// Drawing code
let firstLinePath = UIBezierPath(rect: CGRect(x: 7, y: 0, width: rect.width - ( 7 * 2 ), height: 1 / UIScreen.main.scale))
let firstLinePath = UIBezierPath(rect: CGRect(x: 7, y: 0, width: rect.width - ( 7 * 2 ), height: 1 / scale))
self.linesColor.withAlphaComponent(0.4).setFill()
firstLinePath.fill()

let secondLinePath = UIBezierPath(rect: CGRect(x: 4, y: 2, width: rect.width - ( 4 * 2 ), height: 1 / UIScreen.main.scale))
let secondLinePath = UIBezierPath(rect: CGRect(x: 4, y: 2, width: rect.width - ( 4 * 2 ), height: 1 / scale))
self.linesColor.withAlphaComponent(0.6).setFill()
secondLinePath.fill()
}
Expand Down
8 changes: 8 additions & 0 deletions Tatsi/Views/Assets Grid/AssetsGridViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ final internal class AssetsGridViewController: UICollectionViewController, Picke
// MARK: - Private Properties

fileprivate var showCameraButton: Bool {
#if os(visionOS)
return false
#else
guard self.album.isUserLibrary, UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.camera) else {
return false
}
return self.config?.showCameraOption ?? false
#endif
}

fileprivate var emptyView: AlbumEmptyView? {
Expand Down Expand Up @@ -327,7 +331,9 @@ final internal class AssetsGridViewController: UICollectionViewController, Picke

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
#if !os(visionOS)
self.emptyView?.layoutMargins = UIEdgeInsets(top: self.topLayoutGuide.length + 20, left: 20, bottom: self.bottomLayoutGuide.length + 20, right: 20)
#endif
}

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
Expand Down Expand Up @@ -463,11 +469,13 @@ extension AssetsGridViewController {
}
}
} else {
#if !os(visionOS)
let cameraController = UIImagePickerController()
cameraController.sourceType = UIImagePickerController.SourceType.camera
cameraController.delegate = self
self.present(cameraController, animated: true, completion: nil)
collectionView.deselectItem(at: indexPath, animated: true)
#endif
}
}

Expand Down
4 changes: 4 additions & 0 deletions Tatsi/Views/Assets Grid/Cells/AssetCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ final internal class AssetCollectionViewCell: UICollectionViewCell {
self.imageView.image = nil
DispatchQueue.global(qos: .userInteractive).async { [weak self] in
autoreleasepool {
#if !os(visionOS)
let scale = UIScreen.main.scale > 2 ? 2 : UIScreen.main.scale
#else
let scale = CGFloat(1)
#endif
guard let targetSize = self?.imageSize.scaled(with: scale), self?.asset?.localIdentifier == asset.localIdentifier else {
return
}
Expand Down
4 changes: 3 additions & 1 deletion Tatsi/Views/AuthorizationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@ final internal class AuthorizationViewController: UIViewController, PickerViewCo
guard let url = URL(string: UIApplication.openSettingsURLString) else {
return
}
if #available(iOS 10, *) {
if #available(iOS 10, visionOS 1, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
#if !os(visionOS)
UIApplication.shared.openURL(url)
#endif
}

}
Expand Down