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
https://open.spotify.com/playlist/5xdvmNizfHeCz8fVvaXL4F?si=1f_Q5o4KRh-63p-mwckUlg&dl_branch=1 |
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
import Cocoa | |
// Say we have a Person model | |
enum V1 { | |
struct Person: Codable { | |
let name: String | |
var age: Int | |
} | |
} |
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
let timer = Timer.publish(every: 1.0, on: RunLoop.main, in: .common) | |
.autoconnect() | |
.prepend(Date()) | |
.map { $0.timeIntervalSince1970 } | |
.lane("shared timer") | |
.share() | |
.lane("timer") | |
timer | |
.sink { print($0) }.store(in: &cancellable) |
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
struct ContentView: View { | |
var body: some View { | |
VStack(alignment: .customAlignment) { | |
HStack { | |
Text("100 m").font(Font.body.bold()) | |
Text("Usain Bolt").setCustomAlignmentToLeading() | |
} | |
HStack { | |
Text("5 km").font(Font.body.bold()) | |
Text("Joshua Cheptegei").setCustomAlignmentToLeading() |
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
class ViewModel { | |
let intGetterGetter: () -> () -> Int? | |
var currentInt = 2 | |
init() { | |
self.intGetterGetter = { | |
return { [weak self] in | |
return self?.currentInt | |
} |
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
content | |
.onPreferenceChange(SizeKey.self, perform: { sizes in | |
// this is not always called | |
}) | |
.overlayPreferenceValue(SizeKey.self) { sizes in | |
EmptyView().onAppear { | |
// this is called more reliably | |
// the view's id controls for which changes this is called | |
}.id(sizes.map { $0.width*1000+$0.height }) | |
} |
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
// | |
// ContentView.swift | |
// FlowLayoutST | |
// | |
// Created by Chris Eidhof on 22.08.19. | |
// Copyright © 2019 Chris Eidhof. All rights reserved. | |
// | |
import SwiftUI | |
struct FlowLayout { |
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
class ActionTarget { | |
let handler: () -> Void | |
init(handler: @escaping () -> Void) { | |
self.handler = handler | |
} | |
@IBAction func handle() { | |
handler() | |
} |
NewerOlder