Skip to content

Instantly share code, notes, and snippets.

View barefeettom's full-sized avatar

Tom Brodhurst-Hill barefeettom

View GitHub Profile
@barefeettom
barefeettom / ProductCell Product.swift
Created July 6, 2021 07:05
Part of the tutorial series "Build an app like Lego, Using SwiftUI". https://medium.com/p/184fda9d0c86/
ProductCell(product: product)
@barefeettom
barefeettom / ProductCell+Product preview.swift
Created July 5, 2021 22:50
Part of the tutorial series "Build an app like Lego, Using SwiftUI". https://medium.com/p/184fda9d0c86/
ProductCell(product: .spaceShuttle)
.previewLayout(.sizeThatFits)
@barefeettom
barefeettom / ProductCell+Product.swift
Created July 5, 2021 22:47
Part of the tutorial series "Build an app like Lego, Using SwiftUI". https://medium.com/p/184fda9d0c86/
extension ProductCell {
init(product: Product) {
self.init(
image: Image(product.imageName),
text: Text(product.name),
detailText: Text(product.description),
tertiaryText: Text(String(describing: product.price))
)
}
}
@barefeettom
barefeettom / Product+Mock.swift
Created July 5, 2021 22:44
Part of the tutorial series "Build an app like Lego, Using SwiftUI". https://medium.com/p/184fda9d0c86/
extension Product {
static let sydney: Self = .init(
id: 1,
name: "Sydney Opera House & Harbour Bridge",
description: "Capture the architectural essence and splendor of Sydney with this magnificent set that brings together the iconic Sydney Opera House™, Sydney Harbour Bridge, Sydney Tower and Deutsche Bank Place, in an inspirational skyline setting. Each individual LEGO® structure provides a unique and rewarding building experience with true-to-life color and relative scale depiction. Sydney's sparkling harbor is represented in the tiled baseplate, adding an extra dimension and feel of authenticity to this detailed recreation of one of the world's most glamorous cities.",
price: 98.0,
imageName: "sydney"
)
@barefeettom
barefeettom / Product.swift
Created July 5, 2021 22:42
Part of the tutorial series "Build an app like Lego, Using SwiftUI". https://medium.com/p/184fda9d0c86/
struct Product: Identifiable {
let id: Int
let name: String
let description: String
let price: Double
let imageName: String
}
@barefeettom
barefeettom / ProductCell properties.swift
Created July 5, 2021 22:34
Part of the tutorial series "Build an app like Lego, Using SwiftUI". https://medium.com/p/184fda9d0c86/
let image: Image
let text: Text
let detailText: Text
let tertiaryText: Text
@barefeettom
barefeettom / ProductCell.swift
Created June 22, 2021 22:34
Part of the tutorial "Build an App Like Lego, with SwiftUI" https://medium.com/p/184fda9d0c86/
struct ProductCell: View {
var body: some View {
HStack {
Image(systemName: "photo")
.resizable(resizingMode: .stretch)
.aspectRatio(contentMode: .fit)
.frame(width: 60.0)
VStack(alignment: .leading) {
Text("Text")
.font(.title2)
@barefeettom
barefeettom / Article.mocks.swift
Created June 21, 2021 22:10
Article.mocks for the tutorial "Build an App Like Lego, with SwiftUI" https://medium.com/p/836b8962f66d/
extension Article {
static let mocks: [Self] = [.blockChain, .airBlock]
}
@barefeettom
barefeettom / NewsCell+Article preview.swift
Created May 25, 2021 03:35
Part of the tutorial series "Build an App Like Lego, using SwiftUI". https://medium.com/p/38b1b1f06cba/
NewsCell(article: .airBlock)
.previewLayout(.sizeThatFits)
@barefeettom
barefeettom / NewsCell+Article.swift
Created May 25, 2021 03:30
Part of the tutorial series "Build an App Like Lego, using SwiftUI". https://medium.com/p/38b1b1f06cba/
extension NewsCell {
init(article: Article) {
self.init(
image: Image(article.smallImageName),
text: Text(article.title),
detailText: Text(article.detail),
tertiaryText: Text(String(describing: article.date)),
largeImage: Image(article.largeImageName)
)
}