Skip to content

Commit

Permalink
Add playgrounds & pods to project
Browse files Browse the repository at this point in the history
  • Loading branch information
AgapovOne committed Mar 23, 2019
1 parent 567e55d commit cb39db9
Show file tree
Hide file tree
Showing 8 changed files with 275 additions and 70 deletions.
115 changes: 83 additions & 32 deletions LivePhotoToVideo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

29 changes: 0 additions & 29 deletions LivePhotoToVideo/Resources/Base.lproj/Main.storyboard

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import UIKit
import PlaygroundSupport

import UI

class MyViewController : UIViewController {
override func loadView() {
let view = UIView()
Expand All @@ -17,5 +19,9 @@ class MyViewController : UIViewController {
self.view = view
}
}
// Present the view controller in the Live View window




PlaygroundPage.current.needsIndefiniteExecution = true
PlaygroundPage.current.liveView = MyViewController()
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//: [Previous](@previous)

import UIKit
import PlaygroundSupport

import UI

class fvm: PhotosViewModel {}

//let controller = PermissionsViewController()
let controller = PhotosViewController(viewModel: fvm())

//let addTraits = UITraitCollection(preferredContentSizeCategory: .extraLarge)
//let addTraits = UITraitCollection(preferredContentSizeCategory: .extraSmall)
let addTraits = UITraitCollection()

let (parent, _) = playgroundControllers(device: .phone4_7inch, orientation: .portrait, child: controller, additionalTraits: addTraits)

PlaygroundPage.current.liveView = parent
//PlaygroundPage.current.needsIndefiniteExecution = true

//: [Next](@next)
139 changes: 139 additions & 0 deletions MyPlayground.playground/Sources/playgroundController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import UIKit


public enum Device {
case phone3_5inch
case phone4inch
case phone4_7inch
case phone5_5inch
case pad
case pad12_9inch
}

public enum Orientation {
case portrait
case landscape
}

/**
Creates a controller that represents a specific device, orientation with specific traits.
- parameter device: The device the controller should represent.
- parameter orientation: The orientation of the device.
- parameter child: An optional controller to put inside the parent controller. If omitted
a blank controller will be used.
- parameter additionalTraits: An optional set of traits that will also be applied. Traits in this collection
will trump any traits derived from the device/orientation comboe specified.
- returns: Two controllers: a root controller that can be set to the playground's live view, and a content
controller which should have UI elements added to it
*/
public func playgroundControllers(device: Device = .phone4_7inch,
orientation: Orientation = .portrait,
child: UIViewController = UIViewController(),
additionalTraits: UITraitCollection = .init())
-> (parent: UIViewController, child: UIViewController) {

let parent = UIViewController()
parent.view.backgroundColor = .white

child.view.backgroundColor = .white
child.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]

parent.addChild(child)
parent.view.addSubview(child.view)
child.didMove(toParent: parent)

child.view.frame = parent.view.frame

let traits: UITraitCollection
switch (device, orientation) {
case (.phone3_5inch, .portrait):
parent.view.frame = .init(x: 0, y: 0, width: 320, height: 480)
traits = .init(traitsFrom: [
.init(horizontalSizeClass: .compact),
.init(verticalSizeClass: .regular),
.init(userInterfaceIdiom: .phone)
])
case (.phone3_5inch, .landscape):
parent.view.frame = .init(x: 0, y: 0, width: 480, height: 320)
traits = .init(traitsFrom: [
.init(horizontalSizeClass: .compact),
.init(verticalSizeClass: .compact),
.init(userInterfaceIdiom: .phone)
])
case (.phone4inch, .portrait):
parent.view.frame = .init(x: 0, y: 0, width: 320, height: 568)
traits = .init(traitsFrom: [
.init(horizontalSizeClass: .compact),
.init(verticalSizeClass: .regular),
.init(userInterfaceIdiom: .phone)
])
case (.phone4inch, .landscape):
parent.view.frame = .init(x: 0, y: 0, width: 568, height: 320)
traits = .init(traitsFrom: [
.init(horizontalSizeClass: .compact),
.init(verticalSizeClass: .compact),
.init(userInterfaceIdiom: .phone)
])
case (.phone4_7inch, .portrait):
parent.view.frame = .init(x: 0, y: 0, width: 375, height: 667)
traits = .init(traitsFrom: [
.init(horizontalSizeClass: .compact),
.init(verticalSizeClass: .regular),
.init(userInterfaceIdiom: .phone)
])
case (.phone4_7inch, .landscape):
parent.view.frame = .init(x: 0, y: 0, width: 667, height: 375)
traits = .init(traitsFrom: [
.init(horizontalSizeClass: .compact),
.init(verticalSizeClass: .compact),
.init(userInterfaceIdiom: .phone)
])
case (.phone5_5inch, .portrait):
parent.view.frame = .init(x: 0, y: 0, width: 414, height: 736)
traits = .init(traitsFrom: [
.init(horizontalSizeClass: .compact),
.init(verticalSizeClass: .regular),
.init(userInterfaceIdiom: .phone)
])
case (.phone5_5inch, .landscape):
parent.view.frame = .init(x: 0, y: 0, width: 736, height: 414)
traits = .init(traitsFrom: [
.init(horizontalSizeClass: .regular),
.init(verticalSizeClass: .compact),
.init(userInterfaceIdiom: .phone)
])
case (.pad, .portrait):
parent.view.frame = .init(x: 0, y: 0, width: 768, height: 1024)
traits = .init(traitsFrom: [
.init(horizontalSizeClass: .regular),
.init(verticalSizeClass: .regular),
.init(userInterfaceIdiom: .pad)
])
case (.pad, .landscape):
parent.view.frame = .init(x: 0, y: 0, width: 1024, height: 768)
traits = .init(traitsFrom: [
.init(horizontalSizeClass: .regular),
.init(verticalSizeClass: .regular),
.init(userInterfaceIdiom: .pad)
])
case (.pad12_9inch, .portrait):
parent.view.frame = .init(x: 0, y: 0, width: 1024, height: 1366)
traits = .init(traitsFrom: [
.init(horizontalSizeClass: .regular),
.init(verticalSizeClass: .regular),
.init(userInterfaceIdiom: .pad)
])
case (.pad12_9inch, .landscape):
parent.view.frame = .init(x: 0, y: 0, width: 1366, height: 1024)
traits = .init(traitsFrom: [
.init(horizontalSizeClass: .regular),
.init(verticalSizeClass: .regular),
.init(userInterfaceIdiom: .pad)
])
}

let allTraits = UITraitCollection.init(traitsFrom: [traits, additionalTraits])
parent.setOverrideTraitCollection(allTraits, forChild: child)

return (parent, child)
}
7 changes: 5 additions & 2 deletions MyPlayground.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios' executeOnSourceChanges='false'>
<timeline fileName='timeline.xctimeline'/>
<playground version='6.0' target-platform='ios' executeOnSourceChanges='false'>
<pages>
<page name='Project Views'/>
<page name='Empty ViewController'/>
</pages>
</playground>
15 changes: 10 additions & 5 deletions Podfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target 'LivePhotoToVideo' do
use_frameworks!
abstract_target 'Workspace' do

