-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
275 additions
and
70 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
MyPlayground.playground/Pages/Project Views.xcplaygroundpage/Contents.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
139
MyPlayground.playground/Sources/playgroundController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters