tgios 0.0.35 → 0.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGNhNjk1M2E4OTdlMDEyYWJhNzYyNjkyN2NjYWM0NTllNzY2OTA5MQ==
4
+ YWM1ZDM1YjYwMTgwOTcwZTFkMzljYTJmMzc5YzY5MjA1ZjgyZDhjOQ==
5
5
  data.tar.gz: !binary |-
6
- ZmNlMGM0OGJhYzE3ZmYyMWViMjI3NGJiYmZjOTg1OTk5ZDAzMDdmYw==
6
+ OWE0MzBhNDhhZWNkZmVmZWQzY2JiZDNlMGM2MWQzMDk0YTA4NjlhYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTY3YzY3MWRkMjlkMmM5MzFmNGMzNGU2ODNiYmU3ODVlMTM5NDI3NDQ4MjVm
10
- ZjBiNjg2MGM2MTUzZDNmZjEyMWMyM2E4OWUzYjljMDI3N2RiZmFjOWE1YjQ3
11
- NzFjNmZlOTMxMGFmOTMzZmVkNzVlNjEzOGQ2ZmJlOWM2ODIxYjU=
9
+ MzkyYmRiNDU2YTYxMTFkNmM0OTFmOGRmNTA5NGZhNTZhMDE5NjY4MzM0NDRl
10
+ OTA1ZWMyMjRmYTk2YmE1ZWEzNzA2NDJkNmM0MDNlZWE0YTZkODIxYWEyN2Rh
11
+ NGNjNjg2MTNjOGQ0NmMyZDZjYTA2YzYyNDdkY2FiMmRmN2U5NDU=
12
12
  data.tar.gz: !binary |-
13
- YTFmMDFjYjUxY2M1NjM2YTEyMDI0ODQwZDA3MWY4OTUxNzFhMjgzZjFkOTlm
14
- N2E5NWMyNzY0MWQ1Mzk4Y2YyYWNhMTFjZTU1YmVhOGMzNWMyNzA0ZjhkZTM2
15
- OTk5N2FhMDNhYjhiZjFmYTU4Y2ZiMjQxNDQ5NTdiYmI2YjQyYTM=
13
+ MmVhZWVhODIxNGQ0OWUxMjc4NWZjZDU0ZWI5YTg4NTU2OTY5MTNlYjhmMWNj
14
+ NmUyYzhjNTM4MTFhYjE4NDEwNGMxOTlhOGRkNjQwY2E1ODU4YTdiYzY4ZGFi
15
+ ZmNiNjQ5YWJjNTFmYmE1ZjAwYWRjM2FhYWFhYTkyYzYwNjEyYjQ=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tgios (0.0.35)
4
+ tgios (0.0.36)
5
5
  awesome_print_motion
6
6
  motion-layout
7
7
  plastic_cup (>= 0.1.1)
