Skip to content

Instantly share code, notes, and snippets.

@fxm90
fxm90 / Combine+Pairwise.swift
Last active February 17, 2024 02:09
Extension for a Combine-Publisher that returns the current and previous value.
//
// Combine+Pairwise.swift
//
// Created by Felix Mau on 17.05.21.
// Copyright © 2021 Felix Mau. All rights reserved.
//
import Combine
extension Publisher {
@fxm90
fxm90 / SwiftUI+HTML.swift
Created June 28, 2021 14:43
Extension that converts Strings with basic HTML tags to SwiftUI's Text (Supports SwiftUI 3.0 / iOS 15.0).
//
// SwiftUI+HTML.swift
//
// Created by Felix Mau on 28.05.21.
// Copyright © 2021 Felix Mau. All rights reserved.
//
import SwiftUI
@available(iOS 15.0, *)
@fxm90
fxm90 / Combine-CLLocationManagerDelegate.swift
Last active July 13, 2023 09:15
Playground showing how to convert a delegate pattern to combine publishers.
//
// Combine-CLLocationManagerDelegate.playground
//
// Created by Felix Mau on 30.07.20.
// Copyright © 2020 Felix Mau. All rights reserved.
//
import PlaygroundSupport
import Combine
import CoreLocation
@fxm90
fxm90 / WebViewExampleViewController.swift
Last active June 17, 2023 01:18
Show progress of WKWebView in UIProgressBar that is attached to an UINavigationBar
//
// WebViewExampleViewController.swift
//
// Created by Felix Mau on 06.01.18.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import UIKit
import WebKit
@fxm90
fxm90 / CheckboxToggleStyle.swift
Last active March 31, 2023 17:38
A fully configurable toggle style for SwiftUI, making the Toggle look like a checkbox.
//
// CheckboxToggleStyle.swift
//
// Created by Felix Mau on 25.05.2021.
// Copyright © 2021 Felix Mau. All rights reserved.
//
/// A fully configurable toggle style for SwiftUI, making the Toggle look like a checkbox.
struct CheckboxToggleStyle: ToggleStyle {
@fxm90
fxm90 / String+Log.swift
Last active February 4, 2023 17:47
A simple log extension on `String` using literal expressions
//
// String+Log.swift
//
// Created by Felix Mau on 16/09/18.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import Foundation
extension String {
@fxm90
fxm90 / Redux.swift
Last active December 12, 2022 10:52
Playground showing how to use Redux with SwiftUI.
//
// Redux.playground
//
// Created by Felix Mau on 25.06.20.
// Copyright © 2020 Felix Mau. All rights reserved.
//
import PlaygroundSupport
import SwiftUI
@fxm90
fxm90 / NotificationCenter+ObserveOnce.swift
Last active December 5, 2022 15:15
Extension for "NotificationCenter" to observe a notification just once and directly unsubscribe.
//
// NotificationCenter+ObserveOnce.swift
//
// Created by Felix Mau on 18.10.20.
// Copyright © 2020 Felix Mau. All rights reserved.
//
import UIKit
extension NotificationCenter {
@fxm90
fxm90 / ScreenOverlayViewModel.swift
Last active May 9, 2022 14:46
Example on how to elegantly test a delegate protocol.
//
// ScreenOverlayViewModel.swift
//
// Created by Felix Mau on 12.10.19.
// Copyright © 2019 Felix Mau. All rights reserved.
//
protocol ScreenOverlayViewModelDelegate: AnyObject {
func screenOverlayViewModelDidUpdate(alpha: CGFloat)
}
@fxm90
fxm90 / swiftui.stencil
Last active May 2, 2022 04:00
A stencil template for generating SwiftUI assets with SwiftGen. Currently only `Image` and `Color` are supported.
//
// Do not edit! File generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
//
// SwiftUI Template by Felix Mau – https://felix.hamburg
//
// Latest version available at https://gist.github.com/fxm90/d1eb5439ad0f45d727bdb98132e933a6
//
import SwiftUI