cancel flow per design

pull/2/head
Michael Kirk 6 years ago
parent 1a4062dd89
commit 0a32448470

@ -8,6 +8,7 @@ import PromiseKit
protocol ImagePickerGridControllerDelegate: AnyObject {
func imagePickerDidCompleteSelection(_ imagePicker: ImagePickerGridController)
func imagePickerDidCancel(_ imagePicker: ImagePickerGridController)
func imagePicker(_ imagePicker: ImagePickerGridController, isAssetSelected asset: PHAsset) -> Bool
func imagePicker(_ imagePicker: ImagePickerGridController, didSelectAsset asset: PHAsset, attachmentPromise: Promise<SignalAttachment>)
@ -273,7 +274,7 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
@objc
func didPressCancel(sender: UIBarButtonItem) {
self.dismiss(animated: true)
self.delegate?.imagePickerDidCancel(self)
}
// MARK: - Layout

@ -214,6 +214,31 @@ class SendMediaNavigationController: OWSNavigationController {
pushViewController(approvalViewController, animated: true)
updateButtons()
}
private func didRequestExit(dontAbandonText: String) {
if attachmentDraftCollection.count == 0 {
self.sendMediaNavDelegate?.sendMediaNavDidCancel(self)
} else {
let alertTitle = NSLocalizedString("SEND_MEDIA_ABANDON_TITLE", comment: "alert title when user attempts to leave the send media flow when they have an in-progress album")
let alert = UIAlertController(title: alertTitle, message: nil, preferredStyle: .alert)
let confirmAbandonText = NSLocalizedString("SEND_MEDIA_CONFIRM_ABANDON_ALBUM", comment: "alert action, confirming the user wants to exit the media flow and abandon any photos they've taken")
let confirmAbandonAction = UIAlertAction(title: confirmAbandonText,
style: .destructive,
handler: { [weak self] _ in
guard let self = self else { return }
self.sendMediaNavDelegate?.sendMediaNavDidCancel(self)
})
alert.addAction(confirmAbandonAction)
let dontAbandonAction = UIAlertAction(title: dontAbandonText,
style: .default,
handler: { _ in })
alert.addAction(dontAbandonAction)
self.presentAlert(alert)
}
}
}
extension SendMediaNavigationController: UINavigationControllerDelegate {
@ -266,7 +291,8 @@ extension SendMediaNavigationController: PhotoCaptureViewControllerDelegate {
}
func photoCaptureViewControllerDidCancel(_ photoCaptureViewController: PhotoCaptureViewController) {
self.sendMediaNavDelegate?.sendMediaNavDidCancel(self)
let dontAbandonText = NSLocalizedString("SEND_MEDIA_RETURN_TO_CAMERA", comment: "alert action when the user decides not to cancel the media flow after all.")
didRequestExit(dontAbandonText: dontAbandonText)
}
}
@ -276,6 +302,11 @@ extension SendMediaNavigationController: ImagePickerGridControllerDelegate {
showApprovalAfterProcessingAnyMediaLibrarySelections()
}
func imagePickerDidCancel(_ imagePicker: ImagePickerGridController) {
let dontAbandonText = NSLocalizedString("SEND_MEDIA_RETURN_TO_MEDIA_LIBRARY", comment: "alert action when the user decides not to cancel the media flow after all.")
didRequestExit(dontAbandonText: dontAbandonText)
}
func showApprovalAfterProcessingAnyMediaLibrarySelections() {
let mediaLibrarySelections: [MediaLibrarySelection] = self.mediaLibrarySelections.orderedValues

@ -1991,6 +1991,18 @@
/* Text for button to send a Signal invite via SMS. %@ is placeholder for the recipient's phone number. */
"SEND_INVITE_VIA_SMS_BUTTON_FORMAT" = "Invite via SMS: %@";
/* alert title when user attempts to leave the send media flow when they have an in-progress album */
"SEND_MEDIA_ABANDON_TITLE" = "Discard Media?";
/* alert action, confirming the user wants to exit the media flow and abandon any photos they've taken */
"SEND_MEDIA_CONFIRM_ABANDON_ALBUM" = "Discard Media";
/* alert action when the user decides not to cancel the media flow after all. */
"SEND_MEDIA_RETURN_TO_CAMERA" = "Return to Camera";
/* alert action when the user decides not to cancel the media flow after all. */
"SEND_MEDIA_RETURN_TO_MEDIA_LIBRARY" = "Return to Media Library";
/* No comment provided by engineer. */
"SEND_SMS_CONFIRM_TITLE" = "Invite a friend via insecure SMS?";

Loading…
Cancel
Save