Skip to content
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

Use safe area guides for text label and shutter button #69

Merged
merged 3 commits into from
Feb 14, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 11 additions & 1 deletion Lumina/Lumina/UI/Extensions/InterfaceHandlerExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,18 @@ extension LuminaViewController {
func updateButtonFrames() {
self.cancelButton.center = CGPoint(x: self.view.frame.minX + 55, y: self.view.frame.maxY - 45)
if self.view.frame.width > self.view.frame.height {
self.shutterButton.center = CGPoint(x: self.view.frame.maxX - 45, y: self.view.frame.midY)
var maxX = self.view.frame.maxX
if #available(iOS 11, *) {
maxX = self.view.safeAreaLayoutGuide.layoutFrame.maxX
}
maxX -= 45
self.shutterButton.center = CGPoint(x: maxX, y: self.view.frame.midY)
} else {
var maxY = self.view.frame.maxY
if #available(iOS 11, *) {
maxY = self.view.safeAreaLayoutGuide.layoutFrame.maxY
}
maxY -= 45
self.shutterButton.center = CGPoint(x: self.view.frame.midX, y: self.view.frame.maxY - 45)
}
self.switchButton.center = CGPoint(x: self.view.frame.maxX - 25, y: self.view.frame.minY + 25)
Expand Down
7 changes: 6 additions & 1 deletion Lumina/Lumina/UI/LuminaButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ final class LuminaButton: UIButton {
self.titleLabel?.layer.shadowRadius = 6
case .shutter:
self.backgroundColor = UIColor.normalState
self.frame = CGRect(origin: CGPoint(x: UIScreen.main.bounds.midX - 35, y: UIScreen.main.bounds.maxY - 80), size: CGSize(width: self.shutterButtonDimension, height: self.shutterButtonDimension))
var minY = UIScreen.main.bounds.maxY
if #available(iOS 11, *) {
minY = self.safeAreaLayoutGuide.layoutFrame.maxY
}
minY -= 80
self.frame = CGRect(origin: CGPoint(x: UIScreen.main.bounds.midX - 35, y: minY), size: CGSize(width: self.shutterButtonDimension, height: self.shutterButtonDimension))
self.layer.cornerRadius = CGFloat(self.shutterButtonDimension / 2)
self.layer.borderWidth = 3
self.layer.borderColor = UIColor.borderNormalState
Expand Down
7 changes: 6 additions & 1 deletion Lumina/Lumina/UI/LuminaTextPromptView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ final class LuminaTextPromptView: UIView {

override func layoutSubviews() {
self.frame.size = CGSize(width: UIScreen.main.bounds.maxX - 110, height: 80)
self.textLabel.frame = CGRect(origin: CGPoint(x: 5, y: 5), size: CGSize(width: frame.width - 10, height: frame.height - 10))
var minY = CGFloat(0.0)
if #available(iOS 11, *) {
minY = self.safeAreaLayoutGuide.layoutFrame.minY
}
minY += 5.0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right here, we could perhaps put a check to see how much minY has changed, and update self.frame.size based on this value. I would love to do this, but not having an iPhone X means I dont know what value to expect ¯_(ツ)_/¯

self.textLabel.frame = CGRect(origin: CGPoint(x: 5, y: minY), size: CGSize(width: frame.width - 10, height: frame.height - 10))
}

required init?(coder aDecoder: NSCoder) {
Expand Down