Skip to content

Instantly share code, notes, and snippets.

Avatar

Felix M. fxm90

View GitHub Profile
@fxm90
fxm90 / ColoredToggleStyle.swift
Last active Mar 29, 2021
A fully configurable toggle style for SwiftUI.
View ColoredToggleStyle.swift
//
// ColoredToggleStyle.swift
//
// Created by Felix Mau on 29.03.2021.
// Copyright © 2021 Felix Mau. All rights reserved.
//
/// A fully configurable toggle style.
struct ColoredToggleStyle: ToggleStyle {
@fxm90
fxm90 / CombinePublishedVsCurrentValueSubject.playground
Last active Mar 29, 2021
Gist showing the difference between the property wrapper `@Published` and a `CurrentValueSubject`
View CombinePublishedVsCurrentValueSubject.playground
//
// CombinePublishedVsCurrentValueSubject.playground
//
// Created by Felix Mau on 09.02.21.
// Copyright © 2021 Felix Mau. All rights reserved.
//
import Foundation
import Combine
@fxm90
fxm90 / swiftui.stencil
Last active Feb 16, 2021
A stencil template for generating SwiftUI assets with SwiftGen. Currently only `Image` and `Color` are supported.
View swiftui.stencil
//
// 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 Nov 27, 2020
Extension that converts Strings with basic HTML tags to SwiftUI's Text.
View Font+Formatting.swift
//
// 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 Nov 23, 2020
Playground showing how to use Redux with SwiftUI.
View Redux.swift
//
// Redux.playground
//
// Created by Felix Mau on 25.06.20.
// Copyright © 2020 Felix Mau. All rights reserved.
//
import PlaygroundSupport
import Combine
import SwiftUI
@fxm90
fxm90 / Combine-CLLocationManagerDelegate.swift
Created Jul 31, 2020
Playground showing how to convert a delegate pattern to combine publishers.
View Combine-CLLocationManagerDelegate.swift
//
// Combine-CLLocationManagerDelegate.playground
//
// Created by Felix Mau on 30.07.20.
// Copyright © 2020 Felix Mau. All rights reserved.
//
import PlaygroundSupport
import Foundation
import CoreLocation
@fxm90
fxm90 / Combine-PassthroughSubject-CurrentValueSubject.swift
Last active Dec 24, 2020
Playground showing the difference between a `PassthroughSubject` and a `CurrentValueSubject`
View Combine-PassthroughSubject-CurrentValueSubject.swift
//
// Combine-PassthroughSubject-CurrentValueSubject.playground
//
// Created by Felix Mau on 30.07.20.
// Copyright © 2020 Felix Mau. All rights reserved.
//
import PlaygroundSupport
import Combine
@fxm90
fxm90 / ScreenOverlayViewModel.swift
Last active Aug 1, 2020
Example on how to elegantly test a delegate protocol.
View ScreenOverlayViewModel.swift
//
// 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 / UIColor+MakeDynamicColor.swift
Last active Sep 23, 2019
Creates an instance of `UIColor`, that generates its color data dynamically based on the current `userInterfaceStyle`. Furthermore this method falls back to the `lightVariant` color for iOS versions prior to iOS 13.
View UIColor+MakeDynamicColor.swift
//
// UIColor+MakeDynamicColor.swift
//
// Created by Felix Mau on 22/09/19.
// Copyright © 2019 Felix Mau. All rights reserved.
//
import Foundation
extension UIColor {
@fxm90
fxm90 / swiftformat.sh
Created Sep 1, 2019
Check "SwiftFormat" installed via CocoaPods. Add a new "Run Script Phase" with this gist.
View swiftformat.sh
SWIFTFORMAT="${PODS_ROOT}/SwiftFormat/CommandLineTool/swiftformat"
if [ ! -f "$SWIFTFORMAT" ]; then
echo "warning: SwiftFormat not installed!"
exit 1
fi
$SWIFTFORMAT ./