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 | |
| enum Experiment: String, CaseIterable, Identifiable { | |
| case form | |
| case concentricRect | |
| case uniformConcentricRect | |
| case containerRelative | |
| case containerRelativeWithContainerShape | |
| case containerCornerInsets |
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 TabBar: View { | |
| @State private var selectedTab: Tab = .overview | |
| @Namespace private var ns | |
| enum Tab { | |
| case overview, data, graphs, settings | |
| } | |
| var body: some View { |
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 | |
| import SwiftUI | |
| import UIKit | |
| extension UIBlurEffect { | |
| public static func variableBlurEffect(radius: Double, imageMask: UIImage) -> UIBlurEffect? { | |
| let methodType = (@convention(c) (AnyClass, Selector, Double, UIImage) -> UIBlurEffect).self | |
| let selectorName = ["imageMask:", "effectWithVariableBlurRadius:"].reversed().joined() | |
| let selector = NSSelectorFromString(selectorName) |
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
| // A URLSession extension that fetches data from a URL and decodes to some Decodable type. | |
| // Usage: let user = try await URLSession.shared.decode(UserData.self, from: someURL) | |
| // Note: this requires Swift 5.5. | |
| extension URLSession { | |
| func decode<T: Decodable>( | |
| _ type: T.Type = T.self, | |
| from url: URL, | |
| keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys, | |
| dataDecodingStrategy: JSONDecoder.DataDecodingStrategy = .deferredToData, | |
| dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate |