Skip to content

Instantly share code, notes, and snippets.

Avatar

Felix M. fxm90

View GitHub Profile
@fxm90
fxm90 / WebViewExampleViewController.swift
Last active Jun 8, 2022
Show progress of WKWebView in UIProgressBar that is attached to an UINavigationBar
View WebViewExampleViewController.swift
//
// WebViewExampleViewController.swift
//
// Created by Felix Mau on 06.01.18.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import UIKit
import WebKit
@fxm90
fxm90 / Combine+Pairwise.swift
Last active May 18, 2022
Extension for a Combine-Publisher that returns the current and previous value.
View Combine+Pairwise.swift
//
// Combine+Pairwise.swift
//
// Created by Felix Mau on 17.05.21.
// Copyright © 2021 Felix Mau. All rights reserved.
//
import Combine
extension Publisher {
@fxm90
fxm90 / ScreenOverlayViewModel.swift
Last active May 9, 2022
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 / Combine-CLLocationManagerDelegate.swift
Last active May 2, 2022
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 Combine
import CoreLocation
@fxm90
fxm90 / swiftui.stencil
Last active May 2, 2022
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 / SwiftUI+HTML.swift
Created Jun 28, 2021
Extension that converts Strings with basic HTML tags to SwiftUI's Text (Supports SwiftUI 3.0 / iOS 15.0).
View SwiftUI+HTML.swift
//
// 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 / UIView+AnimateAlpha.swift
Last active Dec 22, 2021
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 {
@fxm90
fxm90 / Combine-PassthroughSubject-CurrentValueSubject.swift
Last active Nov 17, 2021
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 / Font+Formatting.swift
Last active Jun 28, 2021
Extension that converts Strings with basic HTML tags to SwiftUI's Text (Supports SwiftUI 1.0 / iOS 13.0).
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 / Dictionary+PlusAssignment.swift
Last active Jun 14, 2021
Combine two dictionaries of same type with custom operator.
View Dictionary+PlusAssignment.swift
extension Dictionary {
/// Combine two dictionaries of same type with `+` operator.
///
/// - Important: When `left` and `right` are having a same key, the value from `right` will override
/// the value from `left`. E.g.
/// ```
/// var left = ["a": 1, "b": 2]
/// let right = ["a": 3, "c": 4]
/// left += right
/// print(left)