Skip to content

Instantly share code, notes, and snippets.

@raulriera
raulriera / concierge.yml
Created March 7, 2021 15:43
Concierge Bot for your issues
name: Concierge bot
on:
issue_comment:
types: [created]
issues:
types: [opened]
jobs:
triaging:
import UIKit
class ViewController: UIViewController {
@IBOutlet private weak var cardView: UIView!
private var animator: UIDynamicAnimator!
private var snapping: UISnapBehavior!
override func viewDidLoad() {
super.viewDidLoad()
@raulriera
raulriera / CombinedCell.swift
Created December 11, 2017 14:23
CombinedCell implementation for the Building apps with FunctionalTableData
//
// CombinedCell.swift
// Project-01
//
// Created by Geoff Foster on 2017-12-08.
// Copyright © 2017 Raul Riera. All rights reserved.
//
import UIKit
import FunctionalTableData
@raulriera
raulriera / LabelCell.swift
Last active November 25, 2017 20:50
HostCell implementation of a UILabel for the Building apps with FunctionalTableData series
typealias LabelCell = HostCell<UILabel, LabelState, LayoutMarginsTableItemLayout>
struct LabelState: Equatable {
let text: String
let font: UIFont
let isMultiline: Bool
init(text: String, font: UIFont = UIFont.systemFont(ofSize: 17), isMultiline: Bool = true) {
self.text = text
self.font = font
@raulriera
raulriera / ConcealingTitleView.swift
Last active February 12, 2023 21:54
Final implementation for the Medium article "The case of the disappearing titleView" https://medium.com/shopify-mobile/the-case-of-the-disappearing-titleview-%EF%B8%8F-e516ffd2fea2
import Foundation
final class ConcealingTitleView: UIView {
private let label = UILabel()
private var contentOffset: CGFloat = 0 {
didSet {
label.frame.origin.y = titleVerticalPositionAdjusted(by: contentOffset)
}
}
var text: String = "" {
@raulriera
raulriera / Cacher.swift
Created December 7, 2016 14:40
Code sample for Medium article about Caching and Protocols
public protocol Cachable {
var fileName: String { get }
func transform() -> Data
}
final public class Cacher {
let destination: URL
private let queue = OperationQueue()
public enum CacheDestination {
import UIKit
// This class allows the "presentedController" to receive touches
// https://pspdfkit.com/blog/2015/presentation-controllers/
class PSPDFTouchForwardingView: UIView {
var passthroughViews: [UIView] = []
override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? {
guard let hitView = super.hitTest(point, withEvent: event) else { return nil }
@raulriera
raulriera / UserRequest.swift
Created January 16, 2016 15:42
Example of the Medium article
public struct UserRequest: DribbbleRequestType {
public typealias Response = User
public var path: String {
return "/user"
}
public func responseFromObject(object: AnyObject, URLResponse: NSHTTPURLResponse) -> Response? {
guard let dictionary = object as? [String: AnyObject] else {
return nil
public typealias URLSessionOperationCompletion = (data: NSData?, response: NSHTTPURLResponse?, error: NSError?) -> Void
public class URLSessionOperation: Operation {
private var task: NSURLSessionDataTask?
private var completionHandler: URLSessionOperationCompletion?
/**
Returns an instance of `URLSessionOperation`
@raulriera
raulriera / UIViewExtensions.swift
Created October 23, 2015 14:32
Sometimes I just want to get a given constraint
//
// UIViewExtensions.swift
//
// Created by Raúl Riera on 23/09/2015.
// Copyright (c) 2015 Raul Riera. All rights reserved.
//
import UIKit
extension UIView {