-
Notifications
You must be signed in to change notification settings - Fork 25
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
Live Preview #39
Live Preview #39
Conversation
@HungnguyenVN, can you review this pull request? |
Generated by 🚫 Danger |
801aef0
to
d1deed0
Compare
e7d9023
to
f9ab52c
Compare
f9ab52c
to
bcfe885
Compare
bcfe885
to
faddd5f
Compare
@bcylin It seems that the project directories update broke |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Carthage build fails due to the /Users/travis/build/carousell/pickle/Example/Pods/*
cache. Example/Pods/*
are now ignored on the master branch.
CI should pass after removing the ignored directories:
https://travis-ci.org/bcylin/pickle/builds/515880016 @ f9fc024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍 just left some minor suggestions.
Call to AVCaptureDeviceInput will trigger user prompt, which is not what we want here So this code need to move from intiazlier to startSession()
hey @bcylin, thank you for taking your time to review the PR, I've made the changes requested. In addition, I've modified a few other things that need your opinion on. I have commented in the code |
@@ -122,7 +122,7 @@ open class ImagePickerController: UINavigationController { | |||
} | |||
} | |||
|
|||
fileprivate var selectedAssets: [PHAsset] | |||
public private(set) var selectedAssets: [PHAsset] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our new gallery design requires passing selected assets from photo gallery view to camera view so I need to make selectedAssets
in ImagePickerViewController
publicly accessible
Basically we need a way to pass selectedAssets
between a custom camera controller and ImagePickerController
, please refer to the PR's description for details. Let me know if you have a better way to do this, thanks!
func startSession() throws { | ||
guard hasPermssion else { | ||
throw CameraSessionError.noPermission | ||
} | ||
guard | ||
let input = AVCaptureDevice.default(for: .video), | ||
let deviceInput = try? AVCaptureDeviceInput(device: input) else { | ||
throw CameraSessionError.noDeviceInput |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing AVCaptureDeviceInput
in the initializer will prematurely prompt user for permission, so I have moved it to startSession()
instead. We only use the live view when user has already granted permission previously
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite an interesting camera flow!
@@ -19,6 +19,9 @@ public protocol ImagePickerControllerDelegate: UINavigationControllerDelegate { | |||
/// Asks the delegate if the image picker should launch camera with certain permission status. | |||
func imagePickerController(_ picker: ImagePickerController, shouldLaunchCameraWithAuthorization status: AVAuthorizationStatus) -> Bool | |||
|
|||
/// Tells the delegate that picker has finished launching camera with an array of selected assets | |||
@objc optional func imagePickerController(_ picker: ImagePickerController, didFinishLaunchingCameraWith assets: [PHAsset]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be imagePickerControllerdidFinishLaunchingCamera(_:)
since the selectedAssets
is now accessible from ImagePickerController
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no, I have changed it back to private
since we already have this delegate
if traitCollection.forceTouchCapability == .available { | ||
registerForPreviewing(with: self, sourceView: collectionView) | ||
} | ||
if configuration?.isLiveCameraViewEnabled == .some(true) { | ||
sessionHandler = try? CameraSessionHandler() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AVCaptureDeviceInput
is moved to startSession()
, maybe the initializer doesn't have to throw an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's throwing .noPermission
error if there is no permission, should I change it to just return nil
with init?()
?
@@ -209,6 +209,10 @@ open class ImagePickerController: UINavigationController { | |||
showPermissionErrorIfNeeded?() | |||
} | |||
|
|||
public func updateSelectedAssets(with assets: [PHAsset]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be good to have the documentation of this method, also worth mentioning that this method won't trigger the didSelect
and didDeselectImageAsset
delegate methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated README
Thanks @bcylin! I'll merge it and create a new release |
PhotoGalleryViewController
if there is camera access permissionPhotoGalleryViewController
that allowsselectedAssets
to be passed between the 2, using:ImagePickerControllerDelegate
updateSelectedAssets(_ assets: [PHAsset])
that will replace existing assets inImagePickerControlelr
since custom camera controller can modify selected assets as well