@@ -0,0 +1,208 @@
1
+ module Tgios
2
+ class TableSectionListBinding < BindingBase
3
+ Events = [:cell_identifier, :build_cell, :update_cell,
4
+ :get_section, :get_section_text, :get_section_footer_text, :get_rows, :get_row, :get_row_text, :get_row_detail_text,
5
+ :touch_row, :cell_height, :section_header, :section_footer, :reach_bottom, :header_height, :footer_height
6
+ ]
7
+
8
+ def initialize(table_view, list, options={})
9
+ @table = WeakRef.new(table_view)
10
+ @table.dataSource = self
11
+ @table.delegate = self
12
+ @list = list
13
+
14
+ @options = (options || {})
15
+
16
+ @section_text_indicator = (@options.delete(:section_text_indicator) || :title)
17
+ @section_footer_text_indicator = (@options.delete(:section_footer_text_indicator) || :footer_title)
18
+ @rows_indicator = (@options.delete(:rows_indicator) || :rows)
19
+ @row_text_indicator = (@options.delete(:row_text_indicator) || :title)
20
+ @row_detail_indicator = (@options.delete(:row_detail_indicator) || :detail)
21
+
22
+
23
+ @lines = (@options.delete(:lines) || 1)
24
+ @lines = @lines == true ? 2 : @lines == false ? 1 : @lines
25
+ @show_row_text = (@options.delete(:show_row_text) || true)
26
+ @show_row_detail = (@options.delete(:show_row_detail) || false)
27
+
28
+
29
+ @events = {}
30
+ @events[:cell_identifier]=->(index_path, record) { 'CELL_IDENTIFIER' }.weak!
31
+ @events[:build_cell]=->(cell_identifier, index_path, record) { build_cell(cell_identifier) }.weak!
32
+ @events[:update_cell]=->(cell, index_path, record) { update_cell(cell, index_path, record)}.weak!
33
+ @events[:update_accessory]=->(cell, index_path, record) { update_accessory(cell, index_path, record)}.weak!
34
+
35
+ @events[:get_section]=->(index_path) { get_section(index_path) }.weak!
36
+ @events[:get_section_text]=->(index_path, record) { get_section_text(index_path, record) }.weak!
37
+ @events[:get_section_footer_text]=->(index_path, record) { get_section_footer_text(index_path, record) }.weak!
38
+ @events[:get_rows]=->(index_path) { get_rows(index_path) }.weak!
39
+ @events[:get_row]=->(index_path) { get_row(index_path) }.weak!
40
+ @events[:get_row_text]=->(index_path, record) { get_row_text(index_path, record) }.weak!
41
+ @events[:get_row_detail_text]=->(index_path, record) { get_row_detail_text(index_path, record) }.weak!
42
+
43
+ end
44
+
45
+ def onPrepareForRelease
46
+ @events = {}
47
+ end
48
+
49
+ def on(event_key,&block)
50
+ raise ArgumentError.new("Event not found, valid events are: [#{Events.join(', ')}]") unless Events.include?(event_key)
51
+ @events[event_key] = block.weak!
52
+ self
53
+ end
54
+
55
+ def reload(list=nil)
56
+ @list = list unless list.nil?
57
+ @table.reloadData
58
+ end
59
+
60
+ def get_section(index_path)
61
+ section_idx = index_path.respondsToSelector(:section) ? index_path.section : index_path
62
+ @list[section_idx]
63
+ end
64
+
65
+ def get_section_text(index_path, record=nil)
66
+ record ||= @events[:get_section].call(index_path)
67
+ text = record.is_a?(Hash) ? record[@section_text_indicator] : record.send(@section_text_indicator)
68
+ text.to_s
69
+ end
70
+
71
+ def get_section_footer_text(index_path, record=nil)
72
+ record ||= @events[:get_section].call(index_path)
73
+ text = record.is_a?(Hash) ? record[@section_footer_text_indicator] : record.respond_to?(@section_footer_text_indicator) ? record.send(@section_footer_text_indicator) : nil
74
+ text.nil? ? nil : text.to_s
75
+ end
76
+
77
+ def get_rows(index_path)
78
+ record = @events[:get_section].call(index_path)
79
+ rows = record.is_a?(Hash) ? record[@rows_indicator] : record.send(@rows_indicator)
80
+ rows
81
+ end
82
+
83
+ def get_row(index_path)
84
+ rows = @events[:get_rows].call(index_path)
85
+ row_idx = index_path.respondsToSelector(:row) ? index_path.row : index_path
86
+ rows[row_idx]
87
+ end
88
+
89
+ def get_row_text(index_path, record=nil)
90
+ record ||= @events[:get_row].call(index_path)
91
+ text = record.is_a?(Hash) ? record[@row_text_indicator] : record.send(@row_text_indicator)
92
+ text.to_s
93
+ end
94
+
95
+ def get_row_detail_text(index_path, record=nil)
96
+ record ||= @events[:get_row].call(index_path)
97
+ text = record.is_a?(Hash) ? record[@row_detail_indicator] : record.send(@row_detail_indicator)
98
+ text.to_s
99
+ end
100
+
101
+ def build_cell(cell_identifier)
102
+ cell = UITableViewCell.value1(cell_identifier)
103
+ cell.textLabel.adjustsFontSizeToFitWidth = true
104
+ if @lines != 1
105
+ cell.textLabel.numberOfLines = 0
106
+ end
107
+ cell.clipsToBounds = true
108
+ cell
109
+ end
110
+
111
+ def update_cell(cell, index_path, record=nil)
112
+ record ||= @events[:get_row].call(index_path)
113
+ cell.textLabel.text = @events[:get_row_text].call(index_path, record) if @show_row_text
114
+ cell.detailTextLabel.text = @events[:get_row_detail_text].call(index_path, record) if @show_row_detail
115
+ cell.detailTextLabel
116
+ end
117
+
118
+ def update_accessory(cell, index_path, record)
119
+ cell.accessoryType = (@options[:accessory] || :none).uitablecellaccessory
120
+ cell.accessoryView = nil
121
+ end
122
+
123
+ def tableView(tableView, cellForRowAtIndexPath: index_path)
124
+ record = @events[:get_row].call(index_path)
125
+ cell_identifier = @events[:cell_identifier].call(index_path, record)
126
+ cell=tableView.dequeueReusableCellWithIdentifier(cell_identifier)
127
+ cell = @events[:build_cell].call(cell_identifier, index_path, record) if cell.nil?
128
+ @events[:update_cell].call(cell, index_path, record)
129
+ @events[:update_accessory].call(cell, index_path, record)
130
+ cell
131
+ end
132
+
133
+ def tableView(tableView, didSelectRowAtIndexPath:index_path)
134
+ if @events.has_key?(:touch_row)
135
+ record = @events[:get_row].call(index_path)
136
+ @events[:touch_row].call(record, index_path)
137
+ end
138
+ end
139
+
140
+ def tableView(tableView, numberOfRowsInSection: section)
141
+ rows = @events[:get_rows].call(section)
142
+ rows.length
143
+ end
144
+
145
+ def numberOfSectionsInTableView(tableView)
146
+ @list.length
147
+ end
148
+
149
+ def tableView(tableView, heightForRowAtIndexPath: index_path)
150
+ height = if @events.has_key?(:cell_height)
151
+ record = @events[:get_row].call(index_path)
152
+ @events[:cell_height].call(index_path, record)
153
+ end
154
+ return height if height.is_a?(Numeric)
155
+ return @options[:height] unless @options[:height].nil?
156
+ 26 + 19 * @lines
157
+ end
158
+
159
+ def tableView(tableView, titleForHeaderInSection:section)
160
+ record = @events[:get_section].call(section)
161
+ @events[:get_section_text].call(section, record)
162
+ end
163
+
164
+ def tableView(tableView, viewForHeaderInSection:section)
165
+ record = @events[:get_section].call(section)
166
+ @events[:section_header].call(section, record) if @events.has_key?(:section_header)
167
+ end
168
+
169
+ def tableView(tableView, heightForHeaderInSection:section)
170
+ height = if @events.has_key?(:header_height)
171
+ record = @events[:get_section].call(section)
172
+ @events[:header_height].call(section, record)
173
+ end
174
+ return height if height.is_a?(Numeric)
175
+ return @options[:header_height] unless @options[:header_height].nil?
176
+ 24
177
+ end
178
+
179
+ def tableView(tableView, titleForFooterInSection:section)
180
+ record = @events[:get_section].call(section)
181
+ @events[:get_section_footer_text].call(section, record)
182
+ end
183
+
184
+ def tableView(tableView, viewForFooterInSection:section)
185
+ record = @events[:get_section].call(section)
186
+ @events[:section_footer].call(section, record) if @events.has_key?(:section_footer)
187
+ end
188
+
189
+ def tableView(tableView, heightForFooterInSection:section)
190
+ height = if @events.has_key?(:footer_height)
191
+ record = @events[:get_section].call(section)
192
+ @events[:footer_height].call(section, record)
193
+ end
194
+ return height if height.is_a?(Numeric)
195
+ return @options[:footer_height] unless @options[:footer_height].nil?
196
+ 0
197
+ end
198
+
199
+
200
+ def tableView(tableView, willDisplayCell:cell, forRowAtIndexPath:index_path)
201
+ unless @events[:reach_bottom].nil? || index_path.section < @list.length - 1 || index_path.row < @events[:get_rows].call(index_path).length - 1
202
+ record = @events[:get_row].call(index_path)
203
+ @events[:reach_bottom].call(index_path, record)
204
+ end
205
+ end
206
+
207
+ end
208
+ end
@@ -54,6 +54,12 @@ module Tgios
54
54
  @picker_view.selectRow(idx, inComponent:0, animated: false)
