This file contains hidden or 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
| // | |
| // SnapCarousel.swift | |
| // prototype5 | |
| // | |
| // Created by xtabbas on 5/7/20. | |
| // Copyright © 2020 xtadevs. All rights reserved. | |
| // | |
| import SwiftUI |
This file contains hidden or 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
| // Checkout the explanation article here - https://sameer-syd.medium.com/swiftui-two-directional-snaplist-95cb852957be | |
| import SwiftUI | |
| import Combine | |
| struct HomeView: View { | |
| @StateObject var viewModel: HomeViewModel | |
This file contains hidden or 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 | |
| struct ScrollableView<Content: View>: UIViewControllerRepresentable, Equatable { | |
| // MARK: - Coordinator | |
| final class Coordinator: NSObject, UIScrollViewDelegate { | |
| // MARK: - Properties | |
| private let scrollView: UIScrollView | |
| var offset: Binding<CGPoint> |
This file contains hidden or 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 Foundation | |
| public typealias Mass = Measurement<UnitMass> | |
| public typealias Duration = Measurement<UnitDuration> | |
| public typealias Angle = Measurement<UnitAngle> | |
| public typealias Length = Measurement<UnitLength> | |
| public typealias Speed = Measurement<UnitSpeed> | |
| public extension Measurement where UnitType: Dimension { | |
| static var zero: Measurement<UnitType> { |
This file contains hidden or 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
| //============================================================================// | |
| // Part 1. StoredPropertyIterable | |
| // This models the purely static layout of a struct. | |
| //============================================================================// | |
| // This is an implementation detail that is required before PAT existentials are | |
| // possible. | |
| protocol _StoredPropertyIterableBase { | |
| static var _allStoredPropertiesTypeErased: [AnyKeyPath] { get } | |
| static var _recursivelyAllStoredPropertiesTypeErased: [AnyKeyPath] { get } |
This file contains hidden or 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 line(from p1: SCNVector3, to p2: SCNVector3) -> SCNNode? { | |
| // Draw a line between two points and return it as a node | |
| var indices = [Int32(0), Int32(1)] | |
| let positions = [p1, p2] | |
| let vertexSource = SCNGeometrySource(vertices: positions) | |
| let indexData = Data(bytes: &indices, count:MemoryLayout<Int32>.size * indices.count) | |
| let element = SCNGeometryElement(data: indexData, primitiveType: .line, primitiveCount: 1, bytesPerIndex: MemoryLayout<Int32>.size) | |
| let line = SCNGeometry(sources: [vertexSource], elements: [element]) | |
| let lineNode = SCNNode(geometry: line) |
This file contains hidden or 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
| @resultBuilder | |
| struct StringBuilder { | |
| static func buildBlock(_ components: String...) -> String { | |
| let filtered = components.filter { $0 != "" } | |
| return filtered.joined(separator: "⭐️") | |
| } | |
| static func buildOptional(_ component: String?) -> String { | |
| return component ?? "" |
This file contains hidden or 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 WeekdaySet: OptionSet { | |
| struct Info { | |
| var name: String | |
| var index: Int | |
| } | |
| static var info:[Int:Info] = [:] | |
| let rawValue: UInt8 | |
| init(rawValue: UInt8) { |
This file contains hidden or 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://exchangerate.host/#/faq | |
| var requestURL = 'https://api.exchangerate.host/convert?from=USD&to=EUR'; | |
| var request = new XMLHttpRequest(); | |
| request.open('GET', requestURL); | |
| request.responseType = 'json'; | |
| request.send(); | |
| request.onload = function() { |
This file contains hidden or 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
| // | |
| // Tokenizer.swift | |
| // | |
| // Created by Jason Jobe on 4/15/20. | |
| // Copyright © 2020 Jason Jobe. All rights reserved. | |
| // | |
| public struct Tokenizer { | |
| public struct ReadError: Error { | |
| var str: String | |
| var pos: Int |