Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class DemoAvatarDownloadViewController: BaseFormViewController {
title: "Default Avatar Option:",
subtitle: "Backend driven",
buttonTitle: "Select"
) { [weak self] _ in
self?.selectImageDefault()
) { [weak self] action in
self?.selectImageDefault(sender: action.sender as? UIView)
}

lazy var fetchButton = ButtonField(
Expand Down Expand Up @@ -105,7 +105,7 @@ class DemoAvatarDownloadViewController: BaseFormViewController {

private var preferredDefaultAvatar: DefaultAvatarOption? = nil

@objc private func selectImageDefault() {
@objc private func selectImageDefault(sender: UIView?) {
let controller = UIAlertController(title: "Default Avatar Option", message: nil, preferredStyle: .actionSheet)

DefaultAvatarOption.allCases.forEach { option in
Expand All @@ -119,6 +119,7 @@ class DemoAvatarDownloadViewController: BaseFormViewController {
}

controller.addAction(UIAlertAction(title: "Cancel", style: .cancel))
controller.popoverPresentationController?.sourceView = sender

present(controller, animated: true)
}
Expand Down
6 changes: 4 additions & 2 deletions Demo/Demo/Gravatar-Demo/DemoBaseProfileViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ open class DemoBaseProfileViewController: UIViewController {
])
}

@objc private func selectPalette() {
@objc private func selectPalette(sender: UIView?) {
let controller = UIAlertController(title: "Palette", message: nil, preferredStyle: .actionSheet)

paletteTypes.forEach { option in
Expand All @@ -102,10 +102,11 @@ open class DemoBaseProfileViewController: UIViewController {
})
}
controller.addAction(UIAlertAction(title: "Cancel", style: .cancel))
controller.popoverPresentationController?.sourceView = sender
present(controller, animated: true)
}

@objc private func selectProfileStyle() {
@objc private func selectProfileStyle(sender: UIView?) {
let controller = UIAlertController(title: "Layout Styles", message: nil, preferredStyle: .actionSheet)
ProfileViewConfiguration.Style.allCases.forEach { option in
controller.addAction(UIAlertAction(title: "\(option.rawValue)", style: .default) { [weak self] action in
Expand All @@ -115,6 +116,7 @@ open class DemoBaseProfileViewController: UIViewController {
})
}
controller.addAction(UIAlertAction(title: "Cancel", style: .cancel))
controller.popoverPresentationController?.sourceView = sender
present(controller, animated: true)
}
}
4 changes: 3 additions & 1 deletion Demo/Demo/Gravatar-Demo/DemoRemoteSVGViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class DemoRemoteSVGViewController: UITableViewController {
return cell
}

@objc private func selectPalette() {
@objc private func selectPalette(sender: UIView?) {
let controller = UIAlertController(title: "Palette", message: nil, preferredStyle: .actionSheet)

paletteTypes.forEach { option in
Expand All @@ -102,6 +102,8 @@ class DemoRemoteSVGViewController: UITableViewController {
})
}
controller.addAction(UIAlertAction(title: "Cancel", style: .cancel))
controller.popoverPresentationController?.sourceView = sender

present(controller, animated: true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class DemoUIImageViewExtensionViewController: BaseFormViewController {
title: "Default Avatar:",
subtitle: "Backend driven",
buttonTitle: "Select"
) { [weak self] _ in
self?.selectImageDefault()
) { [weak self] action in
self?.selectImageDefault(sender: action.sender as? UIView)
}

lazy var cancelOngoingButtonField = ButtonField(title: "Cancel") { [weak self] _ in
Expand Down Expand Up @@ -60,7 +60,7 @@ class DemoUIImageViewExtensionViewController: BaseFormViewController {

private var preferredDefaultAvatar: DefaultAvatarOption? = nil

@objc private func selectImageDefault() {
@objc private func selectImageDefault(sender: UIView?) {
let controller = UIAlertController(title: "Default Avatar", message: nil, preferredStyle: .actionSheet)

DefaultAvatarOption.allCases.forEach { option in
Expand All @@ -71,6 +71,7 @@ class DemoUIImageViewExtensionViewController: BaseFormViewController {
}

controller.addAction(UIAlertAction(title: "Cancel", style: .cancel))
controller.popoverPresentationController?.sourceView = sender

present(controller, animated: true)
}
Expand Down
11 changes: 6 additions & 5 deletions Demo/Demo/Gravatar-Demo/DemoUploadImageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class DemoUploadImageViewController: BaseFormViewController {
title: "Backend selection behavior",
subtitle: "Preserve selection",
buttonTitle: "Select"
) { [weak self] _ in
self?.avatarSelectionTapped()
) { [weak self] action in
self?.avatarSelectionTapped(sender: action.sender as? UIView)
}

lazy var selectAvatarButtonField = ButtonField(title: "Select Image") { [weak self] _ in
Expand Down Expand Up @@ -129,11 +129,11 @@ extension DemoUploadImageViewController: UIImagePickerControllerDelegate, UINavi
}
}

@objc private func avatarSelectionTapped() {
setAvatarSelectionMethod(with: emailFormField.text)
@objc private func avatarSelectionTapped(sender: UIView?) {
setAvatarSelectionMethod(with: emailFormField.text, sender: sender)
}

@objc private func setAvatarSelectionMethod(with email: String) {
@objc private func setAvatarSelectionMethod(with email: String, sender: UIView?) {
let controller = UIAlertController(title: "Avatar selection behavior:", message: nil, preferredStyle: .actionSheet)


Expand All @@ -147,6 +147,7 @@ extension DemoUploadImageViewController: UIImagePickerControllerDelegate, UINavi
}

controller.addAction(UIAlertAction(title: "Cancel", style: .cancel))
controller.popoverPresentationController?.sourceView = sender

present(controller, animated: true)
}
Expand Down