# Main
pod 'RxSwift'
pod 'RxCocoa'
pod 'RxDataSources'

# UI
pod 'Cartography'
target 'UI' do
pod 'Cartography'
pod 'Reusable'
end

target 'LivePhotoToVideo'

target 'LivePhotoToVideoTests' do
inherit! :search_paths
# Pods for testing


end

end
10 changes: 9 additions & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
PODS:
- Cartography (3.1.0)
- Differentiator (3.1.0)
- Reusable (4.0.5):
- Reusable/Storyboard (= 4.0.5)
- Reusable/View (= 4.0.5)
- Reusable/Storyboard (4.0.5)
- Reusable/View (4.0.5)
- RxAtomic (4.4.2)
- RxCocoa (4.4.2):
- RxSwift (>= 4.4.2, ~> 4.4)
Expand All @@ -13,6 +18,7 @@ PODS:

DEPENDENCIES:
- Cartography
- Reusable
- RxCocoa
- RxDataSources
- RxSwift
Expand All @@ -21,6 +27,7 @@ SPEC REPOS:
https://github.com/cocoapods/specs.git:
- Cartography
- Differentiator
- Reusable
- RxAtomic
- RxCocoa
- RxDataSources
Expand All @@ -29,11 +36,12 @@ SPEC REPOS:
SPEC CHECKSUMS:
Cartography: 1988b7578871a56c036e7af17195cb2190edf18c
Differentiator: be49ca3408f0ecfc761e4c7763d20c62be01b9ad
Reusable: 188be1a54ac0691bc66e5bb24ec6eb91971b315b
RxAtomic: d00e97c10db88c6f08540e0bf2752fc5a2404167
RxCocoa: 477990dc3b4c3ff55fb0ac77e1cc06244e0aaec8
RxDataSources: a843bad90c29817f5923ec8163f4af2de084ceb3
RxSwift: 74c29b693c8e42b0f64400e8b06564575742d649

PODFILE CHECKSUM: 1fb6958177f26f7e87c2db0495c78b3f1414474d
PODFILE CHECKSUM: 427ef3e6b11d8b2ee65d8b919bd6ed170e8121b1

COCOAPODS: 1.6.1

0 comments on commit cb39db9

Please sign in to comment.