Slide 1

Slide 1 text

share your code

Slide 2

Slide 2 text

share your code

Slide 3

Slide 3 text

Brian Gesiak
 @modocache

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

github.com/Quick/Quick/ issues/300

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

✨ BananaUIKit

Slide 11

Slide 11 text

Series A
 B


Slide 12

Slide 12 text

Series X
 Y
 Z


Slide 13

Slide 13 text

abstractions 
 for what will change

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

@interface BananaAlertView : UIAlertView + (void)showWithTitleText:(NSString *)titleText messageText:(NSString *)messageText dismissButtonText:(NSString *)dismissButtonText; @end

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

@interface BananaAlertView : UIAlertView + (void)showWithTitleText:(NSString *)titleText messageText:(NSString *)messageText dismissButtonText:(NSString *)dismissButtonText; @end

Slide 19

Slide 19 text

@interface BananaAlertView : UIAlertView + (void)showWithTitleText:(NSString *)titleText messageText:(NSString *)messageText dismissButtonText:(NSString *)dismissButtonText; @end tintColor:(UIColor *)tintColor;

Slide 20

Slide 20 text

[BananaAlertView showWithTitleText:@"403 Error" messageText:@"Forbidden banana." dismissButtonText:@"Dang."];

Slide 21

Slide 21 text

[BananaAlertView showWithTitleText:@"403 Error" messageText:@"Forbidden banana." dismissButtonText:@"Dang."]; No known class method for selector 'showWithTitleText:messageText:…'

Slide 22

Slide 22 text

BananaUIKit

Slide 23

Slide 23 text

BananaUIKit 2.0

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

v1.0 v1.1 v2.0 v2.1 v2.2

Slide 26

Slide 26 text

[BananaAlertView showWithTitleText:@"403 Error" messageText:@"Forbidden banana." dismissButtonText:@"Dang."]; No known class method for selector 'showWithTitleText:messageText:…'

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

@interface BananaAlertView : UIAlertView + (void)showWithTitleText:(NSString *)titleText messageText:(NSString *)messageText dismissButtonText:(NSString *)dismissButtonText; + (void)showWithTitleText:(NSString *)titleText messageText:(NSString *)messageText dismissButtonText:(NSString *)dismissButtonText tintColor:(UIColor *)tintColor; @end

Slide 29

Slide 29 text

@interface BananaAlertView : UIAlertView + (void)showWithTitleText:(NSString *)titleText messageText:(NSString *)messageText dismissButtonText:(NSString *)dismissButtonText; + (void)showWithTitleText:(NSString *)titleText messageText:(NSString *)messageText dismissButtonText:(NSString *)dismissButtonText tintColor:(UIColor *)tintColor; @end

Slide 30

Slide 30 text