55
55
  end
56
56
 
57
+ def reload(list=nil)
58
+ @list = WeakRef.new(list) if list
59
+ NSLog "#{@list.length}====="
60
+ @picker_view.reloadAllComponents
61
+ end
62
+
57
63
  def onPrepareForRelease
58
64
  @events=nil
59
65
  @picker_view.dataSource=nil
@@ -96,6 +96,10 @@ module Tgios
96
96
  @loading = false
97
97
  end
98
98
  end
99
+
100
+ unless @events[:reach_bottom].nil? || indexPath.row < @list.length - 1
101
+ @events[:reach_bottom].call(indexPath)
102
+ end
99
103
  end
100
104
 
101
105
  def tableView(tableView, commitEditingStyle: editingStyle, forRowAtIndexPath: index_path)
data/lib/tgios/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tgios
2
- VERSION = '0.0.35'
2
+ VERSION = '0.0.36'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tgios
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.35
4
+ version: 0.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - April Tsang
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-13 00:00:00.000000000 Z
12
+ date: 2015-06-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sugarcube
@@ -102,6 +102,7 @@ files:
102
102
  - lib/tgios/photo_upload.rb
103
103
  - lib/tgios/scan_qr_controller.rb
104
104
  - lib/tgios/search_controller.rb
105
+ - lib/tgios/table_section_list_binding.rb
105
106
  - lib/tgios/ui_button_binding.rb
106
107
  - lib/tgios/ui_collection_view_binding.rb
107
108
  - lib/tgios/ui_picker_view_list_binding.rb