Skip to content

Instantly share code, notes, and snippets.

@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 = "" {
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 / 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:
@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
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 / PagingControl.js
Created April 19, 2012 02:13
Custom paging control for scrollableViews for Titanium Appcelerator
// I was unhappy about there was close to no control over the "pageControl"
// in scrollableViews, so I hacked my own
// -----
// Configuration
var pageColor = "#c99ed5";
PagingControl = function(scrollableView){
var container = Titanium.UI.createView({
height: 60
@raulriera
raulriera / HorizontalTableView.js
Created January 24, 2013 12:37
Horizontal TableView for Titanium Appcelerator. This still needs some android love, trying to use an inverted tableview made the table impossible to scroll (on android)
function HorizontalTableView(options) {
// defaults params
var options = options || {};
options.width = options.width || Titanium.Platform.displayCaps.platformWidth;
options.height = options.height || Titanium.Platform.displayCaps.platformHeight;
var isAndroid = Ti.Platform.osname === 'android';
// On iOS we can do this, on Android there is some weird scrolling problems
@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