Skip to content

Commit

Permalink
replaced Cartography with Anchorage in the Demo App
Browse files Browse the repository at this point in the history
  • Loading branch information
sobri909 committed May 2, 2018
1 parent 9323ddc commit 2237993
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 143 deletions.
4 changes: 2 additions & 2 deletions LocoKit Demo App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-LocoKit Demo App/Pods-LocoKit Demo App-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Cartography/Cartography.framework",
"${BUILT_PRODUCTS_DIR}/Anchorage/Anchorage.framework",
"${BUILT_PRODUCTS_DIR}/GRDB.swift/GRDB.framework",
"${BUILT_PRODUCTS_DIR}/LocoKit/LocoKit.framework",
"${PODS_ROOT}/LocoKitCore/LocoKitCore.framework",
Expand All @@ -298,7 +298,7 @@
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cartography.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Anchorage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GRDB.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/LocoKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/LocoKitCore.framework",
Expand Down
14 changes: 6 additions & 8 deletions LocoKit Demo App/ClassifierView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import LocoKit
import Cartography
import Anchorage

class ClassifierView: UIScrollView {

Expand All @@ -33,13 +33,11 @@ class ClassifierView: UIScrollView {

override func didMoveToSuperview() {
addSubview(rows)
constrain(rows, superview!) { rows, superview in
rows.top == rows.superview!.top
rows.bottom == rows.superview!.bottom - 8
rows.left == rows.superview!.left + 16
rows.right == rows.superview!.right - 16
rows.right == superview.right - 16
}
rows.topAnchor == rows.superview!.topAnchor
rows.bottomAnchor == rows.superview!.bottomAnchor - 8
rows.leftAnchor == rows.superview!.leftAnchor + 16
rows.rightAnchor == rows.superview!.rightAnchor - 16
rows.rightAnchor == superview!.rightAnchor - 16
}

func update(sample: LocomotionSample? = nil) {
Expand Down
14 changes: 6 additions & 8 deletions LocoKit Demo App/LocoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import LocoKit
import Cartography
import Anchorage
import CoreLocation

class LocoView: UIScrollView {
Expand All @@ -31,13 +31,11 @@ class LocoView: UIScrollView {

override func didMoveToSuperview() {
addSubview(rows)
constrain(rows, superview!) { rows, superview in
rows.top == rows.superview!.top
rows.bottom == rows.superview!.bottom - 8
rows.left == rows.superview!.left + 16
rows.right == rows.superview!.right - 16
rows.right == superview.right - 16
}
rows.topAnchor == rows.superview!.topAnchor
rows.bottomAnchor == rows.superview!.bottomAnchor - 8
rows.leftAnchor == rows.superview!.leftAnchor + 16
rows.rightAnchor == rows.superview!.rightAnchor - 16
rows.rightAnchor == superview!.rightAnchor - 16
}

func update(sample: LocomotionSample? = nil) {
Expand Down
14 changes: 6 additions & 8 deletions LocoKit Demo App/LogView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//

import LocoKit
import Anchorage
import SwiftNotes
import Cartography

class LogView: UIScrollView {

Expand Down Expand Up @@ -38,13 +38,11 @@ class LogView: UIScrollView {

override func didMoveToSuperview() {
addSubview(label)
constrain(label, superview!) { rows, superview in
rows.top == rows.superview!.top + 10
rows.bottom == rows.superview!.bottom - 10
rows.left == rows.superview!.left + 8
rows.right == rows.superview!.right - 8
rows.right == superview.right - 8
}
label.topAnchor == label.superview!.topAnchor + 10
label.bottomAnchor == label.superview!.bottomAnchor - 10
label.leftAnchor == label.superview!.leftAnchor + 8
label.rightAnchor == label.superview!.rightAnchor - 8
label.rightAnchor == superview!.rightAnchor - 8
}

func update() {
Expand Down
14 changes: 6 additions & 8 deletions LocoKit Demo App/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftNotes
import Cartography
import Anchorage

extension NSNotification.Name {
public static let settingsChanged = Notification.Name("settingsChanged")
Expand Down Expand Up @@ -39,13 +39,11 @@ class SettingsView: UIScrollView {

override func didMoveToSuperview() {
addSubview(rows)
constrain(rows, superview!) { rows, superview in
rows.top == rows.superview!.top
rows.bottom == rows.superview!.bottom
rows.left == rows.superview!.left + 8
rows.right == rows.superview!.right - 8
rows.right == superview.right - 8
}
rows.topAnchor == rows.superview!.topAnchor
rows.bottomAnchor == rows.superview!.bottomAnchor
rows.leftAnchor == rows.superview!.leftAnchor + 8
rows.rightAnchor == rows.superview!.rightAnchor - 8
rows.rightAnchor == superview!.rightAnchor - 8
}

func buildViewTree() {
Expand Down
14 changes: 6 additions & 8 deletions LocoKit Demo App/TimelineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import LocoKit
import Cartography
import Anchorage

class TimelineView: UIScrollView {

Expand All @@ -32,13 +32,11 @@ class TimelineView: UIScrollView {

override func didMoveToSuperview() {
addSubview(rows)
constrain(rows, superview!) { rows, superview in
rows.top == rows.superview!.top
rows.bottom == rows.superview!.bottom - 16
rows.left == rows.superview!.left + 16
rows.right == rows.superview!.right - 16
rows.right == superview.right - 16
}
rows.topAnchor == rows.superview!.topAnchor
rows.bottomAnchor == rows.superview!.bottomAnchor - 16
rows.leftAnchor == rows.superview!.leftAnchor + 16
rows.rightAnchor == rows.superview!.rightAnchor - 16
rows.rightAnchor == superview!.rightAnchor - 16
}

func update(with items: [TimelineItem]) {
Expand Down
46 changes: 17 additions & 29 deletions LocoKit Demo App/ToggleBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2017 Big Paua. All rights reserved.
//

import Cartography
import Anchorage

class ToggleBox: UIView {

Expand Down Expand Up @@ -36,20 +36,14 @@ class ToggleBox: UIView {
let dotWidth = dot.frame.size.width
addSubview(dot)

constrain(dot) { dot in
dot.centerY == dot.superview!.centerY
dot.height == dotWidth
dot.width == dotWidth
}

dot.centerYAnchor == dot.superview!.centerYAnchor
dot.heightAnchor == dotWidth
dot.widthAnchor == dotWidth

if let lastDot = lastDot {
constrain(dot, lastDot) { dot, lastDot in
dot.left == lastDot.right - 4
}
dot.leftAnchor == lastDot.rightAnchor - 4
} else {
constrain(dot) { dot in
dot.left == dot.superview!.left + 8
}
dot.leftAnchor == dot.superview!.leftAnchor + 8
}

lastDot = dot
Expand All @@ -67,25 +61,19 @@ class ToggleBox: UIView {
addSubview(toggle)

if let lastDot = lastDot {
constrain(lastDot, label) { dot, label in
label.left == dot.right + 5
}

label.leftAnchor == lastDot.rightAnchor + 5

} else {
constrain(label, toggle) { label, toggle in
label.left == label.superview!.left + 9
}
label.leftAnchor == label.superview!.leftAnchor + 9
}

constrain(label, toggle) { label, toggle in
label.top == label.superview!.top
label.bottom == label.superview!.bottom
label.height == 44

toggle.centerY == toggle.superview!.centerY
toggle.right == toggle.superview!.right - 10
toggle.left == label.right
}
label.topAnchor == label.superview!.topAnchor
label.bottomAnchor == label.superview!.bottomAnchor
label.heightAnchor == 44

toggle.centerYAnchor == toggle.superview!.centerYAnchor
toggle.rightAnchor == toggle.superview!.rightAnchor - 10
toggle.leftAnchor == label.rightAnchor
}

@objc func triggerOnChange() {
Expand Down
28 changes: 8 additions & 20 deletions LocoKit Demo App/UIStackView.helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,22 @@
// Copyright © 2017 Big Paua. All rights reserved.
//

import Cartography
import Anchorage

extension UIStackView {

func addUnderline() {
let underline = UIView()
underline.backgroundColor = UIColor(white: 0.85, alpha: 1)
addArrangedSubview(underline)

constrain(underline) { underline in
underline.height == 0.5
}
underline.heightAnchor == 0.5
}

func addGap(height: CGFloat) {
let gap = UIView()
gap.backgroundColor = .white
addArrangedSubview(gap)

constrain(gap) { gap in
gap.height == height
}
gap.heightAnchor == height
}

func addHeading(title: String, alignment: NSTextAlignment = .left) {
Expand All @@ -53,11 +47,7 @@ extension UIStackView {
let row = UIStackView()
row.distribution = .fillEqually
row.spacing = 0.5

for view in views {
row.addArrangedSubview(view)
}

views.forEach { row.addArrangedSubview($0) }
addArrangedSubview(row)
}

Expand Down Expand Up @@ -87,12 +77,10 @@ extension UIStackView {
row.addArrangedSubview(rightLabel)
row.addArrangedSubview(rightPad)
addArrangedSubview(row)

constrain(row, leftPad, rightPad) { row, leftPad, rightPad in
leftPad.width == 8
rightPad.width == 8
row.height == 20
}

leftPad.widthAnchor == 8
rightPad.widthAnchor == 8
row.heightAnchor == 20

return row
}
Expand Down
Loading

0 comments on commit 2237993

Please sign in to comment.