This file contains hidden or 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
import UIKit | |
class ViewControllerStack: UIViewController { | |
private var firstContainerTopAnchor: NSLayoutConstraint? | |
private var firstController: UIViewController? | |
private var controllers: [UIViewController]? | |
private var containerView = UIView() | |
init(controllers: [UIViewController]) { | |
self.controllers = controllers |
This file contains hidden or 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
// | |
// ObservableTestTests.swift | |
// ObservableTestTests | |
// | |
// Created by Eduardo Domene Junior on 01/12/19. | |
// Copyright © 2019 Eduardo Domene Junior. All rights reserved. | |
// | |
import XCTest | |
import Observable |
This file contains hidden or 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
//: A UIKit based Playground for presenting user interface | |
// based on: https://stackoverflow.com/questions/37967555/how-can-i-mimic-the-bottom-sheet-from-the-maps-app | |
// This example includes an autoresizing collapsed-view. | |
// Clicking on "testing" will add another label, updating the collapsed-view's height. | |
// Click and drag the red section (BottomSheet) to update its position. | |
import UIKit | |
import PlaygroundSupport | |
let screenHeight: CGFloat = 400 |
This file contains hidden or 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
import UIKit | |
import PlaygroundSupport | |
let screenHeight: CGFloat = 400 | |
let screenWidth: CGFloat = 200 | |
class InnerViewController: UIViewController { | |
var stack: UIStackView = { | |
var label: UILabel { | |
let label = UILabel() |
This file contains hidden or 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
protocol Animal { | |
var name: String { get } | |
var age: Int { get } | |
func makeNoise() | |
} | |
struct Dog: Animal { | |
let name: String | |
let age: Int | |
This file contains hidden or 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
let myHorse = Horse(name: "Horsy", age: 5) | |
print(myHorse.name) | |
// Horsy |
This file contains hidden or 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
let animals: [Animal] = [ | |
Dog(name: "Doggy", age: 3), | |
Horse(name: "Horsy", age: 5) | |
] | |
let pages = animals.map { PageDetails(animal: $0) } | |
let listView = ListView(pages: pages, animals: animals) |
This file contains hidden or 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
// Composition root | |
let animals: [Animal] = [ | |
Dog(name: "Doggy", age: 3), | |
Horse(name: "Horsy", age: 5) | |
] | |
let pageDetails = PageDetails() | |
let vc = ListView(pageDetails: pageDetails, animals: animals) |
This file contains hidden or 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
struct AnimalReport { | |
let animal: Animal | |
func describe() {...} | |
} | |
struct AnimalSelection { | |
let animals: [Animal] | |
let animalReport: AnimalReport | |
func selectAnimal(_ animal: Animal) {...} | |
} | |
let animals: [Animal] = [ |
This file contains hidden or 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
struct AnimalReport { | |
var animal: Animal? | |
func describe() { | |
guard let animal = animal else { return } | |
print("Animal is called \(animal.name) and is \(animal.age) years old") | |
} | |
} | |
struct AnimalSelection { | |
let animals: [Animal] |