@implementation BananaAlertView + (void)showWithTitleText:(NSString *)titleText messageText:(NSString *)messageText dismissButtonText:(NSString *)dismissButtonText { [self showWithTitleText:titleText messageText:messageText dismissButtonText:dismissButtonText tintColor:[UIColor yellowColor]]; } + (void)showWithTitleText:(NSString *)titleText messageText:(NSString *)messageText dismissButtonText:(NSString *)dismissButtonText tintColor:(UIColor *)tintColor { // ... }

Slide 31

Slide 31 text

@implementation BananaAlertView + (void)showWithTitleText:(NSString *)titleText messageText:(NSString *)messageText dismissButtonText:(NSString *)dismissButtonText { [self showWithTitleText:titleText messageText:messageText dismissButtonText:dismissButtonText tintColor:[UIColor yellowColor]]; } + (void)showWithTitleText:(NSString *)titleText messageText:(NSString *)messageText dismissButtonText:(NSString *)dismissButtonText tintColor:(UIColor *)tintColor { // ... }

Slide 32

Slide 32 text

@implementation BananaAlertView + (void)showWithTitleText:(NSString *)titleText messageText:(NSString *)messageText dismissButtonText:(NSString *)dismissButtonText { [self showWithTitleText:titleText messageText:messageText dismissButtonText:dismissButtonText tintColor:[UIColor yellowColor]]; } + (void)showWithTitleText:(NSString *)titleText messageText:(NSString *)messageText dismissButtonText:(NSString *)dismissButtonText tintColor:(UIColor *)tintColor { // ... }

Slide 33

Slide 33 text

[BananaAlertView showWithTitleText:@"403 Error" messageText:@"Forbidden banana." dismissButtonText:@"Dang."];

Slide 34

Slide 34 text

[BananaAlertView showWithTitleText:@"403 Error" messageText:@"Forbidden banana." dismissButtonText:@"Dang."]; [BananaAlertView showWithTitleText:@"500 Error" messageText:@"Internal banana." dismissButtonText:@"Rats."
 tintColor:[UIColor redColor]];

Slide 35

Slide 35 text

public class BananaAlertView { public static func show( titleText: String, messageText: String, dismissButtonText: String) {
 // ... } }

Slide 36

Slide 36 text

public class BananaAlertView { public static func show( titleText: String, messageText: String, dismissButtonText: String) {
 // ... } } dismissButtonText: String, tintColor: UIColor = UIColor.yellowColor()) { // ... }

Slide 37

Slide 37 text

public typealias ButtonCallback = (buttonIndex: Int) -> () public class BananaAlertView { public static func show( titleText: String, messageText: String, dismissButtonText: String, dismissButtonCallback: ButtonCallback, tintColor: UIColor = UIColor.yellowColor()) { // ... } }

Slide 38

Slide 38 text

public typealias ButtonCallback = (buttonIndex: Int) -> () public class BananaAlertView { public static func show( titleText: String, messageText: String, dismissButtonText: String, dismissButtonCallback: ButtonCallback, tintColor: UIColor = UIColor.yellowColor()) { // ... } }

Slide 39

Slide 39 text

public typealias ButtonCallback = (buttonIndex: Int) -> () public class BananaAlertView { public static func show( titleText: String, messageText: String, dismissButtonText: String, dismissButtonCallback: ButtonCallback, tintColor: UIColor = UIColor.yellowColor()) { // ... } }

Slide 40

Slide 40 text

BananaAlertView.show( "500 Error", messageText: "Internal banana error.", dismissButtonText: "Rats.", dismissButtonCallback: { (buttonIndex: Int) in
 // ...
 }, tintColor: UIColor.redColor() )

Slide 41

Slide 41 text

BananaAlertView.show( "500 Error", messageText: "Internal banana error.", dismissButtonText: "Rats.", dismissButtonCallback: { (buttonIndex: Int) in
 // ...
 }, tintColor: UIColor.redColor() )

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

public typealias ButtonCallback = (buttonIndex: Int) -> () public class BananaAlertView { public static func show( titleText: String, messageText: String, dismissButtonText: String, dismissButtonCallback: ButtonCallback, tintColor: UIColor = UIColor.yellowColor()) { // ... } }

Slide 44

Slide 44 text

public typealias ButtonCallback = (buttonIndex: Int) -> () public class BananaAlertView { public static func show( titleText: String, messageText: String, dismissButtonText: String, dismissButtonCallback: ButtonCallback, tintColor: UIColor = UIColor.yellowColor()) { // ... } } (buttonIndex: Int, buttonTitle: String) -> ()

Slide 45

Slide 45 text

BananaAlertView.show( "500 Error", messageText: "Internal banana error.", dismissButtonText: "Rats.", dismissButtonCallback: { (buttonIndex: Int) in
 // ...
 }, tintColor: UIColor.redColor() )

Slide 46

Slide 46 text

BananaAlertView.show( "500 Error", messageText: "Internal banana error.", dismissButtonText: "Rats.", dismissButtonCallback: { (buttonIndex: Int) in
 // ...
 }, tintColor: UIColor.redColor() ) Cannot invoke 'show' with an argument list of type '(String, message…

Slide 47

Slide 47 text

BananaAlertView.show( "500 Error", messageText: "Internal banana error.", dismissButtonText: "Rats.", dismissButtonCallback: { (buttonIndex: Int) in
 // ...
 }, tintColor: UIColor.redColor() ) Cannot invoke 'show' with an argument list of type '(String, message…

Slide 48

Slide 48 text

parameter objects

Slide 49

Slide 49 text

public struct ButtonCallbackParameters { let buttonIndex: Int let buttonText: String } public typealias ButtonCallback = (buttonIndex: Int) -> ()

Slide 50

Slide 50 text

public struct ButtonCallbackParameters { let buttonIndex: Int let buttonText: String } public typealias ButtonCallback = (buttonIndex: Int) -> ()

Slide 51

Slide 51 text

public struct ButtonCallbackParameters { let buttonIndex: Int let buttonText: String } public typealias ButtonCallback = (buttonIndex: Int) -> () public typealias ButtonCallback = (parameters: ButtonCallbackParameters) -> ()

Slide 52

Slide 52 text

BananaAlertView.show( "500 Error", messageText: "Internal banana error.", dismissButtonText: "Rats.", dismissButtonCallback: { (buttonIndex: Int) in
 // ...
 }, tintColor: UIColor.redColor() )

Slide 53

Slide 53 text

BananaAlertView.show( "500 Error", messageText: "Internal banana error.", dismissButtonText: "Rats.", dismissButtonCallback: { (buttonIndex: Int) in
 // ...
 }, tintColor: UIColor.redColor() ) dismissButtonCallback: { parameters in if parameters.buttonText == "Rats." { // ... } },

Slide 54

Slide 54 text

BananaAlertView.show( "500 Error", messageText: "Internal banana error.", dismissButtonText: "Rats.", dismissButtonCallback: { (buttonIndex: Int) in
 // ...
 }, tintColor: UIColor.redColor() ) dismissButtonCallback: { parameters in if parameters.buttonText == "Rats." { // ... } },

Slide 55

Slide 55 text

public struct ButtonCallbackParameters { let buttonIndex: Int let buttonTitle: String } public typealias ButtonCallback = (parameters: ButtonCallbackParameters) -> ()

Slide 56

Slide 56 text

public struct ButtonCallbackParameters { let buttonIndex: Int let buttonTitle: String } public typealias ButtonCallback = (parameters: ButtonCallbackParameters) -> () let totalButtonCount: Int

Slide 57

Slide 57 text

public struct ButtonCallbackParameters { let buttonIndex: Int let buttonTitle: String } public typealias ButtonCallback = (parameters: ButtonCallbackParameters) -> () let totalButtonCount: Int

Slide 58

Slide 58 text

BananaAlertView.show( "500 Error", messageText: "Internal banana error.", dismissButtonText: "Rats.", dismissButtonCallback: { parameters in if parameters.buttonText == "Rats." { // ... } }, tintColor: UIColor.redColor() )

Slide 59

Slide 59 text

BananaAlertView.show( "500 Error", messageText: "Internal banana error.", dismissButtonText: "Rats.", dismissButtonCallback: { parameters in if parameters.buttonText == "Rats." { // ... } }, tintColor: UIColor.redColor() )

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

public struct ButtonCallbackParameters { let buttonIndex: Int
 let buttonTitle: String
 let totalButtonCount: Int } public typealias ButtonCallback = (parameters: ButtonCallbackParameters) -> ()

Slide 62

Slide 62 text

public struct ButtonCallbackParameters { let buttonIndex: Int
 let buttonTitle: String
 let totalButtonCount: Int } public typealias ButtonCallback = (parameters: ButtonCallbackParameters) -> () @availability(*, deprecated=2.0)

Slide 63

Slide 63 text

BananaAlertView.show( "500 Error", messageText: "Internal banana error.", dismissButtonText: "Rats.", dismissButtonCallback: { parameters in if parameters.buttonText == "Rats." { // ... } }, tintColor: UIColor.redColor() )

Slide 64

Slide 64 text

BananaAlertView.show( "500 Error", messageText: "Internal banana error.", dismissButtonText: "Rats.", dismissButtonCallback: { parameters in if parameters.buttonText == "Rats." { // ... } }, tintColor: UIColor.redColor() ) 'buttonText' was deprecated in * version 2.0

Slide 65

Slide 65 text

public struct AlertViewOptions {
 public let dismissButtonText: String
 public let tintColor: UIColor public let animationDuration: NSTimeInterval } public class BananaAlertView { public static func show( titleText: String, messageText: String, options: AlertViewOptions) { // ... } }

Slide 66

Slide 66 text

public struct AlertViewOptions {
 public let dismissButtonText: String
 public let tintColor: UIColor public let animationDuration: NSTimeInterval } public class BananaAlertView { public static func show( titleText: String, messageText: String, options: AlertViewOptions) { // ... } } = AlertViewOptions()) { = "OK" = UIColor.yellowColor() = 1

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

# U+1F645 KENT BECK

Slide 75

Slide 75 text

#

Slide 76

Slide 76 text

future-proof your API

Slide 77

Slide 77 text

more overhead

Slide 78

Slide 78 text

don’t force users to choose

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

@interface JVFloatLabeledTextField : UITextField @property (nonatomic, assign) CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIFont *floatingLabelFont UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIColor *floatingLabelTextColor UI_APPEARANCE_SELECTOR; @end

Slide 82

Slide 82 text

@interface JVFloatLabeledTextField : UITextField @property (nonatomic, assign) CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIFont *floatingLabelFont UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIColor *floatingLabelTextColor UI_APPEARANCE_SELECTOR; @end

Slide 83

Slide 83 text

CGRect frame = CGRectMake(0.f, 0.f, 100.f, 44.f); JVFloatLabeledTextField *textField = [[JVFloatLabeledTextField alloc] initWithFrame:frame];

Slide 84

Slide 84 text

CGRect frame = CGRectMake(0.f, 0.f, 100.f, 44.f); JVFloatLabeledTextField *textField = [[JVFloatLabeledTextField alloc] initWithFrame:frame]; textField.placeholder = @"Price"; textField.floatingLabelYPadding = 10.f; textField.floatingLabelTextColor = [UIColor blueColor];

Slide 85

Slide 85 text

CGRect frame = CGRectMake(0.f, 0.f, 100.f, 44.f); JVFloatLabeledTextField *textField = [[JVFloatLabeledTextField alloc] initWithFrame:frame]; textField.placeholder = @"Price"; textField.floatingLabelYPadding = 10.f; textField.floatingLabelTextColor = [UIColor blueColor];

Slide 86

Slide 86 text

subclasses force people to use your class exclusively

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

No content

Slide 89

Slide 89 text

@interface UITextField (JVFloatLabeledTextField) @property (nonatomic, assign) CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIFont *floatingLabelFont UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIColor *floatingLabelTextColor UI_APPEARANCE_SELECTOR; @end @interface JVFloatLabeledTextField : UITextField

Slide 90

Slide 90 text

@interface UITextField (JVFloatLabeledTextField) @property (nonatomic, assign) CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIFont *floatingLabelFont UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIColor *floatingLabelTextColor UI_APPEARANCE_SELECTOR; @end

Slide 91

Slide 91 text

@interface UITextField (JVFloatLabeledTextField) @property (nonatomic, assign) CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIFont *floatingLabelFont UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIColor *floatingLabelTextColor UI_APPEARANCE_SELECTOR; @end

Slide 92

Slide 92 text

@interface UITextField (JVFloatLabeledTextField) { CGFloat _floatingLabelYPadding; } @property (nonatomic, assign) CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR; @end

Slide 93

Slide 93 text

@interface UITextField (JVFloatLabeledTextField) { CGFloat _floatingLabelYPadding; } @property (nonatomic, assign) CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR; @end

Slide 94

Slide 94 text

const void * const YPaddingKey = &YPaddingKey; - (void)setFloatingLabelYPadding:(CGFloat)yPadding { objc_setAssociatedObject( self, YPaddingKey, @(yPadding), OBJC_ASSOCIATION_RETAIN_NONATOMIC ); } - (CGFloat)floatingLabelYPadding { return [objc_getAssociatedObject(self, YPaddingKey) floatValue]; }

Slide 95

Slide 95 text

const void * const YPaddingKey = &YPaddingKey; - (void)setFloatingLabelYPadding:(CGFloat)yPadding { objc_setAssociatedObject( self, YPaddingKey, @(yPadding), OBJC_ASSOCIATION_RETAIN_NONATOMIC ); } - (CGFloat)floatingLabelYPadding { return [objc_getAssociatedObject(self, YPaddingKey) floatValue]; }

Slide 96

Slide 96 text

const void * const YPaddingKey = &YPaddingKey; - (void)setFloatingLabelYPadding:(CGFloat)yPadding { objc_setAssociatedObject( self, YPaddingKey, @(yPadding), OBJC_ASSOCIATION_RETAIN_NONATOMIC ); } - (CGFloat)floatingLabelYPadding { return [objc_getAssociatedObject(self, YPaddingKey) floatValue]; }

Slide 97

Slide 97 text

@interface UITextField (JVFloatLabeledTextField) @property (nonatomic, assign) CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIFont *floatingLabelFont UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIColor *floatingLabelTextColor UI_APPEARANCE_SELECTOR; @end

Slide 98

Slide 98 text

@interface UITextField (JVFloatLabeledTextField) @property (nonatomic, assign) CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIFont *floatingLabelFont UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIColor *floatingLabelTextColor UI_APPEARANCE_SELECTOR; @end

Slide 99

Slide 99 text

const void * const YPaddingKey = &YPaddingKey; const void * const FontKey = &FontKey; const void * const TextColorKey = &TextColorKey; - (void)setFloatingLabelYPadding:(CGFloat)yPadding { objc_setAssociatedObject( self, YPaddingKey, @(yPadding), OBJC_ASSOCIATION_RETAIN_NONATOMIC ); } - (CGFloat)floatingLabelYPadding { return [objc_getAssociatedObject(self, YPaddingKey) floatValue];

Slide 100

Slide 100 text

} - (UIFont *)floatingLabelFont { return objc_getAssociatedObject(self, FontKey); } - (void)setFloatingLabelTextColor:(UIColor *)color { objc_setAssociatedObject( self, TextColorKey, color, OBJC_ASSOCIATION_RETAIN_NONATOMIC ); } - (UIColor *)floatingLabelTextColor { return objc_getAssociatedObject(self, TextColorKey); }

Slide 101

Slide 101 text

extension UITextField { var floatingLabelYPadding: CGFloat { set { objc_setAssociatedObject( self, &YPaddingKey, newValue, objc_AssociationPolicy(OBJC_ASSOCIATION_ASSIGN) ) } get { if let padding = objc_getAssociatedObject( self, &YPaddingKey) as? CGFloat { return padding } else { return 0

Slide 102

Slide 102 text

extension UITextField { var floatingLabelYPadding: CGFloat { set { objc_setAssociatedObject( self, &YPaddingKey, newValue, objc_AssociationPolicy(OBJC_ASSOCIATION_ASSIGN) ) } get { if let padding = objc_getAssociatedObject( self, &YPaddingKey) as? CGFloat { return padding } else { return 0

Slide 103

Slide 103 text

&TextColorKey, newValue, objc_AssociationPolicy( OBJC_ASSOCIATION_RETAIN_NONATOMIC) ) } get { if let color = objc_getAssociatedObject( self, &TextColorKey) as? UIColor { return color } else { return UIColor.blackColor() } } } }

Slide 104

Slide 104 text

doesn’t scale

Slide 105

Slide 105 text

// objc4-532/runtime/objc-references.mm
 
 // class AssociationsManager manages a lock / hash table // singleton pair. Allocating an instance acquires the // lock, and calling its assocations() method // lazily allocates it. class AssociationsManager { static OSSpinLock _lock; // associative references: // object pointer -> PtrPtrHashMap. static AssociationsHashMap *_map; public: AssociationsManager() { OSSpinLockLock(&_lock); } ~AssociationsManager() { OSSpinLockUnlock(&_lock); } };

Slide 106

Slide 106 text

CGFloat *floatingLabelYPadding UIFont *floatingLabelFont UIColor *floatingLabelTextColor UIColor *floatingLabelActiveColor BOOL animateEvenIfNotFirstResponder UITextField
 (JVFloatLabeledTextField)

Slide 107

Slide 107 text

CGFloat *floatingLabelYPadding UIFont *floatingLabelFont UIColor *floatingLabelTextColor UIColor *floatingLabelActiveColor BOOL animateEvenIfNotFirstResponder JVFloatLabeledOptions

Slide 108

Slide 108 text

CGFloat *floatingLabelYPadding UIFont *floatingLabelFont UIColor *floatingLabelTextColor UIColor *floatingLabelActiveColor BOOL animateEvenIfNotFirstResponder JVFloatLabeledOptions UITextField
 (JVFloatLabeledTextField) JVFloatLabeledOptions *options

Slide 109

Slide 109 text

extension UITextField { var options: FloatLabelOptions { get { if let options = objc_getAssociatedObject( self, &OptionsKey) as? FloatLabelOptions { return options } else { return FloatLabelOptions() } } set { // ... } } }

Slide 110

Slide 110 text

extension UITextField { var options: FloatLabelOptions { get { if let options = objc_getAssociatedObject( self, &OptionsKey) as? FloatLabelOptions { return options } else { return FloatLabelOptions() } } set { // ... } } }

Slide 111

Slide 111 text

extension UITextField { var options: FloatLabelOptions { get { if let options = objc_getAssociatedObject( self, &OptionsKey) as? FloatLabelOptions { return options } else { return FloatLabelOptions() } } set { // ... } } }

Slide 112

Slide 112 text

extension UITextField { var options: FloatLabelOptions { get { if let options = objc_getAssociatedObject( self, &OptionsKey) as? FloatLabelOptions { return options } else { return FloatLabelOptions() } } set { // ... } } }

Slide 113

Slide 113 text

@objc class FloatLabelOptions { let yPadding: CGFloat let font: UIFont let textColor: UIColor // ... }

Slide 114

Slide 114 text

@objc class FloatLabelOptions { let yPadding: CGFloat let font: UIFont let textColor: UIColor // ... }

Slide 115

Slide 115 text

#

Slide 116

Slide 116 text

compose multiple categories

Slide 117

Slide 117 text

runtime sorcery

Slide 118

Slide 118 text

No content

Slide 119

Slide 119 text

No content

Slide 120

Slide 120 text

let options = MDCSwipeOptions() options.threshold = 130 options.onPan = { state in switch state.direction { case .Left: self.bookmarkView.alpha = 0 self.dontBookmarkView.alpha = state.thresholdRatio case .Right: self.bookmarkView.alpha = state.thresholdRatio self.dontBookmarkView.alpha = 0 } } webView.mdc_swipeToChooseSetup(options)

Slide 121

Slide 121 text

let options = MDCSwipeOptions() options.threshold = 130 options.onPan = { state in switch state.direction { case .Left: self.bookmarkView.alpha = 0 self.dontBookmarkView.alpha = state.thresholdRatio case .Right: self.bookmarkView.alpha = state.thresholdRatio self.dontBookmarkView.alpha = 0 } } webView.mdc_swipeToChooseSetup(options)

Slide 122

Slide 122 text

let options = MDCSwipeOptions() options.threshold = 130 options.onPan = { state in switch state.direction { case .Left: self.bookmarkView.alpha = 0 self.dontBookmarkView.alpha = state.thresholdRatio case .Right: self.bookmarkView.alpha = state.thresholdRatio self.dontBookmarkView.alpha = 0 } } webView.mdc_swipeToChooseSetup(options)

Slide 123

Slide 123 text

let options = MDCSwipeOptions() options.threshold = 130 options.onPan = { state in switch state.direction { case .Left: self.bookmarkView.alpha = 0 self.dontBookmarkView.alpha = state.thresholdRatio case .Right: self.bookmarkView.alpha = state.thresholdRatio self.dontBookmarkView.alpha = 0 } } webView.mdc_swipeToChooseSetup(options)

Slide 124

Slide 124 text

let options = MDCSwipeOptions() options.threshold = 130 options.onPan = { state in switch state.direction { case .Left: self.bookmarkView.alpha = 0 self.dontBookmarkView.alpha = state.thresholdRatio case .Right: self.bookmarkView.alpha = state.thresholdRatio self.dontBookmarkView.alpha = 0 } } webView.mdc_swipeToChooseSetup(options)

Slide 125

Slide 125 text

let options = MDCSwipeOptions() options.threshold = 130 options.onPan = { state in switch state.direction { case .Left: self.bookmarkView.alpha = 0 self.dontBookmarkView.alpha = state.thresholdRatio case .Right: self.bookmarkView.alpha = state.thresholdRatio self.dontBookmarkView.alpha = 0 } } webView.mdc_swipeToChooseSetup(options)

Slide 126

Slide 126 text

let options = MDCSwipeOptions() options.threshold = 130 options.onPan = { state in switch state.direction { case .Left: self.bookmarkView.alpha = 0 self.dontBookmarkView.alpha = state.thresholdRatio case .Right: self.bookmarkView.alpha = state.thresholdRatio self.dontBookmarkView.alpha = 0 } } webView.mdc_swipeToChooseSetup(options)

Slide 127

Slide 127 text

No content

Slide 128

Slide 128 text

No content

Slide 129

Slide 129 text

No content

Slide 130

Slide 130 text

let options = MDCSwipeOptions() options.threshold = 130 options.onPan = { state in switch state.direction { case .Left: self.bookmarkView.alpha = 0 self.dontBookmarkView.alpha = state.thresholdRatio case .Right: self.bookmarkView.alpha = state.thresholdRatio self.dontBookmarkView.alpha = 0 } } webView.mdc_swipeToChooseSetup(options)

Slide 131

Slide 131 text

let options = MDCSwipeOptions() options.threshold = 130 options.onPan = { state in switch state.direction { case .Left: self.bookmarkView.alpha = 0 self.dontBookmarkView.alpha = state.thresholdRatio case .Right: self.bookmarkView.alpha = state.thresholdRatio self.dontBookmarkView.alpha = 0 } } webView.mdc_swipeToChooseSetup(options)

Slide 132

Slide 132 text

parameter objects

Slide 133

Slide 133 text

public struct ButtonCallbackParameters { let buttonIndex: Int
 let buttonTitle: String
 let totalButtonCount: Int } public typealias ButtonCallback = (parameters: ButtonCallbackParameters) -> ()

Slide 134

Slide 134 text

public struct ButtonCallbackParameters { let buttonIndex: Int
 let buttonTitle: String
 let totalButtonCount: Int } public typealias ButtonCallback = (parameters: ButtonCallbackParameters) -> () @availability(*, deprecated=2.0)

Slide 135

Slide 135 text

extensions vs. subclasses

Slide 136

Slide 136 text

extension UITextField { var options: FloatLabelOptions { get { // ... } set { // ... } } }

Slide 137

Slide 137 text

configuration objects

Slide 138

Slide 138 text

let options = MDCSwipeOptions() options.threshold = 130 options.onPan = { state in // ... } webView.mdc_swipeToChooseSetup(options)

Slide 139

Slide 139 text

prefer immutability

Slide 140

Slide 140 text

let options = MDCSwipeOptions() options.threshold = 130 options.onPan = { state in // ... } webView.mdc_swipeToChooseSetup(options)

Slide 141

Slide 141 text

- github.com/Quick/Quick
 - github.com/modocache/MDCSwipeToChoose 
 @modocache