tgios 0.0.37 → 0.0.38
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 +8 -8
- data/lib/tgios/beacon_manager.rb +116 -29
- data/lib/tgios/image_loader.rb +1 -1
- data/lib/tgios/photo_controller.rb +5 -10
- data/lib/tgios/scan_qr_controller.rb +36 -2
- data/lib/tgios/search_controller.rb +11 -1
- data/lib/tgios/table_section_list_binding.rb +40 -2
- data/lib/tgios/ui_collection_view_binding.rb +12 -0
- data/lib/tgios/ui_table_view_list_binding.rb +38 -13
- data/lib/tgios/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTIzZDUyZTdiNGY4ZGQwODBjNTI2ZDk2ZTkyN2NmZTNhNGEzNzI5ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzRlYWViYjJlYjBlYzk4YzBjY2M1YzAzMTgyOGQ3OGM2ODkwMTEzMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDZhMDk5Mjk0OTIxOGNlNDYzMzJmM2JiNzRmNDY3ZTU1OTE1NGYyNTUwMGMy
|
10
|
+
NTFmN2RlNTg4ZDllZjMzYmFiZmQyNmI4ZGVmMWNlZDVhNDZjNGYzYjRkZDE3
|
11
|
+
NTQzYjNjNWFmMzVhNzk3N2RlODJiMjBlOTQ3MmFlNzc4NTU1ZGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2U3MzU2M2FhYzllMjUzYThmMzYxNjM0NjU5YjJlM2JhMzEzOGVkYjkxMWMy
|
14
|
+
N2I3ZDRkNzJkYjZlMDgwNTlhZTczOGVjY2ZiYzMxZGExNzE1Y2NkMjk1NDhi
|
15
|
+
MmQwZjliYTNiNGY2ZTNiZTY2ODM1NDUxYjJiOWFiZTNhZDNjY2Q=
|
data/lib/tgios/beacon_manager.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
module Tgios
|
7
7
|
class FakeBeacon
|
8
|
-
attr_accessor :proximityUUID, :major, :minor
|
8
|
+
attr_accessor :proximityUUID, :major, :minor, :accuracy, :proximity, :rssi
|
9
9
|
|
10
10
|
def initialize(attributes)
|
11
11
|
attributes.each do |k, v|
|
@@ -17,8 +17,10 @@ module Tgios
|
|
17
17
|
|
18
18
|
class BeaconManager < BindingBase
|
19
19
|
attr_accessor :range_method, :range_limit, :tolerance, :current_beacon, :background
|
20
|
+
ALGORITHMS = [:continue, :timeout]
|
20
21
|
|
21
22
|
BeaconFoundKey = 'Tgios::BeaconManager::BeaconFound'
|
23
|
+
BeaconsFoundKey = 'Tgios::BeaconManager::BeaconsFound'
|
22
24
|
EnterRegionKey = 'Tgios::BeaconManager::EnterRegion'
|
23
25
|
ExitRegionKey = 'Tgios::BeaconManager::ExitRegion'
|
24
26
|
|
@@ -30,17 +32,36 @@ module Tgios
|
|
30
32
|
@default
|
31
33
|
end
|
32
34
|
|
33
|
-
|
35
|
+
#############################################
|
36
|
+
# range_method: :rssi or :accuracy
|
37
|
+
# range_limit: around -70 for :rssi / around 1.5 (meters) for :accuracy
|
38
|
+
# background: range beacons when device is in background
|
39
|
+
# algorithm: :continue or :timeout
|
40
|
+
# tolerance: for algorithm continue: number of times a beacon is ranged continuously required to trigger beacon changed event, for algorithm timeout: time in seconds for a beacon marked as changed
|
41
|
+
#############################################
|
42
|
+
|
43
|
+
def initialize(options)
|
34
44
|
@events = {}
|
35
45
|
@previous_beacons = []
|
36
|
-
@
|
37
|
-
@
|
38
|
-
|
39
|
-
|
40
|
-
@
|
41
|
-
|
42
|
-
|
43
|
-
@
|
46
|
+
@beacons_last_seen_at = {}
|
47
|
+
@background = options[:background]
|
48
|
+
|
49
|
+
self.algorithm = (options[:algorithm] || :continue)
|
50
|
+
@tolerance = (options[:tolerance] || 5)
|
51
|
+
|
52
|
+
@uuid = NSUUID.alloc.initWithUUIDString(options[:uuid])
|
53
|
+
@major = options[:major]
|
54
|
+
@minor = options[:minor]
|
55
|
+
@range_method = (options[:range_method] || :rssi)
|
56
|
+
@range_limit = (options[:range_limit] || -70)
|
57
|
+
|
58
|
+
@region = if @major && @minor
|
59
|
+
CLBeaconRegion.alloc.initWithProximityUUID(@uuid, major: @major, minor: @minor, identifier: identifier)
|
60
|
+
elsif @major
|
61
|
+
CLBeaconRegion.alloc.initWithProximityUUID(@uuid, major: @major, identifier: identifier)
|
62
|
+
else
|
63
|
+
CLBeaconRegion.alloc.initWithProximityUUID(@uuid, identifier: identifier)
|
64
|
+
end
|
44
65
|
@region.notifyOnEntry = true
|
45
66
|
@region.notifyOnExit = true
|
46
67
|
@region.notifyEntryStateOnDisplay = true
|
@@ -49,6 +70,11 @@ module Tgios
|
|
49
70
|
|
50
71
|
UIApplicationWillEnterForegroundNotification.add_observer(self, 'on_enter_foreground:')
|
51
72
|
UIApplicationDidEnterBackgroundNotification.add_observer(self, 'on_enter_background:')
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
def identifier
|
77
|
+
[@uuid.UUIDString, @major, @minor].join('/')
|
52
78
|
end
|
53
79
|
|
54
80
|
def on(event_key,&block)
|
@@ -56,28 +82,35 @@ module Tgios
|
|
56
82
|
self
|
57
83
|
end
|
58
84
|
|
85
|
+
def algorithm=(val)
|
86
|
+
alg = val.to_s.to_sym
|
87
|
+
return unless alg.present?
|
88
|
+
if @algorithm != alg
|
89
|
+
@previous_beacons.clear
|
90
|
+
end
|
91
|
+
raise ArgumentError.new("Algorithm not found, valid algorithm are: [#{ALGORITHMS.join(', ')}]") unless ALGORITHMS.include?(alg)
|
92
|
+
|
93
|
+
@algorithm = alg
|
94
|
+
end
|
95
|
+
|
59
96
|
def locationManager(manager, didDetermineState: state, forRegion: region)
|
60
97
|
NSLog "didDetermineState #{state}"
|
61
98
|
if state == CLRegionStateInside
|
62
99
|
manager.startRangingBeaconsInRegion(region)
|
100
|
+
did_enter_region(region)
|
101
|
+
elsif state == CLRegionStateOutside
|
102
|
+
did_exit_region(region)
|
63
103
|
end
|
64
104
|
end
|
65
105
|
|
66
106
|
def locationManager(manager, didEnterRegion: region)
|
67
107
|
NSLog 'didEnterRegion'
|
68
|
-
|
69
|
-
manager.startRangingBeaconsInRegion(region)
|
70
|
-
end
|
108
|
+
did_enter_region(region)
|
71
109
|
end
|
72
110
|
|
73
111
|
def locationManager(manager, didExitRegion: region)
|
74
112
|
NSLog 'didExitRegion'
|
75
|
-
|
76
|
-
manager.stopRangingBeaconsInRegion(region)
|
77
|
-
if has_event(:exit_region)
|
78
|
-
@events[:exit_region].call(region)
|
79
|
-
end
|
80
|
-
end
|
113
|
+
did_exit_region(region)
|
81
114
|
end
|
82
115
|
|
83
116
|
def locationManager(manager, didRangeBeacons: beacons, inRegion: region)
|
@@ -105,6 +138,11 @@ module Tgios
|
|
105
138
|
end
|
106
139
|
|
107
140
|
BeaconFoundKey.post_notification(self, {region: region, beacon: @current_beacon})
|
141
|
+
BeaconsFoundKey.post_notification(self, {region: region, beacon: @current_beacon, beacons_in_range: beacons_in_range, any_beacons: known_beacons + unknown_beacons})
|
142
|
+
end
|
143
|
+
|
144
|
+
def locationManager(manager, rangingBeaconsDidFailForRegion: region, withError: error)
|
145
|
+
@events[:ranging_failed].call(region, error) if @events[:range_failed]
|
108
146
|
end
|
109
147
|
|
110
148
|
def location_manager
|
@@ -159,22 +197,67 @@ module Tgios
|
|
159
197
|
stop_monitor unless @background
|
160
198
|
end
|
161
199
|
|
200
|
+
def did_enter_region(region)
|
201
|
+
if region.isKindOfClass(CLBeaconRegion)
|
202
|
+
location_manager.startRangingBeaconsInRegion(region)
|
203
|
+
if has_event(:enter_region)
|
204
|
+
@events[:enter_region].call(region)
|
205
|
+
end
|
206
|
+
EnterRegionKey.post_notification(self, {region: region})
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def did_exit_region(region)
|
211
|
+
if region.isKindOfClass(CLBeaconRegion)
|
212
|
+
location_manager.stopRangingBeaconsInRegion(region)
|
213
|
+
if has_event(:exit_region)
|
214
|
+
@events[:exit_region].call(region)
|
215
|
+
end
|
216
|
+
ExitRegionKey.post_notification(self, {region: region})
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
162
220
|
def has_event(event)
|
163
221
|
@events.has_key?(event)
|
164
222
|
end
|
165
223
|
|
166
224
|
def push_beacon(beacon)
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
225
|
+
case @algorithm
|
226
|
+
when :continue
|
227
|
+
if beacon_eqs(beacon, @current_beacon)
|
228
|
+
@current_beacon = beacon
|
229
|
+
else
|
230
|
+
if @previous_beacons.find { |b| !beacon_eqs(beacon, b) }.blank? # all previous beacons is the new beacon
|
231
|
+
@current_beacon = beacon
|
232
|
+
else
|
233
|
+
@current_beacon = nil if @previous_beacons.find{ |b| beacon_eqs(@current_beacon, b)}.blank? # all previous beacons is not the current beacon
|
234
|
+
end
|
235
|
+
end
|
236
|
+
@previous_beacons << beacon
|
237
|
+
@previous_beacons.delete_at(0) if @previous_beacons.length > @tolerance
|
238
|
+
|
239
|
+
when :timeout
|
240
|
+
time_now = Time.now
|
241
|
+
beacon_hash = {beacon: beacon, time: time_now}
|
242
|
+
@beacons_last_seen_at[self.class.beacon_key(beacon)] = beacon_hash
|
243
|
+
|
244
|
+
while @previous_beacons.present? && time_now - @previous_beacons.first[:time] > @tolerance do
|
245
|
+
@previous_beacons.delete_at(0)
|
246
|
+
end
|
247
|
+
@previous_beacons << beacon_hash
|
248
|
+
|
249
|
+
current_beacon_hash = @beacons_last_seen_at[self.class.beacon_key(@current_beacon)]
|
250
|
+
if current_beacon_hash
|
251
|
+
|
252
|
+
end
|
253
|
+
if !current_beacon_hash || time_now - current_beacon_hash[:time] < @tolerance
|
254
|
+
# current beacon not change
|
255
|
+
else
|
256
|
+
count_hash = @previous_beacons.each_with_object(Hash.new(0)) {|e, h| h[self.class.beacon_key(e[:beacon])] += @tolerance - (time_now - e[:time])} # beacon has more weighting if time is later
|
257
|
+
max_beacon_key = count_hash.max_by(&:last).first
|
258
|
+
@current_beacon = @beacons_last_seen_at[max_beacon_key][:beacon]
|
259
|
+
end
|
175
260
|
end
|
176
|
-
@previous_beacons << beacon
|
177
|
-
@previous_beacons.delete_at(0) if @previous_beacons.length > @tolerance
|
178
261
|
end
|
179
262
|
|
180
263
|
def beacon_eqs(beacon1, beacon2)
|
@@ -186,6 +269,10 @@ module Tgios
|
|
186
269
|
beacon1.minor == beacon2.minor && beacon1.major == beacon2.major && beacon1.proximityUUID == beacon2.proximityUUID
|
187
270
|
end
|
188
271
|
|
272
|
+
def self.beacon_key(beacon)
|
273
|
+
[beacon.try(:proximityUUIDbeacon), beacon.try(:major), beacon.try(:minor)].join('/')
|
274
|
+
end
|
275
|
+
|
189
276
|
def new_fake_beacon(options)
|
190
277
|
FakeBeacon.new({uuid: @uuid}.merge(options))
|
191
278
|
end
|
data/lib/tgios/image_loader.rb
CHANGED
@@ -1,20 +1,17 @@
|
|
1
1
|
module Tgios
|
2
2
|
class PhotoController < ExtendedUIViewController
|
3
|
-
include LoadingIndicator
|
4
3
|
attr_accessor :url
|
5
4
|
|
6
5
|
def viewDidLoad
|
7
6
|
super
|
8
7
|
self.view.backgroundColor = :black.uicolor
|
9
8
|
|
10
|
-
|
9
|
+
@load_view = LoadingView.add_loading_view_to(self.view)
|
11
10
|
unless @url.nil?
|
12
|
-
start_loading
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
if success
|
17
|
-
ap 'image loaded'
|
11
|
+
@load_view.start_loading
|
12
|
+
ImageLoader.load_url(@url) do |image, success|
|
13
|
+
@load_view.stop_loading
|
14
|
+
if success && self.view
|
18
15
|
# TODO: use motion layout or other way to handle frame size (or allow full screen)
|
19
16
|
small_frame = self.view.bounds
|
20
17
|
small_frame.size.height -= 20 + 44 if small_frame == UIScreen.mainScreen.bounds
|
@@ -22,9 +19,7 @@ module Tgios
|
|
22
19
|
scroll_view = PhotoScrollView.alloc.initWithFrame(small_frame, image: image)
|
23
20
|
self.view.addSubview(scroll_view)
|
24
21
|
end
|
25
|
-
image_loader.prepareForRelease
|
26
22
|
end
|
27
|
-
image_loader.load
|
28
23
|
|
29
24
|
end
|
30
25
|
end
|
@@ -7,14 +7,38 @@ module Tgios
|
|
7
7
|
self.view.backgroundColor = :dark_gray.uicolor
|
8
8
|
@load_view = Tgios::LoadingView.add_loading_view_to(self.view)
|
9
9
|
@load_view.start_loading
|
10
|
-
if
|
10
|
+
if NSProcessInfo.processInfo.environment[:IPHONE_SIMULATOR_DEVICE].present?
|
11
11
|
self.performSelector('fake_scan', withObject: nil, afterDelay: 3)
|
12
12
|
else
|
13
|
-
|
13
|
+
check_permission
|
14
|
+
# self.performSelector('startScanning', withObject: nil, afterDelay: 0.5)
|
14
15
|
end
|
15
16
|
|
16
17
|
end
|
17
18
|
|
19
|
+
def check_permission
|
20
|
+
status = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo)
|
21
|
+
if status == AVAuthorizationStatusAuthorized
|
22
|
+
self.performSelector('startScanning', withObject: nil, afterDelay: 0.5)
|
23
|
+
elsif status == AVAuthorizationStatusNotDetermined
|
24
|
+
Dispatch::Queue.new('ScanQrController').async do
|
25
|
+
AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo, completionHandler: ->(granted) {
|
26
|
+
if granted
|
27
|
+
Dispatch::Queue.main.async do
|
28
|
+
startScanning
|
29
|
+
end
|
30
|
+
else
|
31
|
+
Dispatch::Queue.main.async do
|
32
|
+
@events[:permission_denied].call if @events[:permission_denied]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
})
|
36
|
+
end
|
37
|
+
else
|
38
|
+
@events[:permission_denied].call if @events[:permission_denied]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
18
42
|
def startScanning
|
19
43
|
@load_view.stop_loading
|
20
44
|
setupCapture
|
@@ -27,6 +51,16 @@ module Tgios
|
|
27
51
|
@session.sessionPreset = AVCaptureSessionPresetHigh
|
28
52
|
|
29
53
|
@device = AVCaptureDevice.defaultDeviceWithMediaType AVMediaTypeVideo
|
54
|
+
if @device.lockForConfiguration(nil)
|
55
|
+
if @device.isFocusModeSupported(AVCaptureFocusModeContinuousAutoFocus)
|
56
|
+
@device.focusMode = AVCaptureFocusModeContinuousAutoFocus
|
57
|
+
end
|
58
|
+
if @device.isAutoFocusRangeRestrictionSupported
|
59
|
+
@device.autoFocusRangeRestriction = AVCaptureAutoFocusRangeRestrictionNear
|
60
|
+
end
|
61
|
+
@device.unlockForConfiguration
|
62
|
+
end
|
63
|
+
|
30
64
|
@error = Pointer.new('@')
|
31
65
|
@input = AVCaptureDeviceInput.deviceInputWithDevice @device, error: @error
|
32
66
|
|
@@ -35,7 +35,7 @@ module Tgios
|
|
35
35
|
@search_bar.sizeToFit
|
36
36
|
@search_bar.delegate=self
|
37
37
|
@search_result_table.tableHeaderView=@search_bar
|
38
|
-
@search_bar.becomeFirstResponder unless @hide_keyboard
|
38
|
+
@search_bar.performSelector('becomeFirstResponder', withObject: nil, afterDelay: 0.0) unless @hide_keyboard
|
39
39
|
@events[:after_layout].call(@search_bar, @search_result_table) unless @events[:after_layout].nil?
|
40
40
|
|
41
41
|
end
|
@@ -64,6 +64,16 @@ module Tgios
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
def viewWillAppear(animated)
|
68
|
+
super
|
69
|
+
@search_result_table_binding.listen_to_keyboard
|
70
|
+
end
|
71
|
+
|
72
|
+
def viewWillDisappear(animated)
|
73
|
+
@search_result_table_binding.stop_listen_to_keyboard
|
74
|
+
super
|
75
|
+
end
|
76
|
+
|
67
77
|
def init
|
68
78
|
super
|
69
79
|
@events={}
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module Tgios
|
2
2
|
class TableSectionListBinding < BindingBase
|
3
|
-
Events = [:cell_identifier, :build_cell, :update_cell,
|
3
|
+
Events = [:cell_identifier, :build_cell, :update_cell, :update_accessory,
|
4
4
|
:get_section, :get_section_text, :get_section_footer_text, :get_rows, :get_row, :get_row_text, :get_row_detail_text,
|
5
|
-
:touch_row, :
|
5
|
+
:touch_row, :delete_row, :can_delete_row, :should_indent, :editing_style,
|
6
|
+
:cell_height, :section_header, :section_footer, :reach_bottom, :header_height, :footer_height
|
6
7
|
]
|
7
8
|
|
8
9
|
def initialize(table_view, list, options={})
|
@@ -137,6 +138,26 @@ module Tgios
|
|
137
138
|
end
|
138
139
|
end
|
139
140
|
|
141
|
+
def tableView(tableView, commitEditingStyle: editingStyle, forRowAtIndexPath: index_path)
|
142
|
+
if editingStyle == UITableViewCellEditingStyleDelete
|
143
|
+
if @events[:delete_row].present?
|
144
|
+
record = @events[:get_row].call(index_path)
|
145
|
+
@events[:delete_row].call(index_path, record) do |success|
|
146
|
+
tableView.deleteRowsAtIndexPaths([index_path], withRowAnimation: UITableViewRowAnimationFade) if success
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def tableView(tableView, canEditRowAtIndexPath:index_path)
|
153
|
+
if @events[:can_delete_row].present?
|
154
|
+
record = @events[:get_row].call(index_path)
|
155
|
+
@events[:can_delete_row].call(index_path, record)
|
156
|
+
else
|
157
|
+
@events[:delete_row].present?
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
140
161
|
def tableView(tableView, numberOfRowsInSection: section)
|
141
162
|
rows = @events[:get_rows].call(section)
|
142
163
|
rows.length
|
@@ -196,6 +217,23 @@ module Tgios
|
|
196
217
|
0
|
197
218
|
end
|
198
219
|
|
220
|
+
def tableView(tableView, shouldIndentWhileEditingRowAtIndexPath:index_path)
|
221
|
+
flag = if @events.has_key?(:should_indent)
|
222
|
+
record = @events[:get_row].call(index_path)
|
223
|
+
@events[:should_indent].call(index_path, record)
|
224
|
+
end
|
225
|
+
return flag unless flag.nil?
|
226
|
+
true
|
227
|
+
end
|
228
|
+
|
229
|
+
def tableView(tableView, editingStyleForRowAtIndexPath:index_path)
|
230
|
+
style = if @events.has_key?(:editing_style)
|
231
|
+
record = @events[:get_row].call(index_path)
|
232
|
+
@events[:editing_style].call(index_path, record)
|
233
|
+
end
|
234
|
+
return style unless style.nil?
|
235
|
+
UITableViewCellEditingStyleDelete
|
236
|
+
end
|
199
237
|
|
200
238
|
def tableView(tableView, willDisplayCell:cell, forRowAtIndexPath:index_path)
|
201
239
|
unless @events[:reach_bottom].nil? || index_path.section < @list.length - 1 || index_path.row < @events[:get_rows].call(index_path).length - 1
|
@@ -43,6 +43,18 @@ module Tgios
|
|
43
43
|
@events[:item_tapped].call(view_at(indexPath), indexPath.row) unless @events[:item_tapped].nil?
|
44
44
|
end
|
45
45
|
|
46
|
+
def collectionView(collectionView, layout:collectionViewLayout, sizeForItemAtIndexPath:indexPath)
|
47
|
+
size = if @events[:item_size].nil?
|
48
|
+
view_at(indexPath).try(:bounds).try(:size)
|
49
|
+
else
|
50
|
+
@events[:item_size].call(view_at(indexPath), indexPath)
|
51
|
+
end
|
52
|
+
unless size && size != CGSizeZero
|
53
|
+
size = collectionViewLayout.itemSize
|
54
|
+
end
|
55
|
+
size
|
56
|
+
end
|
57
|
+
|
46
58
|
def scrollViewDidEndDecelerating(scrollView)
|
47
59
|
page = (scrollView.contentOffset.x / scrollView.frame.size.width).round
|
48
60
|
if page != @current_page
|
@@ -12,6 +12,11 @@ module Tgios
|
|
12
12
|
@tableView.delegate=self
|
13
13
|
@display_field=display_field
|
14
14
|
set_list(list)
|
15
|
+
if @table_utility_binding.nil?
|
16
|
+
@table_utility_binding = UITableViewUtilityBinding.new.bind(@tableView)
|
17
|
+
else
|
18
|
+
@table_utility_binding.bind(@tableView)
|
19
|
+
end
|
15
20
|
@options=(options || {})
|
16
21
|
return self
|
17
22
|
end
|
@@ -44,7 +49,8 @@ module Tgios
|
|
44
49
|
end
|
45
50
|
|
46
51
|
def update_cell_text(record, cell, index_path)
|
47
|
-
|
52
|
+
text = record.is_a?(Hash) ? record[@display_field] : record.send(@display_field)
|
53
|
+
cell.textLabel.text=text.to_s
|
48
54
|
cell
|
49
55
|
end
|
50
56
|
|
@@ -85,21 +91,23 @@ module Tgios
|
|
85
91
|
end
|
86
92
|
|
87
93
|
def tableView(tableView, willDisplayCell:cell, forRowAtIndexPath:indexPath)
|
88
|
-
|
89
|
-
@
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
94
|
+
if indexPath.row >= @list.length - 1
|
95
|
+
unless @events[:load_more].nil? || !@total.nil? && @total <= @list.size || @loading
|
96
|
+
@loading = true
|
97
|
+
@events[:load_more].call(@page+1, indexPath) do |success, results, total|
|
98
|
+
if success && !@list.nil?
|
99
|
+
@total = total
|
100
|
+
@page += 1
|
101
|
+
@list.concat(results)
|
102
|
+
@tableView.reloadData
|
103
|
+
end
|
104
|
+
@loading = false
|
96
105
|
end
|
97
|
-
@loading = false
|
98
106
|
end
|
99
|
-
end
|
100
107
|
|
101
|
-
|
102
|
-
|
108
|
+
unless @events[:reach_bottom].nil?
|
109
|
+
@events[:reach_bottom].call(indexPath)
|
110
|
+
end
|
103
111
|
end
|
104
112
|
end
|
105
113
|
|
@@ -129,7 +137,24 @@ module Tgios
|
|
129
137
|
can_edit
|
130
138
|
end
|
131
139
|
|
140
|
+
def scrollViewDidScroll(scroll_view)
|
141
|
+
@events[:did_scroll].call(scroll_view) if @events[:did_scroll]
|
142
|
+
end
|
143
|
+
|
144
|
+
def scrollViewDidEndDragging(scroll_view, willDecelerate:decelerate)
|
145
|
+
@events[:did_end_scroll].call(scroll_view, decelerate) if @events[:did_end_scroll]
|
146
|
+
end
|
147
|
+
|
148
|
+
def listen_to_keyboard
|
149
|
+
@table_utility_binding.listen_to_keyboard
|
150
|
+
end
|
151
|
+
|
152
|
+
def stop_listen_to_keyboard
|
153
|
+
@table_utility_binding.stop_listen_to_keyboard
|
154
|
+
end
|
155
|
+
|
132
156
|
def onPrepareForRelease
|
157
|
+
@table_utility_binding.prepareForRelease
|
133
158
|
@events=nil
|
134
159
|
@list=nil
|
135
160
|
@display_field=nil
|
data/lib/tgios/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.38
|
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:
|
12
|
+
date: 2016-11-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sugarcube
|