Skip to content

Instantly share code, notes, and snippets.

View barefeettom's full-sized avatar

Tom Brodhurst-Hill barefeettom

View GitHub Profile
@barefeettom
barefeettom / NewsCell airBlock.swift
Created May 25, 2021 03:13
Part of the tutorial series "Build an App Like Lego, using SwiftUI". https://medium.com/p/38b1b1f06cba/
NewsCell(article: .airBlock)
@barefeettom
barefeettom / NewsCell blockChain.swift
Created May 25, 2021 03:11
Part of the tutorial series "Build an App Like Lego, using SwiftUI". https://medium.com/p/38b1b1f06cba/
NewsCell(article: .blockChain)
@barefeettom
barefeettom / Article+Mock.swift
Created May 25, 2021 02:40
Part of the tutorial series "Build an App Like Lego, using SwiftUI". https://medium.com/p/38b1b1f06cba/
extension Article {
static let blockChain: Self = .init(
title: "Lego Block Chain",
date: Date(),
detail: "Add your own Lego block to the chain of transactions to guarantee security by trusting a whole crowd of people you've never met. What can possibly go wrong?",
smallImageName: "blockCircle",
largeImageName: "chain"
)
@barefeettom
barefeettom / Article.swift
Created May 25, 2021 02:36
Part of the tutorial series "Build an App Like Lego, using SwiftUI". https://medium.com/p/38b1b1f06cba/
struct Article {
let title: String
let date: Date
let detail: String
let smallImageName: String
let largeImageName: String
}
@barefeettom
barefeettom / NewCell preview instance.swift
Last active May 25, 2021 03:07
For the tutorial series "Build an App Like Lego, with SwiftUI": https://medium.com/p/22784ed19252/
NewsCell(
image: Image(systemName: "photo"),
text: Text("Text"),
detailText: Text("Detail Text"),
tertiaryText: Text("Tertiary Text"),
largeImage: Image(systemName: "photo")
)
/// Measurement system, such as metric, imperial.
enum System {
case metric
case imperial
}
extension System: FetchValue {}
enum Key: String, FetchKey {
case appID
case site = "q"
case system = "units"
var isInURLPath: Bool {
switch self {
case .system: return true
default: return false
}
enum Key: String, FetchKey {
case appID
case site = "q"
case system = "units"
}
public protocol Fetchable {
// Required. No default values:
/// The type of the object in the response.
associatedtype Fetched
/// The type of the failure object in the response.
associatedtype FetchedFailure
struct Site {
let id: Int
let name: String
let weathers: [Weather]
let main: Main
struct Weather {
let id: Int
let main: String
let description: String