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
// | |
// IntelligenceUIPlatterView.swift | |
// | |
// Created by Stephan Casas on 2/13/25. | |
// | |
import SwiftUI | |
import AppKit | |
import Combine |
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 UIKit | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let button = UIButton(type: .system) | |
button.role = .primary | |
button.controlSize = .large |
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
// | |
// ContentView.swift | |
// Emoji Animation hero picker | |
// | |
// Created by Moussa on 3/4/2024. | |
// | |
import SwiftUI | |
struct ContentView: 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
// | |
// CDView.swift | |
// CD | |
// | |
// Created by Daniel Kuntz on 7/3/23. | |
// | |
import SwiftUI | |
struct ShapeWithHole: Shape { |
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 ContentView: View { | |
@State private var sliderValue: Double = 0.0 | |
@State private var selectedIndex: Int = -1 | |
@State private var remainder: Double = 0.0 | |
var body: some View { | |
VStack { | |
HStack { | |
ForEach(0..<5) { index in | |
ZStack { | |
Image(systemName: "star.fill") |
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
// Before π | |
let doingSomethingToOptionalView1: CGFloat? = { | |
guard let firstSubview = subviews.first else { return nil } | |
return (firstSubview.bounds.width / 2.0) + otherView.bounds.width | |
}() | |
// After π | |
let doingSomethingToOptionalView2 = subviews.first.useIfNotNil { ($0.bounds.width / 2.0) + otherView.bounds.width } | |
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
// Implementation of the view using AppKit. | |
#if os(macOS) | |
import AppKit | |
import SwiftUI | |
final class AppKitTextView: NSView { | |
let textView: NSTextView = { | |
let this = NSTextView() | |
this.translatesAutoresizingMaskIntoConstraints = false | |
return this |
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 | |
// Here's a pretty typical scenario where you want to encode a polymorphic type - | |
// in this case a Shape type that can be either a Square or Circle. Swift provides | |
// a nice pattern for doing this in a type-safe way using enums: | |
struct Circle: Codable { | |
var radius: Int | |
} |
NewerOlder