Skip to content

Instantly share code, notes, and snippets.

Felix M. fxm90

Block or report user

Report or block fxm90

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fxm90
fxm90 / ScreenOverlayViewModel.swift
Last active Oct 14, 2019
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 / WebViewExampleViewController.swift
Last active Sep 25, 2019
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 / 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 / URLSession+Result.swift
Last active Sep 5, 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 / 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 / swiftlint.sh
Last active Sep 1, 2019
Check "SwiftLint" installed via CocoaPods. Add a new "Run Script Phase" with this gist.
View swiftlint.sh
SWIFTLINT="${PODS_ROOT}/SwiftLint/swiftlint"
if [ ! -f "$SWIFTLINT" ]; then
echo "warning: SwiftLint not installed!"
exit 1
fi
$SWIFTLINT
@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 / NotificationTestCase.swift
Last active May 30, 2019
XCTest - Assert notification (not) triggered.
View NotificationTestCase.swift
import XCTest
class NotificationTestCase: XCTestCase {
func testTriggerNotification() {
expectation(forNotification: .fooBar,
object: nil,
handler: nil)
let notificationCenter = NotificationCenter.default
@fxm90
fxm90 / UIView+AnimateIsHidden.swift
Last active May 21, 2019
Animate the `alpha` value of a UIView and update the `isHidden` flag accordingly.
View UIView+AnimateIsHidden.swift
//
// UIView+AnimateIsHidden.swift
//
// Created by Felix Mau on 17/12/18.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import UIKit
extension UIView {
@fxm90
fxm90 / VerticalGradientImageView.swift
Last active Feb 11, 2019
An image view containing a vertical gradient as background.
View VerticalGradientImageView.swift
//
// VerticalGradientImageView.swift
//
// Created by Felix Mau on 23/09/18.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import UIKit
class VerticalGradientImageView: UIImageView {
You can’t perform that action at this time.