tgios 0.0.11 → 0.0.12

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
- MzU2M2M5Y2I2NjI2NzQzZmRlMTEyMWFlOTE0MmRkNDRhZjdmOThjZg==
4
+ Yzg1YmIyZmExYmQyMDJmNDQ4NWNiOTRlYWU2YmQ0ZjZhZWViYWY5NQ==
5
5
  data.tar.gz: !binary |-
6
- ZGQzMDljMDBhNDMxOTZkY2UyNzM4OTJmNTE1ZDM2ZTFhOThiOGU3MQ==
6
+ Nzk4YTI2OTNlOWJiMmIyM2Y0MmU0MDdlOGQ2ODliMGEzM2M2NmMxOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDdkZjU2Y2E3YmFhMzViNGQ3Yzc5YzE4YmQ4NWI4ODE0YWE1OWJjOWQ0Nzdl
10
- MWU1OGJkNjkzMTNjNTgzMjk5MWRlZjA0NGY0ZDEyOTU1MjA2ZmJlMGU0M2Q2
11
- MjdkYTBkODY2N2UwZTAyNjllZDk1MDNkZWUzNGFiZWY1OGEyMGM=
9
+ ZDA0MDYzODc2MzI5ZGEyNWNiOTc3OGZhZDNhZGRkZmM0ODgzY2YwM2EyZDdh
10
+ ZjM3ZTdmYWM1MmQzMzY0YWJiMWI0MTk5Mzk4YTI3ZGMyNzQxM2JhN2RiYWUy
11
+ NGMyZDZhODRiMjdlYzM2NmY1MDlkMzlkYmI4YmQyZjY0ZWFmNTk=
12
12
  data.tar.gz: !binary |-
13
- ZjM3ZjE1YWU4NTk3MGJhMWI0ZTk0ODk4NDQ3NTZhZTcyYWQ0OWRiYWZlNjU4
14
- MzYxNzAzNTEyODEyMTgyYTgwODY1NTdhMGQyMTJhY2U4NjRmZTcwOWE3YjZh
15
- NzRjNzg0MzM3ZjE3ZWNhNTI0NzBjNDhiNDRjNjg2YjhlMjkwODc=
13
+ OGEwYmVkOGMyNjY3YjdjMGM3MzYwZGVhNzExNDFlM2MzM2Q2YTYwZDUyN2My
14
+ NzU3MGNjOWE5MTdiMmU0Y2I4MzE2N2EyMTViYmRmMThiNDJlMzcxZTE5NzAz
15
+ NmJjZjZhMTZmYzY1YzFhMmYxMTdhNGZkNzMzYzg1N2ZiYWJiOTM=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tgios (0.0.11)
4
+ tgios (0.0.12)
5
5
  awesome_print_motion
6
6
  motion-layout
7
7
  plastic_cup (>= 0.1.1)
@@ -26,5 +26,14 @@ module Tgios
26
26
  normalized_image
27
27
  end
28
28
  end
29
+
30
+ def self.add_full_subview(super_view, subview)
31
+ Motion::Layout.new do |l|
32
+ l.view super_view
33
+ l.subviews 'subview' => subview
34
+ l.vertical '|[subview]|'
35
+ l.horizontal '|[subview]|'
36
+ end
37
+ end
29
38
  end
30
39
  end
@@ -5,12 +5,7 @@ module Tgios
5
5
  def add_full_table_view_to(view, style=:grouped)
6
6
  style ||= :plain
7
7
  table = UITableView.send(style)
8
- Motion::Layout.new do |l|
9
- l.view view
10
- l.subviews 'table' => table
11
- l.vertical '|[table]|'
12
- l.horizontal '|[table]|'
13
- end
8
+ CommonUIUtility.add_full_subview(view, table)
14
9
  table
15
10
  end
16
11
 
@@ -1,47 +1,62 @@
1
1
  include PlasticCup
2
2
  module Tgios
3
- module LoadingIndicator
4
- def add_loading_indicator_to(view)
5
- Base.add_style_sheet(:loading_view, {
6
- backgroundColor: :black.uicolor,
7
- alpha: 0.5
8
- })
9
- @loading_view = Base.style(UIView.new, hidden: true)
10
- base_view = Base.style(UIView.new, :loading_view)
11
- @indicator = UIActivityIndicatorView.large
12
- [{super_view: view, subview: @loading_view}, {super_view: @loading_view, subview: base_view}, {super_view: @loading_view, subview: @indicator}].each do |hash|
3
+ class LoadingView < UIView
4
+ def initWithFrame(frame)
5
+ if super
6
+ self.hidden = true
7
+ base_view = Base.style(UIView.new, backgroundColor: :black.uicolor, alpha: 0.5)
8
+
9
+ @indicator = UIActivityIndicatorView.large
10
+ [{super_view: self, subview: base_view}, {super_view: self, subview: @indicator}].each do |hash|
11
+ CommonUIUtility.add_full_subview(hash[:super_view], hash[:subview])
12
+ end
13
+ @label = Base.style(UILabel.new,
14
+ frame: self.bounds,
15
+ font: lambda {UIFont.systemFontOfSize(22)},
16
+ textAlignment: :center.uialignment,
17
+ backgroundColor: :clear.uicolor,
18
+ textColor: :white.uicolor)
19
+ @label.sizeToFit
13
20
  Motion::Layout.new do |l|
