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
public extension Int { | |
public var seconds: DispatchTimeInterval { | |
return DispatchTimeInterval.seconds(self) | |
} | |
public var second: DispatchTimeInterval { | |
return seconds | |
} | |
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
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
// | |
// 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
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
struct ContentView: View { | |
@State var count: Int = 3 | |
var body: some View { | |
return NavigationView { | |
VStack(spacing: 50) { | |
HStack { | |
Button(action: { self.count += 1 }) { | |
Text("Add") | |
} |
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
// This view overrides safeAreaInsets in order to work around | |
// (possibly erroneous) behavior of UIKit where safe area insets change | |
// when a view is transformed. (see http://www.openradar.me/35532074) | |
// | |
// Use this view as the direct subview of the view that has the transform applied. | |
// This view's frame should be equal to the superview's bounds for this to work. | |
@objc public class TransformIgnoringSafeAreaInsetsView: UIView { | |
@available(iOS 11.0, *) | |
override public var safeAreaInsets: UIEdgeInsets { | |
guard let superview = self.superview, superview.transform != .identity else { |
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
func ShieldIcon(ac: Int) -> some View { | |
ZStack { | |
Image(systemName: "shield") | |
.font(.title) | |
Text("\(ac)") | |
.font(.caption) | |
} | |
} |
NewerOlder