From c0997c83354c4f7261ba71f7d9a905580f97bb7f Mon Sep 17 00:00:00 2001 From: Sam Wyndham Date: Tue, 29 Oct 2024 10:20:19 +0100 Subject: [PATCH 1/7] Delete `SettingsExternalScreenCellDescriptorType` This abstract type is not referenced and it's conformance limits flexibility fixing this bug --- .../CellDescriptors/SettingsAppearanceCellDescriptor.swift | 2 +- .../Settings/CellDescriptors/SettingsCellDescriptor.swift | 4 ---- .../SettingsExternalScreenCellDescriptor.swift | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsAppearanceCellDescriptor.swift b/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsAppearanceCellDescriptor.swift index df44ffb1236..60fcbc3cf73 100644 --- a/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsAppearanceCellDescriptor.swift +++ b/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsAppearanceCellDescriptor.swift @@ -21,7 +21,7 @@ import UIKit import WireSettingsUI import WireSyncEngine -class SettingsAppearanceCellDescriptor: SettingsCellDescriptorType, SettingsExternalScreenCellDescriptorType { +class SettingsAppearanceCellDescriptor: SettingsGroupCellDescriptorType, SettingsCellDescriptorType { static let cellType: SettingsTableCellProtocol.Type = SettingsAppearanceCell.self private var text: String diff --git a/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsCellDescriptor.swift b/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsCellDescriptor.swift index 372937e4efb..718873a7e1b 100644 --- a/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsCellDescriptor.swift +++ b/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsCellDescriptor.swift @@ -115,10 +115,6 @@ extension SettingsInternalGroupCellDescriptorType { } } -protocol SettingsExternalScreenCellDescriptorType: SettingsGroupCellDescriptorType { - var presentationAction: () -> (UIViewController?) {get} -} - protocol SettingsPropertyCellDescriptorType: SettingsCellDescriptorType { var settingsProperty: SettingsProperty { get } } diff --git a/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsExternalScreenCellDescriptor.swift b/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsExternalScreenCellDescriptor.swift index 0d5d23f1775..235903d2dbf 100644 --- a/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsExternalScreenCellDescriptor.swift +++ b/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsExternalScreenCellDescriptor.swift @@ -33,7 +33,7 @@ enum AccessoryViewMode: Int { case alwaysHide } -class SettingsExternalScreenCellDescriptor: SettingsExternalScreenCellDescriptorType, SettingsControllerGeneratorType { +class SettingsExternalScreenCellDescriptor: SettingsGroupCellDescriptorType, SettingsControllerGeneratorType { static let cellType: SettingsTableCellProtocol.Type = SettingsTableCell.self var visible: Bool = true let title: String From 7b5a32e5602695f75bc776c55260f10cc5aa04f4 Mon Sep 17 00:00:00 2001 From: Sam Wyndham Date: Tue, 29 Oct 2024 15:42:25 +0100 Subject: [PATCH 2/7] Add `isIPad` method --- .../UserInterface/Helpers/UITraitEnvironment+SizeClass.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wire-ios/Wire-iOS/Sources/UserInterface/Helpers/UITraitEnvironment+SizeClass.swift b/wire-ios/Wire-iOS/Sources/UserInterface/Helpers/UITraitEnvironment+SizeClass.swift index 6ef424b0f0a..5db4fce3457 100644 --- a/wire-ios/Wire-iOS/Sources/UserInterface/Helpers/UITraitEnvironment+SizeClass.swift +++ b/wire-ios/Wire-iOS/Sources/UserInterface/Helpers/UITraitEnvironment+SizeClass.swift @@ -29,6 +29,10 @@ extension UITraitEnvironment { return device.userInterfaceIdiom == .pad && isHorizontalSizeClassRegular } + func isIPad(device: DeviceAbstraction = DeviceWrapper(device: .current)) -> Bool { + return device.userInterfaceIdiom == .pad + } + func isIPadRegularPortrait( device: DeviceAbstraction = DeviceWrapper(device: .current) ) -> Bool { From 13ce71bbb3e60edd2203636be0905dfccfaaebb7 Mon Sep 17 00:00:00 2001 From: Sam Wyndham Date: Tue, 29 Oct 2024 15:45:12 +0100 Subject: [PATCH 3/7] Pass the source popover source view through to popover controller Also ensure a popover is always used for iPad --- .../Managers/Image/ImagePickerManager.swift | 49 +++++++++---------- .../Image/ProfileImagePickerManager.swift | 13 +++-- .../SelfProfileViewController.swift | 6 +-- .../SettingsAppearanceCellDescriptor.swift | 10 ++-- ...ettingsCellDescriptorFactory+Account.swift | 6 +-- 5 files changed, 41 insertions(+), 43 deletions(-) diff --git a/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift b/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift index 35848c50130..2a4d7b73e41 100644 --- a/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift +++ b/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift @@ -39,16 +39,19 @@ class ImagePickerManager: NSObject { private let mediaShareRestrictionManager = MediaShareRestrictionManager(sessionRestriction: ZMUserSession.shared()) // MARK: - Methods - func showActionSheet(on viewController: UIViewController? = UIApplication.shared.topmostViewController(onlyFullScreen: false), - completion: @escaping (UIImage) -> Void) -> UIAlertController { + func showActionSheet( + on viewController: UIViewController? = UIApplication.shared.topmostViewController(onlyFullScreen: false), + popoverSourceView: UIView, + completion: @escaping (UIImage) -> Void + ) -> UIAlertController { self.completion = completion self.viewController = viewController - let actionSheet = imagePickerAlert() + let actionSheet = imagePickerAlert(popoverSourceView: popoverSourceView) return actionSheet } - private func imagePickerAlert() -> UIAlertController { + private func imagePickerAlert(popoverSourceView: UIView) -> UIAlertController { typealias Alert = L10n.Localizable.Self.Settings.AccountPictureGroup.Alert let actionSheet = UIAlertController(title: Alert.title, message: nil, @@ -58,7 +61,10 @@ class ImagePickerManager: NSObject { if mediaShareRestrictionManager.isPhotoLibraryEnabled { let galleryAction = UIAlertAction(title: Alert.choosePicture, style: .default) { [weak self] _ in self?.sourceType = .photoLibrary - self?.getImage(fromSourceType: .photoLibrary) + self?.getImage( + fromSourceType: .photoLibrary, + popoverSourceView: popoverSourceView + ) } actionSheet.addAction(galleryAction) } @@ -66,7 +72,10 @@ class ImagePickerManager: NSObject { // Take photo let cameraAction = UIAlertAction(title: Alert.takePicture, style: .default) { [weak self] _ in self?.sourceType = .camera - self?.getImage(fromSourceType: .camera) + self?.getImage( + fromSourceType: .camera, + popoverSourceView: popoverSourceView + ) } actionSheet.addAction(cameraAction) @@ -76,11 +85,11 @@ class ImagePickerManager: NSObject { return actionSheet } - private func getImage(fromSourceType sourceType: UIImagePickerController.SourceType) { - guard UIImagePickerController.isSourceTypeAvailable(sourceType), - let viewController else { - return - } + private func getImage( + fromSourceType sourceType: UIImagePickerController.SourceType, + popoverSourceView: UIView + ) { + guard UIImagePickerController.isSourceTypeAvailable(sourceType), let viewController else { return } let imagePickerController = UIImagePickerController() imagePickerController.delegate = self @@ -96,23 +105,13 @@ class ImagePickerManager: NSObject { imagePickerController.cameraDevice = .front imagePickerController.modalTransitionStyle = .coverVertical case .photoLibrary, .savedPhotosAlbum: - if viewController.isIPadRegular() { + if viewController.isIPad() { + // UIKit will crash if the photo library is not presented using a popoverPresentationController on iPad + // https://developer.apple.com/documentation/uikit/uiimagepickercontroller imagePickerController.modalPresentationStyle = .popover - if let popoverPresentationController = imagePickerController.popoverPresentationController { popoverPresentationController.backgroundColor = UIColor.white - - // UIKit will crash if the photo library is not presented using a popoverPresentationController - // https://developer.apple.com/documentation/uikit/uiimagepickercontroller - // TODO: [WPB-11605] fix this workaround and choose proper sourceView/sourceRect - popoverPresentationController.sourceView = viewController.view - popoverPresentationController.sourceRect = .init( - origin: .init( - x: viewController.view.safeAreaLayoutGuide.layoutFrame.maxX, - y: viewController.view.safeAreaLayoutGuide.layoutFrame.minY - ), - size: .zero - ) + popoverPresentationController.sourceView = popoverSourceView } } default: diff --git a/wire-ios/Wire-iOS/Sources/Managers/Image/ProfileImagePickerManager.swift b/wire-ios/Wire-iOS/Sources/Managers/Image/ProfileImagePickerManager.swift index f65e791057b..d4365ef50c9 100644 --- a/wire-ios/Wire-iOS/Sources/Managers/Image/ProfileImagePickerManager.swift +++ b/wire-ios/Wire-iOS/Sources/Managers/Image/ProfileImagePickerManager.swift @@ -21,14 +21,13 @@ import WireSyncEngine final class ProfileImagePickerManager: ImagePickerManager { - func selectProfileImage() -> UIAlertController { - let actionSheet = showActionSheet { image in - guard let jpegData = image.jpegData else { - return + func selectProfileImage(popoverSourceView: UIView) -> UIAlertController { + let actionSheet = showActionSheet(popoverSourceView: popoverSourceView) { image in + guard let jpegData = image.jpegData, let session = ZMUserSession.shared() else { return } + + session.enqueue { + session.userProfileImage.updateImage(imageData: jpegData) } - ZMUserSession.shared()?.enqueue({ - ZMUserSession.shared()?.userProfileImage.updateImage(imageData: jpegData) - }) } return actionSheet } diff --git a/wire-ios/Wire-iOS/Sources/UserInterface/SelfProfile/SelfProfileViewController.swift b/wire-ios/Wire-iOS/Sources/UserInterface/SelfProfile/SelfProfileViewController.swift index f13202738e4..be2d4e6576b 100644 --- a/wire-ios/Wire-iOS/Sources/UserInterface/SelfProfile/SelfProfileViewController.swift +++ b/wire-ios/Wire-iOS/Sources/UserInterface/SelfProfile/SelfProfileViewController.swift @@ -206,10 +206,10 @@ final class SelfProfileViewController: UIViewController { @objc private func userDidTapProfileImage(_ sender: UIGestureRecognizer) { guard userRightInterfaceType.selfUserIsPermitted(to: .editProfilePicture) else { return } - let alertController = profileImagePicker.selectProfileImage() + let imageView = profileHeaderViewController.imageView + let alertController = profileImagePicker.selectProfileImage(popoverSourceView: imageView) if let popoverPresentationController = alertController.popoverPresentationController { - popoverPresentationController.sourceView = profileHeaderViewController.imageView.superview! - popoverPresentationController.sourceRect = profileHeaderViewController.imageView.frame.insetBy(dx: -4, dy: -4) + popoverPresentationController.sourceView = imageView } present(alertController, animated: true) } diff --git a/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsAppearanceCellDescriptor.swift b/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsAppearanceCellDescriptor.swift index 60fcbc3cf73..f06c1bc1d56 100644 --- a/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsAppearanceCellDescriptor.swift +++ b/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsAppearanceCellDescriptor.swift @@ -28,7 +28,7 @@ class SettingsAppearanceCellDescriptor: SettingsGroupCellDescriptorType, Setting private let presentationStyle: PresentationStyle weak var viewController: UIViewController? - let presentationAction: () -> (UIViewController?) + let presentationAction: (_ sender: UIView) -> UIViewController? var identifier: String? weak var group: SettingsGroupCellDescriptorType? @@ -48,7 +48,7 @@ class SettingsAppearanceCellDescriptor: SettingsGroupCellDescriptorType, Setting text: String, previewGenerator: PreviewGeneratorType? = .none, presentationStyle: PresentationStyle, - presentationAction: @escaping () -> (UIViewController?), + presentationAction: @escaping (_ sender: UIView) -> UIViewController?, settingsCoordinator: AnySettingsCoordinator ) { self.text = text @@ -81,7 +81,7 @@ class SettingsAppearanceCellDescriptor: SettingsGroupCellDescriptorType, Setting // MARK: - SettingsCellDescriptorType func select(_ value: SettingsPropertyValue, sender: UIView) { - guard let controllerToShow = generateViewController() else { return } + guard let controllerToShow = generateViewController(sender: sender) else { return } switch presentationStyle { case .alert: @@ -97,7 +97,7 @@ class SettingsAppearanceCellDescriptor: SettingsGroupCellDescriptorType, Setting } } - func generateViewController() -> UIViewController? { - presentationAction() + private func generateViewController(sender: UIView) -> UIViewController? { + presentationAction(sender) } } diff --git a/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsCellDescriptorFactory+Account.swift b/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsCellDescriptorFactory+Account.swift index 65f4fcfec4d..677ff25d070 100644 --- a/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsCellDescriptorFactory+Account.swift +++ b/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsCellDescriptorFactory+Account.swift @@ -300,8 +300,8 @@ extension SettingsCellDescriptorFactory { return .image(image) } - let presentationAction: () -> (UIViewController?) = { - let actionSheet = profileImagePicker.selectProfileImage() + let presentationAction: (_ sender: UIView) -> UIViewController? = { sender in + let actionSheet = profileImagePicker.selectProfileImage(popoverSourceView: sender) return actionSheet } return SettingsAppearanceCellDescriptor( @@ -331,7 +331,7 @@ extension SettingsCellDescriptorFactory { return SettingsCellPreview.color((selfUser.accentColor ?? .default).uiColor) } - private func colorElementPresentationAction() -> UIViewController { + private func colorElementPresentationAction(sender: UIView) -> UIViewController { guard let selfUser = ZMUser.selfUser(), let userSession = ZMUserSession.shared() From fb95b2e2c10d75ae3f8b1f98fa41e000917a4148 Mon Sep 17 00:00:00 2001 From: Sam Wyndham Date: Tue, 29 Oct 2024 15:46:24 +0100 Subject: [PATCH 4/7] Remove `ImagePickerManager.sourceType` This variable is not read --- .../Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift b/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift index 2a4d7b73e41..4d0eb046bbe 100644 --- a/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift +++ b/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift @@ -34,7 +34,6 @@ class ImagePickerManager: NSObject { // MARK: - Properties private weak var viewController: UIViewController? - private var sourceType: UIImagePickerController.SourceType? private var completion: ((UIImage) -> Void)? private let mediaShareRestrictionManager = MediaShareRestrictionManager(sessionRestriction: ZMUserSession.shared()) @@ -60,7 +59,6 @@ class ImagePickerManager: NSObject { // Choose from gallery option, if security flag enabled if mediaShareRestrictionManager.isPhotoLibraryEnabled { let galleryAction = UIAlertAction(title: Alert.choosePicture, style: .default) { [weak self] _ in - self?.sourceType = .photoLibrary self?.getImage( fromSourceType: .photoLibrary, popoverSourceView: popoverSourceView @@ -71,7 +69,6 @@ class ImagePickerManager: NSObject { // Take photo let cameraAction = UIAlertAction(title: Alert.takePicture, style: .default) { [weak self] _ in - self?.sourceType = .camera self?.getImage( fromSourceType: .camera, popoverSourceView: popoverSourceView From a9a55f995c1c0afd6dc315a595c7c9efaa610d9b Mon Sep 17 00:00:00 2001 From: Sam Wyndham Date: Tue, 29 Oct 2024 15:54:00 +0100 Subject: [PATCH 5/7] Remove `ImagePickerManager.viewController` property --- .../Managers/Image/ImagePickerManager.swift | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift b/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift index 4d0eb046bbe..58abb76299c 100644 --- a/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift +++ b/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift @@ -33,7 +33,6 @@ extension UIImage { class ImagePickerManager: NSObject { // MARK: - Properties - private weak var viewController: UIViewController? private var completion: ((UIImage) -> Void)? private let mediaShareRestrictionManager = MediaShareRestrictionManager(sessionRestriction: ZMUserSession.shared()) @@ -44,13 +43,12 @@ class ImagePickerManager: NSObject { completion: @escaping (UIImage) -> Void ) -> UIAlertController { self.completion = completion - self.viewController = viewController - let actionSheet = imagePickerAlert(popoverSourceView: popoverSourceView) + let actionSheet = imagePickerAlert(popoverSourceView: popoverSourceView, viewController: viewController) return actionSheet } - private func imagePickerAlert(popoverSourceView: UIView) -> UIAlertController { + private func imagePickerAlert(popoverSourceView: UIView, viewController: UIViewController?) -> UIAlertController { typealias Alert = L10n.Localizable.Self.Settings.AccountPictureGroup.Alert let actionSheet = UIAlertController(title: Alert.title, message: nil, @@ -59,8 +57,11 @@ class ImagePickerManager: NSObject { // Choose from gallery option, if security flag enabled if mediaShareRestrictionManager.isPhotoLibraryEnabled { let galleryAction = UIAlertAction(title: Alert.choosePicture, style: .default) { [weak self] _ in - self?.getImage( + guard let self, let viewController else { return } + + self.getImage( fromSourceType: .photoLibrary, + viewController: viewController, popoverSourceView: popoverSourceView ) } @@ -69,8 +70,11 @@ class ImagePickerManager: NSObject { // Take photo let cameraAction = UIAlertAction(title: Alert.takePicture, style: .default) { [weak self] _ in - self?.getImage( + guard let self, let viewController else { return } + + self.getImage( fromSourceType: .camera, + viewController: viewController, popoverSourceView: popoverSourceView ) } @@ -84,9 +88,10 @@ class ImagePickerManager: NSObject { private func getImage( fromSourceType sourceType: UIImagePickerController.SourceType, + viewController: UIViewController, popoverSourceView: UIView ) { - guard UIImagePickerController.isSourceTypeAvailable(sourceType), let viewController else { return } + guard UIImagePickerController.isSourceTypeAvailable(sourceType) else { return } let imagePickerController = UIImagePickerController() imagePickerController.delegate = self From c6a5c7bda430113f08e6cda75818b19e60766e12 Mon Sep 17 00:00:00 2001 From: Sam Wyndham Date: Mon, 18 Nov 2024 16:37:12 +0100 Subject: [PATCH 6/7] Use `PopoverPresentationControllerConfiguration` --- .../Managers/Image/ImagePickerManager.swift | 21 ++++++++++--------- .../Image/ProfileImagePickerManager.swift | 4 ++-- .../SelfProfileViewController.swift | 4 +++- ...ettingsCellDescriptorFactory+Account.swift | 4 +++- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift b/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift index 1f9f360e530..2897e64e080 100644 --- a/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift +++ b/wire-ios/Wire-iOS/Sources/Managers/Image/ImagePickerManager.swift @@ -41,15 +41,18 @@ class ImagePickerManager: NSObject { func showActionSheet( on viewController: UIViewController? = UIApplication.shared.topmostViewController(onlyFullScreen: false), - popoverSourceView: UIView, + popoverConfiguration: PopoverPresentationControllerConfiguration, completion: @escaping (UIImage) -> Void ) -> UIAlertController { self.completion = completion - return imagePickerAlert(popoverSourceView: popoverSourceView, viewController: viewController) + return imagePickerAlert(viewController: viewController, popoverConfiguration: popoverConfiguration) } - private func imagePickerAlert(popoverSourceView: UIView, viewController: UIViewController?) -> UIAlertController { + private func imagePickerAlert( + viewController: UIViewController?, + popoverConfiguration: PopoverPresentationControllerConfiguration + ) -> UIAlertController { typealias Alert = L10n.Localizable.Self.Settings.AccountPictureGroup.Alert let actionSheet = UIAlertController( title: Alert.title, @@ -65,7 +68,7 @@ class ImagePickerManager: NSObject { getImage( fromSourceType: .photoLibrary, viewController: viewController, - popoverSourceView: popoverSourceView + popoverConfiguration: popoverConfiguration ) } actionSheet.addAction(galleryAction) @@ -78,7 +81,7 @@ class ImagePickerManager: NSObject { getImage( fromSourceType: .camera, viewController: viewController, - popoverSourceView: popoverSourceView + popoverConfiguration: popoverConfiguration ) } actionSheet.addAction(cameraAction) @@ -92,7 +95,7 @@ class ImagePickerManager: NSObject { private func getImage( fromSourceType sourceType: UIImagePickerController.SourceType, viewController: UIViewController, - popoverSourceView: UIView + popoverConfiguration: PopoverPresentationControllerConfiguration ) { guard UIImagePickerController.isSourceTypeAvailable(sourceType) else { return } @@ -114,10 +117,8 @@ class ImagePickerManager: NSObject { // UIKit will crash if the photo library is not presented using a popoverPresentationController on iPad // https://developer.apple.com/documentation/uikit/uiimagepickercontroller imagePickerController.modalPresentationStyle = .popover - if let popoverPresentationController = imagePickerController.popoverPresentationController { - popoverPresentationController.backgroundColor = UIColor.white - popoverPresentationController.sourceView = popoverSourceView - } + imagePickerController.popoverPresentationController?.backgroundColor = .white + imagePickerController.configurePopoverPresentationController(using: popoverConfiguration) } default: break diff --git a/wire-ios/Wire-iOS/Sources/Managers/Image/ProfileImagePickerManager.swift b/wire-ios/Wire-iOS/Sources/Managers/Image/ProfileImagePickerManager.swift index f98aadcab0d..4af3b594bfe 100644 --- a/wire-ios/Wire-iOS/Sources/Managers/Image/ProfileImagePickerManager.swift +++ b/wire-ios/Wire-iOS/Sources/Managers/Image/ProfileImagePickerManager.swift @@ -21,8 +21,8 @@ import WireSyncEngine final class ProfileImagePickerManager: ImagePickerManager { - func selectProfileImage(popoverSourceView: UIView) -> UIAlertController { - showActionSheet(popoverSourceView: popoverSourceView) { image in + func selectProfileImage(popoverConfiguration: PopoverPresentationControllerConfiguration) -> UIAlertController { + showActionSheet(popoverConfiguration: popoverConfiguration) { image in guard let jpegData = image.jpegData, let session = ZMUserSession.shared() else { return } session.enqueue { diff --git a/wire-ios/Wire-iOS/Sources/UserInterface/SelfProfile/SelfProfileViewController.swift b/wire-ios/Wire-iOS/Sources/UserInterface/SelfProfile/SelfProfileViewController.swift index ee3c121a8ad..b2d60126a85 100644 --- a/wire-ios/Wire-iOS/Sources/UserInterface/SelfProfile/SelfProfileViewController.swift +++ b/wire-ios/Wire-iOS/Sources/UserInterface/SelfProfile/SelfProfileViewController.swift @@ -209,7 +209,9 @@ final class SelfProfileViewController: UIViewController { guard userRightInterfaceType.selfUserIsPermitted(to: .editProfilePicture) else { return } let imageView = profileHeaderViewController.imageView - let alertController = profileImagePicker.selectProfileImage(popoverSourceView: imageView) + let alertController = profileImagePicker.selectProfileImage( + popoverConfiguration: .sourceView(sourceView: imageView, sourceRect: .null) + ) if let popoverPresentationController = alertController.popoverPresentationController { popoverPresentationController.sourceView = imageView } diff --git a/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsCellDescriptorFactory+Account.swift b/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsCellDescriptorFactory+Account.swift index cee7d0f6fb6..7f56b11efbe 100644 --- a/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsCellDescriptorFactory+Account.swift +++ b/wire-ios/Wire-iOS/Sources/UserInterface/Settings/CellDescriptors/SettingsCellDescriptorFactory+Account.swift @@ -305,7 +305,9 @@ extension SettingsCellDescriptorFactory { } let presentationAction: (_ sender: UIView) -> UIViewController? = { sender in - profileImagePicker.selectProfileImage(popoverSourceView: sender) + profileImagePicker.selectProfileImage( + popoverConfiguration: .sourceView(sourceView: sender, sourceRect: .null) + ) } return SettingsAppearanceCellDescriptor( text: L10n.Localizable.Self.Settings.AccountPictureGroup.picture.capitalized, From b013ec3f5594d4e630f7b8396e0b569e24d5b94f Mon Sep 17 00:00:00 2001 From: Sam Wyndham Date: Mon, 18 Nov 2024 16:43:32 +0100 Subject: [PATCH 7/7] Fix SwiftFormat issue --- .../Sections/ParticipantsSectionController.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wire-ios/Wire-iOS/Sources/UserInterface/GroupDetails/Sections/ParticipantsSectionController.swift b/wire-ios/Wire-iOS/Sources/UserInterface/GroupDetails/Sections/ParticipantsSectionController.swift index 268b2ce8e30..3cfc93297d8 100644 --- a/wire-ios/Wire-iOS/Sources/UserInterface/GroupDetails/Sections/ParticipantsSectionController.swift +++ b/wire-ios/Wire-iOS/Sources/UserInterface/GroupDetails/Sections/ParticipantsSectionController.swift @@ -266,8 +266,12 @@ final class ParticipantsSectionController: GroupDetailsSectionController { switch configuration { case let .user(user): guard let cell = cell as? UserCell else { return unexpectedCellHandler() } - let isE2EICertified = if let userID = user.remoteIdentifier, - let userStatus = viewModel.userStatuses[userID] { userStatus.isE2EICertified } else { false } + let isE2EICertified = + if let userID = user.remoteIdentifier, let userStatus = viewModel.userStatuses[userID] { + userStatus.isE2EICertified + } else { + false + } cell.configure( user: user, isE2EICertified: isE2EICertified,