Skip to content

Commit

Permalink
Episode 21
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Jul 20, 2018
1 parent e543b07 commit 6bd4d13
Show file tree
Hide file tree
Showing 24 changed files with 1,572 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "0018-environment-pt2/Vendor/swift-overture"]
path = 0018-environment-pt2/Vendor/swift-overture
url = https://github.com/pointfreeco/swift-overture.git
[submodule "0021-playground-driven-development/Vendor/swift-overture"]
path = 0021-playground-driven-development/Vendor/swift-overture
url = https://github.com/pointfreeco/swift-overture.git
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import PointFreeFramework
import PlaygroundSupport

let vc = EpisodeListViewController()
PlaygroundPage.current.liveView = vc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios' executeOnSourceChanges='false'>
<timeline fileName='timeline.xctimeline'/>
</playground>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import PointFreeFramework
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

let window = UIWindow()

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {

self.window.rootViewController = EpisodeListViewController()
self.window.makeKeyAndVisible()

return true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
43 changes: 43 additions & 0 deletions 0021-playground-driven-development/PointFree/PointFree/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import Foundation

public struct Episode {
public let blurb: String
public let posterImageUrl: String
public let publishedAt: Date
public let sequence: Int
public let subscriberOnly: Bool
public let title: String
}

public let episodes: [Episode] = [
.init(
blurb: """
What does the Swift type system have to do with algebra? A lot! We’ll begin to explore this correspondence and see how it can help us create type-safe data structures that can catch runtime errors at compile time.
""",
posterImageUrl: "https://d1hf1soyumxcgv.cloudfront.net/0002-side-effects/0002-poster.jpg",
publishedAt: Date(timeIntervalSince1970: 1_519_045_951),
sequence: 4,
subscriberOnly: true,
title: "Algebraic Data Types"
),
.init(
blurb: """
Side effects: can’t live with ’em; can’t write a program without ’em. Let’s explore a few kinds of side effects we encounter every day, why they make code difficult to reason about and test, and how we can control them without losing composition.
""",
posterImageUrl: "https://d1hf1soyumxcgv.cloudfront.net/0002-side-effects/0002-poster.jpg",
publishedAt: Date(timeIntervalSince1970: 1_517_811_069),
sequence: 3,
subscriberOnly: false,
title: "Side Effects"
),
.init(
blurb: """
Our first episode is all about functions! We talk a bit about what makes functions special, contrasting them with the way we usually write code, and have some exploratory discussions about operators and composition.
""",
posterImageUrl: "https://d1hf1soyumxcgv.cloudfront.net/0001-functions/0001-poster.jpg",
publishedAt: Date(timeIntervalSince1970: 1_517_206_269),
sequence: 2,
subscriberOnly: false,
title: "Functions"
),
.init(
blurb: """
Point-Free is here, bringing you videos covering functional programming concepts using the Swift language. Take a moment to hear from the hosts about what to expect from this new series.
""",
posterImageUrl: "https://d1hf1soyumxcgv.cloudfront.net/0000-introduction/0000-poster.jpg",
publishedAt: Date(timeIntervalSince1970: 1_517_206_269),
sequence: 0,
subscriberOnly: false,
title: "We launched!"
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// PointFreeFramework.h
// PointFreeFramework
//
// Created by Stephen Celis on 7/20/18.
// Copyright © 2018 Point-Free. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for PointFreeFramework.
FOUNDATION_EXPORT double PointFreeFrameworkVersionNumber;

//! Project version string for PointFreeFramework.
FOUNDATION_EXPORT const unsigned char PointFreeFrameworkVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <PointFreeFramework/PublicHeader.h>


Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import Foundation
import UIKit
import Overture

extension CGFloat {
static func pf_grid(_ n: Int) -> CGFloat {
return CGFloat(n) * 4
}
}

let generousMargins =
mut(\UIView.layoutMargins, .init(top: .pf_grid(6), left: .pf_grid(6), bottom: .pf_grid(6), right: .pf_grid(6)))

let autoLayoutStyle = mut(\UIView.translatesAutoresizingMaskIntoConstraints, false)

let verticalStackView = mut(\UIStackView.axis, .vertical)

let baseStackViewStyle = concat(
generousMargins,
mut(\UIStackView.spacing, .pf_grid(3)),
verticalStackView,
mut(\.isLayoutMarginsRelativeArrangement, true),
autoLayoutStyle
)

let bolded: (inout UIFont) -> Void = { $0 = $0.bolded }

let baseTextButtonStyle = concat(
mut(\UIButton.titleLabel!.font, UIFont.preferredFont(forTextStyle: .subheadline)),
mver(\UIButton.titleLabel!.font!, bolded)
)

extension UIButton {
var normalTitleColor: UIColor? {
get { return self.titleColor(for: .normal) }
set { self.setTitleColor(newValue, for: .normal) }
}
}

let secondaryTextButtonStyle = concat(
baseTextButtonStyle,
mut(\.normalTitleColor, .black)
)

let primaryTextButtonStyle = concat(
baseTextButtonStyle,
mut(\.normalTitleColor, .pf_purple)
)

let baseButtonStyle = concat(
baseTextButtonStyle,
mut(\.contentEdgeInsets, .init(top: .pf_grid(2), left: .pf_grid(4), bottom: .pf_grid(2), right: .pf_grid(4)))
)

func roundedStyle(cornerRadius: CGFloat) -> (UIView) -> Void {
return concat(
mut(\.layer.cornerRadius, cornerRadius),
mut(\.layer.masksToBounds, true)
)
}

let baseRoundedStyle = roundedStyle(cornerRadius: 6)

let baseFilledButtonStyle = concat(
baseButtonStyle,
baseRoundedStyle
)

extension UIButton {
var normalBackgroundImage: UIImage? {
get { return self.backgroundImage(for: .normal) }
set { self.setBackgroundImage(newValue, for: .normal) }
}
}

let primaryButtonStyle = concat(
baseFilledButtonStyle,
mut(\.normalBackgroundImage, .from(color: .pf_purple)),
mut(\.normalTitleColor, .white)
)

let smallCapsLabelStyle = mut(\UILabel.font, UIFont.preferredFont(forTextStyle: .caption1).smallCaps)
Loading

0 comments on commit 6bd4d13

Please sign in to comment.