14
- l.view hash[:super_view]
15
- l.subviews 'subview' => hash[:subview]
16
- l.vertical '|[subview]|'
17
- l.horizontal '|[subview]|'
21
+ l.view self
22
+ l.subviews 'label' => @label
23
+ l.vertical '[label]-290-|'
24
+ l.horizontal '|-20-[label]-20-|'
18
25
  end
19
26
  end
20
- @label = Base.style(UILabel.new,
21
- frame: view.bounds,
22
- font: lambda {UIFont.systemFontOfSize(22)},
23
- textAlignment: :center.uialignment,
24
- backgroundColor: :clear.uicolor,
25
- textColor: :white.uicolor)
26
- @label.sizeToFit
27
- Motion::Layout.new do |l|
28
- l.view @loading_view
29
- l.subviews 'label' => @label
30
- l.vertical '[label]-290-|'
31
- l.horizontal '|-20-[label]-20-|'
32
- end
27
+ self
28
+ end
29
+
30
+ def self.add_loading_view_to(view)
31
+ loading_view = LoadingView.alloc.initWithFrame(view.bounds)
32
+ CommonUIUtility.add_full_subview(view, loading_view)
33
+ loading_view
33
34
  end
34
35
 
35
36
  def start_loading(text='')
36
37
  @label.text = text
37
- self.view.endEditing(true)
38
- @loading_view.hidden = false
38
+ self.hidden = false
39
39
  @indicator.startAnimating
40
40
  end
41
41
 
42
42
  def stop_loading
43
- @loading_view.hidden = true
43
+ self.hidden = true
44
44
  @indicator.stopAnimating
45
45
  end
46
46
  end
47
+
48
+ module LoadingIndicator
49
+ def add_loading_indicator_to(view)
50
+ @loading_view = LoadingView.add_loading_view_to(view)
51
+ end
52
+
53
+ def start_loading(text='')
54
+ self.view.endEditing(true)
55
+ @loading_view.start_loading(text)
56
+ end
57
+
58
+ def stop_loading
59
+ @loading_view.stop_loading
60
+ end
61
+ end
47
62
  end
@@ -1,17 +1,31 @@
1
1
  module Tgios
2
2
  class PhotoScrollView < UIScrollView
3
+ attr_accessor :image
3
4
  MAX_SCALE = 4.0
4
5
 
6
+ def init
7
+ if super
8
+ self.showsVerticalScrollIndicator = false
9
+ self.showsHorizontalScrollIndicator = false
10
+ self.bouncesZoom = true
11
+ self.decelerationRate = UIScrollViewDecelerationRateFast
12
+ self.delegate = self
13
+ self.backgroundColor = :clear.uicolor
14
+ end
15
+ self
16
+ end
17
+
5
18
  def initWithFrame(frame, image: image)
6
- initWithFrame(frame)
7
- ap "init #{self.class.name}"
8
- self.showsVerticalScrollIndicator = false
9
- self.showsHorizontalScrollIndicator = false
10
- self.bouncesZoom = true
11
- self.decelerationRate = UIScrollViewDecelerationRateFast
12
- self.delegate = self
13
- self.backgroundColor = :clear.uicolor
19
+ init
20
+ self.frame = frame
21
+ self.image = image
14
22
 
23
+ self
24
+ end
25
+
26
+ def image=(image)
27
+ super
28
+ frame = self.frame
15
29
  page_rect = CGRectMake(0, 0, image.size.width, image.size.height)
16
30
 
17
31
  img_scale = frame.size.width / page_rect.size.width
@@ -30,21 +44,21 @@ module Tgios
30
44
 
31
45
  self.maximumZoomScale = MAX_SCALE / img_scale
32
46
  self.minimumZoomScale = fit_scale / img_scale
33
-
34
- self
35
47
  end
36
48
 
37
49
  def layoutSubviews
38
50
  super
51
+ unless @image_view.nil?
52
+ bsize = self.bounds.size
53
+ center_frame = @image_view.frame
39
54
 
40
- bsize = self.bounds.size
41
- center_frame = @image_view.frame
55
+ center_frame.origin.x = center_frame.size.width < bsize.width ? (bsize.width - center_frame.size.width) / 2.0 : 0
56
+ center_frame.origin.y = center_frame.size.height < bsize.height ? (bsize.height - center_frame.size.height) / 2.0 : 0
42
57
 
43
- center_frame.origin.x = center_frame.size.width < bsize.width ? (bsize.width - center_frame.size.width) / 2.0 : 0
44
- center_frame.origin.y = center_frame.size.height < bsize.height ? (bsize.height - center_frame.size.height) / 2.0 : 0
58
+ @image_view.frame = center_frame
59
+ @image_view.contentScaleFactor = 1.0
45
60
 
46
- @image_view.frame = center_frame
47
- @image_view.contentScaleFactor = 1.0
61
+ end
48
62
 
49
63
  end
50
64
 
data/lib/tgios/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tgios
2
- VERSION = '0.0.11'
2
+ VERSION = '0.0.12'
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.11
4
+ version: 0.0.12
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: 2014-02-21 00:00:00.000000000 Z
12
+ date: 2014-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sugarcube