Skip to content

Instantly share code, notes, and snippets.

Avatar

Felix M. fxm90

View GitHub Profile
@fxm90
fxm90 / Font+Formatting.swift
Last active Nov 14, 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 Nov 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 ./
@fxm90
fxm90 / URLSession+Result.swift
Last active Oct 24, 2019
Wrapper around `dataTask(with, completionHandler:)` that uses swifts result type in the completion handler.
View URLSession+Result.swift
//
// URLSession+Result.swift
// HttpRequestSample
//
// Created by Felix Mau on 08/16/19.
// Copyright © 2019 Felix Mau. All rights reserved.
//
import Foundation
@fxm90
fxm90 / Observable.swift
Last active Jun 16, 2019
A lightweight implementation of an observable sequence that you can subscribe to.
View Observable.swift
//
// For reusability reasons I've moved the code into a Framework.
// https://github.com/fxm90/LightweightObservable
//
@fxm90
fxm90 / UIView+AnimateAlpha.swift
Last active Jun 29, 2020
Animate the `alpha` value of a UIView and update the `isHidden` flag accordingly.
View UIView+AnimateAlpha.swift
//
// UIView+AnimateAlpha.swift
//
// Created by Felix Mau on 17/12/18.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import UIKit
extension UIView {
You can’t perform that action at this time.