Skip to content

Instantly share code, notes, and snippets.

@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 / Dictionary+MapKeys.swift
Last active January 25, 2026 16:35
Counterpart methods to `mapValues(_:)` and `compactMapValues(_:)`
//
// Dictionary+MapKeys.swift
//
// Created by Felix Mau on 14.06.21.
// Copyright © 2021 Felix Mau. All rights reserved.
//
extension Dictionary {
@fxm90
fxm90 / CheckboxToggleStyle.swift
Last active January 25, 2026 15:57
A custom `ToggleStyle` that presents a SwiftUI `Toggle` as a checkbox.
//
// CheckboxToggleStyle.swift
//
// Created by Felix Mau on 25.05.2021.
// Copyright © 2021 Felix Mau. All rights reserved.
//
import SwiftUI
// MARK: - Config
@fxm90
fxm90 / Combine+Pairwise.swift
Last active January 25, 2026 15:36
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 / ColoredToggleStyle.swift
Last active January 25, 2026 15:51
A custom `ToggleStyle` that renders a colored, pill-shaped switch with a shadowed circular thumb.
//
// ColoredToggleStyle.swift
//
// Created by Felix Mau on 29.03.2021.
// Copyright © 2021 Felix Mau. All rights reserved.
//
import SwiftUI
// MARK: - Config
@fxm90
fxm90 / CombinePublishedVsCurrentValueSubject.swift
Last active January 25, 2026 20:29
Gist showing the difference between the property wrapper `@Published` and a `CurrentValueSubject`
//
// CombinePublishedVsCurrentValueSubject.playground
//
// Created by Felix Mau on 09.02.21.
// Copyright © 2021 Felix Mau. All rights reserved.
//
import Combine
final class PublishedTest {
@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
@fxm90
fxm90 / Font+Formatting.swift
Last active June 28, 2021 07:50
Extension that converts Strings with basic HTML tags to SwiftUI's Text (Supports SwiftUI 1.0 / iOS 13.0).
//
// Font+Formatting.swift
//
// Created by Felix Mau on 12.11.20.
// Copyright © 2020 Felix Mau. All rights reserved.
//
import Foundation
import SwiftUI
@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 / Combine-CLLocationManagerDelegate.swift
Last active January 25, 2026 15:00
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