tgios 0.0.34 → 0.0.35
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/Gemfile.lock +1 -1
- data/lib/tgios/beacon_manager.rb +22 -14
- data/lib/tgios/images_collection_view_binding.rb +5 -1
- data/lib/tgios/loading_indicator.rb +1 -1
- data/lib/tgios/photo_scroll_view.rb +37 -16
- data/lib/tgios/ui_collection_view_binding.rb +15 -2
- data/lib/tgios/ui_picker_view_list_binding.rb +16 -5
- data/lib/tgios/ui_text_field_binding.rb +2 -2
- 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
|
+
OGNhNjk1M2E4OTdlMDEyYWJhNzYyNjkyN2NjYWM0NTllNzY2OTA5MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmNlMGM0OGJhYzE3ZmYyMWViMjI3NGJiYmZjOTg1OTk5ZDAzMDdmYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTY3YzY3MWRkMjlkMmM5MzFmNGMzNGU2ODNiYmU3ODVlMTM5NDI3NDQ4MjVm
|
10
|
+
ZjBiNjg2MGM2MTUzZDNmZjEyMWMyM2E4OWUzYjljMDI3N2RiZmFjOWE1YjQ3
|
11
|
+
NzFjNmZlOTMxMGFmOTMzZmVkNzVlNjEzOGQ2ZmJlOWM2ODIxYjU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTFmMDFjYjUxY2M1NjM2YTEyMDI0ODQwZDA3MWY4OTUxNzFhMjgzZjFkOTlm
|
14
|
+
N2E5NWMyNzY0MWQ1Mzk4Y2YyYWNhMTFjZTU1YmVhOGMzNWMyNzA0ZjhkZTM2
|
15
|
+
OTk5N2FhMDNhYjhiZjFmYTU4Y2ZiMjQxNDQ5NTdiYmI2YjQyYTM=
|
data/Gemfile.lock
CHANGED
data/lib/tgios/beacon_manager.rb
CHANGED
@@ -11,7 +11,7 @@ module Tgios
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class BeaconManager < BindingBase
|
14
|
-
attr_accessor :
|
14
|
+
attr_accessor :range_method, :range_limit, :tolerance, :current_beacon, :background
|
15
15
|
|
16
16
|
BeaconFoundKey = 'Tgios::BeaconManager::BeaconFound'
|
17
17
|
EnterRegionKey = 'Tgios::BeaconManager::EnterRegion'
|
@@ -25,14 +25,15 @@ module Tgios
|
|
25
25
|
@default
|
26
26
|
end
|
27
27
|
|
28
|
-
def initialize(uuid,
|
28
|
+
def initialize(uuid, range_limit=-70, background=false, tolerance=5, range_method=:rssi)
|
29
29
|
@events = {}
|
30
30
|
@previous_beacons = []
|
31
31
|
@background = background
|
32
32
|
@tolerance = (tolerance || 5)
|
33
33
|
|
34
34
|
@uuid = NSUUID.alloc.initWithUUIDString(uuid)
|
35
|
-
@
|
35
|
+
@range_method = range_method
|
36
|
+
@range_limit = range_limit
|
36
37
|
|
37
38
|
@region = CLBeaconRegion.alloc.initWithProximityUUID(@uuid, identifier: uuid.split('-').first)
|
38
39
|
@region.notifyOnEntry = true
|
@@ -75,18 +76,25 @@ module Tgios
|
|
75
76
|
end
|
76
77
|
|
77
78
|
def locationManager(manager, didRangeBeacons: beacons, inRegion: region)
|
78
|
-
|
79
|
-
|
79
|
+
beacons = beacons.sort_by{|b| b.try(@range_method)}
|
80
|
+
beacons = beacons.reverse if @range_method == :rssi
|
81
|
+
known_beacons = beacons.select{|b| b.proximity != CLProximityUnknown}
|
82
|
+
unknown_beacons = beacons - known_beacons
|
83
|
+
beacon = nil
|
84
|
+
beacons_in_range = known_beacons.select{|b| @range_method == :accuracy ? b.try(@range_method) <= @range_limit : b.try(@range_method) >= @range_limit}
|
85
|
+
beacon = beacons_in_range.first if beacons_in_range.present?
|
86
|
+
|
87
|
+
NSLog("beacons_in_range: ")
|
88
|
+
beacons_in_range.each_with_index do |bir, i|
|
89
|
+
NSLog("##{i}: major: #{bir.major}, minor: #{bir.minor}, accuracy: #{bir.accuracy}, rssi: #{bir.rssi}")
|
80
90
|
end
|
91
|
+
push_beacon(beacon) # nil value will signify null beacon
|
81
92
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
beacon ||= known_beacons.last if known_beacons.length == 1 && known_beacons.last.rssi >= @rssi - 1
|
93
|
+
if has_event(:beacons_found)
|
94
|
+
# use known_beacons + unknown_beacons to make sure closest range comes to the top
|
95
|
+
@events[:beacons_found].call(beacons_in_range, known_beacons + unknown_beacons, @current_beacon)
|
86
96
|
end
|
87
97
|
|
88
|
-
push_beacon(beacon)
|
89
|
-
|
90
98
|
if has_event(:beacon_found)
|
91
99
|
@events[:beacon_found].call(@current_beacon)
|
92
100
|
end
|
@@ -107,8 +115,8 @@ module Tgios
|
|
107
115
|
def request_authorization(manager)
|
108
116
|
if manager.respond_to?(:requestAlwaysAuthorization)
|
109
117
|
status = CLLocationManager.authorizationStatus
|
110
|
-
if status
|
111
|
-
title = (status ==
|
118
|
+
if status != KCLAuthorizationStatusAuthorizedAlways
|
119
|
+
title = (status == KCLAuthorizationStatusDenied) ? "Location services are off" : "Background location is not enabled"
|
112
120
|
message = "To use background location you must turn on 'Always' in the Location Services Settings"
|
113
121
|
|
114
122
|
UIAlertView.alert(title, message: message)
|
@@ -189,4 +197,4 @@ module Tgios
|
|
189
197
|
super
|
190
198
|
end
|
191
199
|
end
|
192
|
-
end
|
200
|
+
end
|
@@ -29,8 +29,12 @@ module Tgios
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def list=(new_list)
|
32
|
+
set_list(new_list)
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_list(new_list, options={})
|
32
36
|
if new_list.is_a?(Array)
|
33
|
-
@image_views = self.class.new_image_views(new_list)
|
37
|
+
@image_views = self.class.new_image_views(new_list, options)
|
34
38
|
reload(@image_views)
|
35
39
|
end
|
36
40
|
end
|
@@ -16,7 +16,7 @@ module Tgios
|
|
16
16
|
@label = Base.style(UILabel.new,
|
17
17
|
frame: self.bounds,
|
18
18
|
font: lambda {UIFont.systemFontOfSize(22)},
|
19
|
-
textAlignment: :center.
|
19
|
+
textAlignment: :center.nstextalignment,
|
20
20
|
backgroundColor: :clear.uicolor,
|
21
21
|
textColor: :white.uicolor)
|
22
22
|
@label.sizeToFit
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Tgios
|
2
2
|
class PhotoScrollView < UIScrollView
|
3
|
-
attr_accessor :image
|
4
|
-
MAX_SCALE = 4.0
|
3
|
+
attr_accessor :image, :max_scale, :content_type, :min_content_type
|
5
4
|
|
6
5
|
def init
|
7
6
|
if super
|
@@ -11,6 +10,11 @@ module Tgios
|
|
11
10
|
self.decelerationRate = UIScrollViewDecelerationRateFast
|
12
11
|
self.delegate = self
|
13
12
|
self.backgroundColor = :clear.uicolor
|
13
|
+
@max_scale = 4.0
|
14
|
+
@content_type = @min_content_type = :horizontal # :horizontal, :vertical, :fit, :fill
|
15
|
+
|
16
|
+
@image_view = PlasticCup::Base.style(UIImageView.new, contentMode: UIViewContentModeScaleAspectFit)
|
17
|
+
self.addSubview(@image_view)
|
14
18
|
end
|
15
19
|
self
|
16
20
|
end
|
@@ -26,25 +30,25 @@ module Tgios
|
|
26
30
|
def image=(image)
|
27
31
|
super
|
28
32
|
if image.is_a?(UIImage)
|
29
|
-
frame = self.frame
|
30
|
-
page_rect = CGRectMake(0, 0, image.size.width, image.size.height)
|
31
33
|
|
32
|
-
|
33
|
-
fit_scale = frame.size.height / page_rect.size.height
|
34
|
-
fit_scale = img_scale if img_scale < fit_scale
|
34
|
+
fit_scale = get_scale(@content_type, image)
|
35
35
|
|
36
|
-
|
36
|
+
image_view_size = CGSizeMake(image.size.width * fit_scale, image.size.height * fit_scale)
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
#reset content
|
39
|
+
self.contentOffset = CGPointZero
|
40
|
+
self.zoomScale = 1.0
|
41
|
+
|
42
|
+
@image_view.image= image
|
43
|
+
@image_view.frame = [[0,0], [image_view_size.width, image_view_size.height]]
|
43
44
|
|
44
|
-
|
45
|
+
#center image
|
46
|
+
self.contentOffset = CGPointMake((image_view_size.width - frame.size.width)/2.0, (image_view_size.height - frame.size.height)/2.0)
|
47
|
+
|
48
|
+
self.zoomScale = 0.995
|
49
|
+
self.maximumZoomScale = @max_scale / fit_scale
|
50
|
+
self.minimumZoomScale = get_scale(@min_content_type, image) / fit_scale
|
45
51
|
|
46
|
-
self.maximumZoomScale = MAX_SCALE / img_scale
|
47
|
-
self.minimumZoomScale = fit_scale / img_scale
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
@@ -64,6 +68,23 @@ module Tgios
|
|
64
68
|
|
65
69
|
end
|
66
70
|
|
71
|
+
def get_scale(type, image)
|
72
|
+
horizontal_scale = frame.size.width / image.size.width
|
73
|
+
vertical_scale = frame.size.height / image.size.height
|
74
|
+
case type
|
75
|
+
when :horizontal
|
76
|
+
horizontal_scale
|
77
|
+
when :vertical
|
78
|
+
vertical_scale
|
79
|
+
when :fit
|
80
|
+
[horizontal_scale, vertical_scale].min
|
81
|
+
when :fill
|
82
|
+
[horizontal_scale, vertical_scale].max
|
83
|
+
else
|
84
|
+
horizontal_scale
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
67
88
|
def viewForZoomingInScrollView(scrollView)
|
68
89
|
@image_view
|
69
90
|
end
|
@@ -2,6 +2,8 @@ module Tgios
|
|
2
2
|
class UICollectionViewBinding < BindingBase
|
3
3
|
include PlasticCup
|
4
4
|
|
5
|
+
attr_accessor :current_page
|
6
|
+
|
5
7
|
def initialize(*args)
|
6
8
|
super
|
7
9
|
@events={}
|
@@ -43,12 +45,23 @@ module Tgios
|
|
43
45
|
|
44
46
|
def scrollViewDidEndDecelerating(scrollView)
|
45
47
|
page = (scrollView.contentOffset.x / scrollView.frame.size.width).round
|
46
|
-
if page != @
|
47
|
-
@
|
48
|
+
if page != @current_page
|
49
|
+
@current_page = page
|
48
50
|
@events[:page_changed].call(page) unless @events[:page_changed].nil?
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
54
|
+
def scrollViewDidScroll(scroll_view)
|
55
|
+
@events[:view_did_scroll].call(scroll_view) if @events[:view_did_scroll]
|
56
|
+
end
|
57
|
+
|
58
|
+
def go_to_page(page, animated=false)
|
59
|
+
frame = @collection_view.bounds
|
60
|
+
frame.origin.x = frame.size.width * page
|
61
|
+
@collection_view.scrollRectToVisible(frame, animated: animated)
|
62
|
+
@events[:page_changed].call(page) unless @events[:page_changed].nil?
|
63
|
+
end
|
64
|
+
|
52
65
|
def view_at(index_path)
|
53
66
|
@views[index_path.row]
|
54
67
|
end
|
@@ -8,10 +8,11 @@ module Tgios
|
|
8
8
|
@events[event_name]=block.weak!
|
9
9
|
end
|
10
10
|
|
11
|
-
def bind(picker_view,
|
11
|
+
def bind(picker_view, options={})
|
12
|
+
@options = options
|
12
13
|
@picker_view=WeakRef.new(picker_view)
|
13
|
-
@list=WeakRef.new(list)
|
14
|
-
@display_field=display_field
|
14
|
+
@list=WeakRef.new(options[:list])
|
15
|
+
@display_field=options[:display_field]
|
15
16
|
@picker_view.dataSource=self
|
16
17
|
@picker_view.delegate=self
|
17
18
|
end
|
@@ -26,14 +27,24 @@ module Tgios
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def pickerView(pickerView, titleForRow: row, forComponent: component)
|
29
|
-
|
30
|
-
|
30
|
+
get_display_text(row)
|
31
|
+
end
|
32
|
+
|
33
|
+
def pickerView(pickerView, attributedTitleForRow:row, forComponent:component)
|
34
|
+
if @options[:text_color]
|
35
|
+
NSAttributedString.alloc.initWithString(get_display_text(row), attributes:{NSForegroundColorAttributeName => @options[:text_color]})
|
36
|
+
end
|
31
37
|
end
|
32
38
|
|
33
39
|
def pickerView(pickerView, didSelectRow:row, inComponent:component)
|
34
40
|
@events[:row_selected].call(row, selected_record) unless @events[:row_selected].nil?
|
35
41
|
end
|
36
42
|
|
43
|
+
def get_display_text(row)
|
44
|
+
record = @list[row]
|
45
|
+
record.is_a?(Hash) ? record[@display_field] : record.send(@display_field)
|
46
|
+
end
|
47
|
+
|
37
48
|
def selected_record
|
38
49
|
@list[@picker_view.selectedRowInComponent(0)]
|
39
50
|
end
|
@@ -15,7 +15,7 @@ module Tgios
|
|
15
15
|
extends: :decimal_button_common,
|
16
16
|
frame: [[0, 163 + 44], [105, 54]],
|
17
17
|
highlighted_background_image: Tgios::CommonUIUtility.imageFromColor(UIColor.colorWithRed(0.324, green: 0.352, blue: 0.402, alpha: 1)),
|
18
|
-
titleColor: :
|
18
|
+
titleColor: :dark_gray.uicolor,
|
19
19
|
highlighted_title_color: :white.uicolor
|
20
20
|
}, :ios6) unless Base.get_style_sheet(:decimal_button)
|
21
21
|
|
@@ -210,7 +210,7 @@ module Tgios
|
|
210
210
|
textColor: :red.uicolor,
|
211
211
|
backgroundColor: :clear.uicolor,
|
212
212
|
font: 'GillSans-Bold'.uifont(25),
|
213
|
-
textAlignment: :center.
|
213
|
+
textAlignment: :center.nstextalignment,
|
214
214
|
text: '!',
|
215
215
|
tag: 888}
|
216
216
|
error_label = Base.style(UILabel.new, error_label_styles)
|
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.35
|
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: 2015-01-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sugarcube
|