Skip to content

Commit

Permalink
BugFix: iPad will not crash while displaying Popups
Browse files Browse the repository at this point in the history
  • Loading branch information
BLeeEZ committed Sep 21, 2020
1 parent 3d85ea5 commit 417837b
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Amperfy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.1;
MARKETING_VERSION = 1.0.2;
PRODUCT_BUNDLE_IDENTIFIER = "net.hildebrand-it.amperfy-music";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1274,7 +1274,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.1;
MARKETING_VERSION = 1.0.2;
PRODUCT_BUNDLE_IDENTIFIER = "net.hildebrand-it.amperfy-music";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
8 changes: 8 additions & 0 deletions Amperfy/Common/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ extension UIAlertController {
}
}
}

func setOptionsForIPadToDisplayPopupCentricIn(view: UIView) {
if let popoverController = self.popoverPresentationController {
popoverController.sourceView = view
popoverController.sourceRect = CGRect(x: view.bounds.midX, y: view.bounds.midY, width: 0, height: 0)
popoverController.permittedArrowDirections = []
}
}
}

extension UISlider {
Expand Down
1 change: 1 addition & 0 deletions Amperfy/Screens/View/AlbumDetailTableHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class AlbumDetailTableHeader: UIView {
@IBAction func optionsButtonPressed(_ sender: Any) {
if let album = self.album, let rootView = self.rootView {
let alert = createAlert(forAlbum: album)
alert.setOptionsForIPadToDisplayPopupCentricIn(view: rootView.view)
rootView.present(alert, animated: true, completion: nil)
}
}
Expand Down
1 change: 1 addition & 0 deletions Amperfy/Screens/View/ArtistDetailTableHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ArtistDetailTableHeader: UIView {
@IBAction func optionsButtonPressed(_ sender: Any) {
if let artist = self.artist, let rootView = self.rootView {
let alert = createAlert(forArtist: artist)
alert.setOptionsForIPadToDisplayPopupCentricIn(view: rootView.view)
rootView.present(alert, animated: true, completion: nil)
}
}
Expand Down
1 change: 1 addition & 0 deletions Amperfy/Screens/View/PlaylistDetailTableHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class PlaylistDetailTableHeader: UIView {
@IBAction func optionsButtonPressed(_ sender: Any) {
if let playlist = self.playlist, let rootView = self.rootView {
let alert = createAlert(forPlaylist: playlist, statusNotifyier: rootView)
alert.setOptionsForIPadToDisplayPopupCentricIn(view: rootView.view)
rootView.present(alert, animated: true, completion: nil)
}
}
Expand Down
1 change: 1 addition & 0 deletions Amperfy/Screens/View/SongTableCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class SongTableCell: UITableViewCell {
generator.impactOccurred()
isAlertPresented = true
let alert = createAlert(forSong: song, rootView: rootView, displayMode: forceTouchDisplayMode)
alert.setOptionsForIPadToDisplayPopupCentricIn(view: rootView.view)
rootView.present(alert, animated: true, completion: nil)
}
}
Expand Down
1 change: 1 addition & 0 deletions Amperfy/Screens/ViewController/LatestSongsVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class LatestSongsVC: UITableViewController {
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
alert.pruneNegativeWidthConstraintsToAvoidFalseConstraintWarnings()
alert.setOptionsForIPadToDisplayPopupCentricIn(view: self.view)
present(alert, animated: true, completion: nil)
}

Expand Down
1 change: 1 addition & 0 deletions Amperfy/Screens/ViewController/PopupPlayerVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class PopupPlayerVC: UIViewController, UITableViewDelegate, UITableViewDataSourc
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
alert.pruneNegativeWidthConstraintsToAvoidFalseConstraintWarnings()
alert.setOptionsForIPadToDisplayPopupCentricIn(view: self.view)

self.present(alert, animated: true, completion: nil)
}
Expand Down

0 comments on commit 417837b

Please sign in to comment.