A full example of adding String
and AttributedString
output to our custom types, as well as adding the ability to parse String
values into your custom type.
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
// | |
// AdvancedToolbarWindow.swift | |
// | |
// Created by Stephan Casas on 3/17/23. | |
// | |
import SwiftUI; | |
import AppKit; | |
class AdvancedToolbarWindow<MainContent: View, TitleToolbarContent: View>: NSWindow, NSToolbarDelegate { |
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 | |
// AppleMusicLyricsPlayer | |
// | |
// Created by Magesh Sridhar on 2/5/23. | |
// | |
import SwiftUI | |
import AVKit |
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 | |
protocol TitleProvider { | |
var title: String { get } | |
} | |
extension ColorScheme { | |
var dual: ColorScheme { | |
switch self { | |
case .light: return .dark |
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
// | |
// NSPersistentContainer+extension.swift | |
// CDMoveDemo | |
// | |
// Created by Tom Harrington on 5/12/20. | |
// Copyright © 2020 Atomic Bird LLC. All rights reserved. | |
// | |
import Foundation | |
import CoreData |
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 URLProtocolMock: URLProtocol { | |
/// Dictionary maps URLs to tuples of error, data, and response | |
static var mockURLs = [URL?: (error: Error?, data: Data?, response: HTTPURLResponse?)]() | |
override class func canInit(with request: URLRequest) -> Bool { | |
// Handle all types of requests | |
return true | |
} | |
override class func canonicalRequest(for request: URLRequest) -> URLRequest { |
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 | |
/// A wrapper view that provides a mutable Binding to its content closure. | |
/// | |
/// Useful in Xcode Previews for interactive previews of views that take a Binding. | |
struct Stateful<Value, Content: View>: View { | |
var content: (Binding<Value>) -> Content | |
@State private var state: Value | |
init(initialState: Value, @ViewBuilder content: @escaping (Binding<Value>) -> Content) { |
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
# Redux in Ruby | |
class Store | |
attr_reader :state | |
def initialize(initial_state, *reducers) | |
@reducers = reducers | |
@state = initial_state || {} | |
end |
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
// Youtube Video: https://youtu.be/SBvrvJ93gh4 | |
import SwiftUI | |
import WebKit | |
struct ContentView: View { | |
let webView = WebView(request: URLRequest(url: URL(string: "https://www.google.com")!)) | |
var body: some View { | |
VStack { |