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
private struct ColorAnimation: AnimatableModifier { | |
var animatableData: Double | |
private let rgbaPair: [(Double, Double)] | |
init(from: Color, to: Color, percentToColor: Double) { | |
animatableData = percentToColor | |
let fromComponents = UIColor(from).cgColor.components! | |
let toComponents = UIColor(to).cgColor.components! | |
rgbaPair = Array(zip(fromComponents.map(Double.init), toComponents.map(Double.init))) |
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 Mock {} | |
extension Mock { | |
static func decode<T>(forResource: String) -> T? where T: Decodable { | |
var result: T? = nil | |
do { | |
if let path = Bundle.main.path(forResource: forResource, ofType: "json"), let jsonData = try String(contentsOfFile: path).data(using: .utf8) { | |
result = try JSONDecoder().decode(T.self, from: jsonData) | |
} |
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 array = [Int]() | |
let dic = [Int : Double]() | |
let tuple = array | |
.map { c -> (a: Int, b: Double) in return (a: c, b: dic[c]!) } | |
.sorted(by: { (x, y) -> Bool in return x.b == y.b ? x.a < y.a : x.b > y.b }).first! |
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
openapi: 3.0.3 | |
info: | |
title: NewsAPI | |
description: NewsAPI.org | |
version: 1.0.0 | |
servers: | |
- url: https://newsapi.org/v2 | |
tags: | |
- name: articles | |
description: News articles |
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 UIKit | |
import OpenCombine | |
import BlueprintUI | |
import BlueprintUICommonControls | |
typealias Published = OpenCombine.Published | |
final class CounterViewModel { | |
@Published var totalCount = 0 |
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 UIKit | |
import CoreRender | |
import Render | |
import OpenCombine | |
final class ViewController: UIViewController { | |
var hostingView: HostingView! | |
let contex = Context() | |
var coreRenderView: CounterView? |
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 scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
let store = Store<Int, CounterAction>(initialState: 0) { previousState, action in | |
switch action { | |
case .increment: | |
return previousState + 1 | |
case .decrement: | |
return previousState - 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 SwiftUI | |
extension AnyTransition { | |
static var moveUpAndFade: AnyTransition { | |
let insertion = AnyTransition.move(edge: .top).combined(with: .opacity) | |
let removal = AnyTransition.move(edge: .top).combined(with: .opacity) | |
return .asymmetric(insertion: insertion, removal: removal) | |
} | |
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 simd | |
extension float4x4 { | |
init(scaleBy s: Float) { | |
self.init(SIMD4<Float>(s, 0, 0, 0), | |
SIMD4<Float>(0, s, 0, 0), | |
SIMD4<Float>(0, 0, s, 0), | |
SIMD4<Float>(0, 0, 0, 1)) | |
} | |
NewerOlder