11//
22// CustomizationViewController.swift
3- // Example
3+ // Example-iOS
44//
55// Created by Ben on 30/01/2018.
66// Copyright © 2018 bcylin.
2626
2727import UIKit
2828import QuickTableViewController
29- import Weakify
3029
3130private final class CustomCell : UITableViewCell { }
3231private final class CustomSwitchCell : SwitchCell { }
@@ -60,26 +59,26 @@ internal final class CustomizationViewController: QuickTableViewController {
6059 title: " SwitchRow \n <CustomSwitchCell> " ,
6160 switchValue: true ,
6261 customization: set ( label: " 0-0 " ) ,
63- action: weakify ( self , type ( of : self ) . log )
62+ action: showLog ( )
6463 ) ,
6564 CustomSwitchRow < SwitchCell > (
6665 title: " CustomSwitchRow \n <SwitchCell> " ,
6766 switchValue: false ,
6867 customization: set ( label: " 0-1 " ) ,
69- action: weakify ( self , type ( of : self ) . log )
68+ action: showLog ( )
7069 )
7170 ] ) ,
7271
7372 Section ( title: " Tap Action " , rows: [
7473 TapActionRow < CustomTapActionCell > (
7574 title: " TapActionRow \n <CustomTapActionCell> " ,
7675 customization: set ( label: " 1-0 " ) ,
77- action: weakify ( self , type ( of : self ) . log )
76+ action: showLog ( )
7877 ) ,
7978 CustomTapActionRow < TapActionCell > (
8079 title: " CustomTapActionRow \n <TapActionCell> " ,
8180 customization: set ( label: " 1-1 " ) ,
82- action: weakify ( self , type ( of : self ) . log )
81+ action: showLog ( )
8382 )
8483 ] ) ,
8584
@@ -88,24 +87,25 @@ internal final class CustomizationViewController: QuickTableViewController {
8887 title: " NavigationRow " ,
8988 subtitle: . none,
9089 customization: set ( label: " 2-0 " ) ,
91- action: weakify ( self , type ( of: self ) . log) ) ,
90+ action: showLog ( )
91+ ) ,
9292 NavigationRow < CustomCell > (
9393 title: " NavigationRow<CustomCell> " ,
9494 subtitle: . belowTitle( " .subtitle " ) ,
9595 customization: set ( label: " 2-1 " ) ,
96- action: weakify ( self , type ( of : self ) . log )
96+ action: showLog ( )
9797 ) ,
9898 CustomNavigationRow (
9999 title: " CustomNavigationRow " ,
100100 subtitle: . rightAligned( " .value1 " ) ,
101101 customization: set ( label: " 2-2 " ) ,
102- action: weakify ( self , type ( of : self ) . log )
102+ action: showLog ( )
103103 ) ,
104104 CustomNavigationRow < CustomCell > (
105105 title: " CustomNavigationRow<CustomCell> " ,
106106 subtitle: . leftAligned( " .value2 " ) ,
107107 customization: set ( label: " 2-3 " ) ,
108- action: weakify ( self , type ( of : self ) . log )
108+ action: showLog ( )
109109 )
110110 ] ) ,
111111
@@ -114,19 +114,19 @@ internal final class CustomizationViewController: QuickTableViewController {
114114 title: " OptionRow " ,
115115 isSelected: false ,
116116 customization: set ( label: " 3-0 " ) ,
117- action: weakify ( self , type ( of : self ) . log )
117+ action: showLog ( )
118118 ) ,
119119 CustomOptionRow (
120120 title: " CustomOptionRow " ,
121121 isSelected: false ,
122122 customization: set ( label: " 3-1 " ) ,
123- action: weakify ( self , type ( of : self ) . log )
123+ action: showLog ( )
124124 ) ,
125125 CustomOptionRow < CustomOptionCell > (
126126 title: " CustomOptionRow<CustomOptionCell> " ,
127127 isSelected: false ,
128128 customization: set ( label: " 3-2 " ) ,
129- action: weakify ( self , type ( of : self ) . log )
129+ action: showLog ( )
130130 )
131131 ] ) ,
132132
@@ -155,16 +155,19 @@ internal final class CustomizationViewController: QuickTableViewController {
155155 }
156156 }
157157
158- private func log( _ sender: Row ) {
159- if let option = sender as? OptionRowCompatible , !option. isSelected {
160- return
161- }
162-
163- let text = ( sender as! RowStyle ) . cellReuseIdentifier
164- debugging. rows = [ NavigationRow ( title: text, subtitle: . none) ]
165- print ( text)
166- DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.2 ) { [ weak self] in
167- self ? . tableView. reloadData ( )
158+ private func showLog( ) -> ( Row ) -> Void {
159+ return { [ weak self] in
160+ if let option = $0 as? OptionRowCompatible , !option. isSelected {
161+ return
162+ }
163+ let identifier = ( $0 as! RowStyle ) . cellReuseIdentifier
164+ self ? . debugging. rows = [
165+ NavigationRow ( title: identifier, subtitle: . none, customization: self ? . set ( label: " debug " ) )
166+ ]
167+ print ( identifier)
168+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.2 ) { [ weak self] in
169+ self ? . tableView. reloadData ( )
170+ }
168171 }
169172 }
170173
0 commit comments