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

Support iPhone X #66

Merged
merged 6 commits into from
Nov 21, 2017
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
2 changes: 0 additions & 2 deletions Example/GalleryDemo/GalleryDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@
"${BUILT_PRODUCTS_DIR}/Hue/Hue.framework",
"${BUILT_PRODUCTS_DIR}/Imaginary/Imaginary.framework",
"${BUILT_PRODUCTS_DIR}/Lightbox/Lightbox.framework",
"${BUILT_PRODUCTS_DIR}/SwiftHash/SwiftHash.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
Expand All @@ -237,7 +236,6 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Hue.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Imaginary.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Lightbox.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftHash.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
19 changes: 8 additions & 11 deletions Example/GalleryDemo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
PODS:
- Cache (4.0.2):
- SwiftHash (~> 2.0.0)
- Gallery (2.0.0)
- Cache (4.1.2)
- Gallery (2.0.2)
- Hue (3.0.0)
- Imaginary (3.0.0):
- Imaginary (3.0.2):
- Cache (~> 4.0)
- Lightbox (2.0.0):
- Lightbox (2.0.1):
- Hue (~> 3.0)
- Imaginary (~> 3.0)
- SwiftHash (2.0.0)

DEPENDENCIES:
- Gallery (from `../../`)
Expand All @@ -20,12 +18,11 @@ EXTERNAL SOURCES:
:path: ../../

SPEC CHECKSUMS:
Cache: 363b6899cee63c82ccbd291e64a6c202abc17a88
Gallery: b0451b47e6be808fbc9ce81f76f999ad55e4c81e
Cache: bd0233fc688b5e83a27bcd87807db7e6f23adcc5
Gallery: 5d303aeda7e9838f4334748ae3fbce8d51cba722
Hue: b8fe1e43eef13631331eebecb2198b68e2622f95
Imaginary: 2765d293d425cbed3b07fa11642554cbaebe913d
Lightbox: 83ec9f4aba4c79fc7bb9bcd263386df9969f09bb
SwiftHash: d2e09b13495447178cdfb8e46e54a5c46f15f5a9
Imaginary: d675200546110e305d6a26db6267c0622ffe5e6b
Lightbox: b72d18d05b57ba55dbac2eb0d7dafdc934205cf3

PODFILE CHECKSUM: eb9042b9d6a5aecd8dbf459941711c9a378e650c

Expand Down
14 changes: 12 additions & 2 deletions Sources/Camera/CameraView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,28 @@ class CameraView: UIView, UIGestureRecognizerDelegate {
insertSubview(focusImageView, belowSubview: bottomContainer)
insertSubview(shutterOverlayView, belowSubview: bottomContainer)

closeButton.g_pin(on: .top)
closeButton.g_pin(on: .left)
closeButton.g_pin(size: CGSize(width: 44, height: 44))

flashButton.g_pin(on: .centerY, view: closeButton)
flashButton.g_pin(on: .centerX)
flashButton.g_pin(size: CGSize(width: 60, height: 44))

rotateButton.g_pin(on: .top)
rotateButton.g_pin(on: .right)
rotateButton.g_pin(size: CGSize(width: 44, height: 44))

if #available(iOS 11, *) {
Constraint.on(
closeButton.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor),
rotateButton.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor)
)
} else {
Constraint.on(
closeButton.topAnchor.constraint(equalTo: superview!.topAnchor),
rotateButton.topAnchor.constraint(equalTo: superview!.topAnchor)
)
}

bottomContainer.g_pinDownward()
bottomContainer.g_pin(height: 80)
bottomView.g_pinEdges()
Expand Down
14 changes: 14 additions & 0 deletions Sources/Utils/Constraints.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,17 @@ extension UIView {
g_pin(on: .centerY, view: view)
}
}

// https:/hyperoslo/Sugar/blob/master/Sources/iOS/Constraint.swift
struct Constraint {
static func on(constraints: [NSLayoutConstraint]) {
constraints.forEach {
($0.firstItem as? UIView)?.translatesAutoresizingMaskIntoConstraints = false
$0.isActive = true
}
}

static func on(_ constraints: NSLayoutConstraint ...) {
on(constraints: constraints)
}
}
18 changes: 16 additions & 2 deletions Sources/Utils/Pages/PagesController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class PagesController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

view.backgroundColor = .black
setup()
}

Expand Down Expand Up @@ -92,8 +93,21 @@ class PagesController: UIViewController {
view.addSubview(scrollView)
scrollView.addSubview(scrollViewContentView)

pageIndicator.g_pinDownward()
pageIndicator.g_pin(height: 40)
Constraint.on(
pageIndicator.leftAnchor.constraint(equalTo: pageIndicator.superview!.leftAnchor),
pageIndicator.rightAnchor.constraint(equalTo: pageIndicator.superview!.rightAnchor),
pageIndicator.heightAnchor.constraint(equalToConstant: 40)
)

if #available(iOS 11, *) {
Constraint.on(
pageIndicator.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
)
} else {
Constraint.on(
pageIndicator.bottomAnchor.constraint(equalTo: pageIndicator.superview!.bottomAnchor)
)
}

scrollView.g_pinUpward()
if usePageIndicator {
Expand Down
20 changes: 16 additions & 4 deletions Sources/Utils/View/GridView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class GridView: UIView {
// MARK: - Setup

func setup() {
backgroundColor = UIColor.lightGray.withAlphaComponent(0.5)

[collectionView, bottomView, topView, emptyView].forEach {
addSubview($0)
}
Expand All @@ -43,8 +41,22 @@ class GridView: UIView {
bottomView.addSubview($0 as! UIView)
}

topView.g_pinUpward()
topView.g_pin(height: 40)
Constraint.on(
topView.leftAnchor.constraint(equalTo: topView.superview!.leftAnchor),
topView.rightAnchor.constraint(equalTo: topView.superview!.rightAnchor),
topView.heightAnchor.constraint(equalToConstant: 40)
)

if #available(iOS 11, *) {
Constraint.on(
topView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor)
)
} else {
Constraint.on(
topView.topAnchor.constraint(equalTo: topView.superview!.topAnchor)
)
}

bottomView.g_pinDownward()
bottomView.g_pin(height: 80)

Expand Down