Skip to content

Instantly share code, notes, and snippets.

View seanlilmateus's full-sized avatar

Mateus seanlilmateus

View GitHub Profile
@seanlilmateus
seanlilmateus / AdvancedToolbarWindow.swift
Created March 18, 2023 07:08 — forked from stephancasas/AdvancedToolbarWindow.swift
A SwiftUI-compatible window for macOS with advanced toolbar configurability.
//
// AdvancedToolbarWindow.swift
//
// Created by Stephan Casas on 3/17/23.
//
import SwiftUI;
import AppKit;
class AdvancedToolbarWindow<MainContent: View, TitleToolbarContent: View>: NSWindow, NSToolbarDelegate {
//
// ContentView.swift
// AppleMusicLyricsPlayer
//
// Created by Magesh Sridhar on 2/5/23.
//
import SwiftUI
import AVKit
@seanlilmateus
seanlilmateus / PhotosStylePicker-Final.swift
Created December 29, 2022 00:08 — forked from HarshilShah/PhotosStylePicker-Final.swift
A SwiftUI picker that tries to match the Years/Months/Days/All Photos palette in the Library tab of Photos for iOS
import SwiftUI
protocol TitleProvider {
var title: String { get }
}
extension ColorScheme {
var dual: ColorScheme {
switch self {
case .light: return .dark
@seanlilmateus
seanlilmateus / NSPersistentContainer+extension.swift
Created December 18, 2022 13:08 — forked from atomicbird/NSPersistentContainer+extension.swift
Back up and restore Core Data persistent stores
//
// NSPersistentContainer+extension.swift
// CDMoveDemo
//
// Created by Tom Harrington on 5/12/20.
// Copyright © 2020 Atomic Bird LLC. All rights reserved.
//
import Foundation
import CoreData
@seanlilmateus
seanlilmateus / URLProtocolMock.swift
Created November 2, 2022 22:07 — forked from soujohnreis/URLProtocolMock.swift
Mock URLSession using URLProtocol
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 {
@seanlilmateus
seanlilmateus / 1.README.md
Created October 1, 2022 10:09 — forked from brettohland/1.README.md
ISBN example with FormatStyle, AttributedStringFormatStyle, ParseableFormatStyle conformance.

Supporting FormatStyle & ParseableFormatStyle To Your Custom Types

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.

Read the blog post

See the Xcode Playground

ko-fi

@seanlilmateus
seanlilmateus / 1.0 README.md
Created October 1, 2022 10:06 — forked from brettohland/1.0 README.md
ParseableFormatStyle Examples
@seanlilmateus
seanlilmateus / Stateful.swift
Created September 2, 2022 15:34 — forked from ole/Stateful.swift
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.
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) {
@seanlilmateus
seanlilmateus / ruby-redux.rb
Created July 21, 2022 20:17 — forked from eadz/ruby-redux.rb
Redux in Ruby
# Redux in Ruby
class Store
attr_reader :state
def initialize(initial_state, *reducers)
@reducers = reducers
@state = initial_state || {}
end
@seanlilmateus
seanlilmateus / ContentView.swift
Created June 24, 2022 01:54 — forked from awunnenb/ContentView.swift
SwiftUI WKWebView and Back- Forward Buttons
// 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 {