sugarcube 1.3.5 → 1.3.6

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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sugarcube (1.3.5)
4
+ sugarcube (1.3.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -71,6 +71,27 @@ Installation
71
71
  # in terminal
72
72
  $ bundle install
73
73
 
74
+ Memory Management
75
+ =================
76
+
77
+ There are some very convenient helper methods around touches and gestures, but
78
+ they come with an unfortunate side effect. These helpers accept a block, but
79
+ that block retains a reference to the object it was created in, which is usually
80
+ a controller.
81
+
82
+ ```ruby
83
+ # ... somewhere in a controller
84
+ button.on :touch do
85
+ # handle touch event
86
+ self.do_something! # <= the block retains 'self' so that this handler will
87
+ # work, even if the controller is released.
88
+ end
89
+ ```
90
+
91
+ To fix this, you need to call `sugarcube_cleanup` when a controller is "going
92
+ away". Another option is to add/remove button/gesture callbacks when the view
93
+ appears, and remove them when it disappears.
94
+
74
95
  Packages
75
96
  ========
76
97
 
@@ -59,10 +59,6 @@ class UIView
59
59
  animation_options = curve | from_current
60
60
  end
61
61
 
62
-
63
-
64
-
65
-
66
62
  if duration == 0 && delay == 0
67
63
  animations.call
68
64
  after_adjusted.call(true) if after_adjusted
@@ -106,12 +102,12 @@ class UIView
106
102
 
107
103
  def show
108
104
  self.hidden = false
109
- self
105
+ return self
110
106
  end
111
107
 
112
108
  def hide
113
109
  self.hidden = true
114
- self
110
+ return self
115
111
  end
116
112
 
117
113
  # Same as UIView##animate, but acts on self
@@ -129,7 +125,7 @@ class UIView
129
125
  self.send("#{key}=", value)
130
126
  end
131
127
  end
132
- self
128
+ return self
133
129
  end
134
130
 
135
131
  # Changes the layer opacity.
@@ -207,7 +203,7 @@ class UIView
207
203
  position = SugarCube::CoreGraphics::Point(f.origin)
208
204
  to_position = CGPoint.new(position.x + delta.x, position.y + delta.y)
209
205
  move_to(to_position, options, more_options, &after)
210
- self
206
+ return self
211
207
  end
212
208
 
213
209
  def resize_to(size, options={}, more_options={}, &after)
@@ -278,21 +274,21 @@ class UIView
278
274
 
279
275
  case direction
280
276
  when :left
281
- size ||= self.bounds.size.width
277
+ size ||= self.frame.size.width
282
278
  delta_to([-size, 0], options, &after)
283
279
  when :right
284
- size ||= self.bounds.size.width
280
+ size ||= self.frame.size.width
285
281
  delta_to([size, 0], options, &after)
286
282
  when :up
287
- size ||= self.bounds.size.height
283
+ size ||= self.frame.size.height
288
284
  delta_to([0, -size], options, &after)
289
285
  when :down
290
- size ||= self.bounds.size.height
286
+ size ||= self.frame.size.height
291
287
  delta_to([0, size], options, &after)
292
288
  else
293
289
  raise "Unknown direction #{direction.inspect}"
294
290
  end
295
- self
291
+ return self
296
292
  end
297
293
 
298
294
  # Vibrates the target. You can trick this thing out to do other effects, like:
@@ -337,7 +333,7 @@ class UIView
337
333
  animation.values = [origin, left, right, origin]
338
334
  animation.keyTimes = [0, 0.25, 0.75, 1.0]
339
335
  self.layer.addAnimation(animation, forKey:'shake')
340
- self
336
+ return self
341
337
  end
342
338
 
343
339
  # this dummy method is needed to define the setDuration method
@@ -389,6 +385,38 @@ class UIView
389
385
  end
390
386
  end
391
387
 
388
+ # Moves the view on screen while slowly rotating it.
389
+ #
390
+ # Based on https://github.com/warrenm/AHAlertView/blob/master/AHAlertView/AHAlertView.m
391
+ def tumble_in(options={}, &after)
392
+ if options.is_a? Numeric
393
+ default_duration = options
394
+ options = {}
395
+ else
396
+ default_duration = 0.3
397
+ end
398
+
399
+ reset_transform = self.transform
400
+ reset_center = self.center
401
+
402
+ options[:duration] ||= default_duration
403
+ options[:options] ||= UIViewAnimationOptionCurveEaseOut
404
+ options[:after] = after
405
+
406
+ window = UIApplication.sharedApplication.windows[0]
407
+ top = self.convertPoint([0, 0], toView:nil).y
408
+ height = window.frame.size.height - top
409
+ offset = CGPoint.new(0, height * -1.5)
410
+ offset = CGPointApplyAffineTransform(offset, self.transform)
411
+ self.transform = CGAffineTransformConcat(self.transform, CGAffineTransformMakeRotation(Math::PI/4))
412
+ self.center = CGPointMake(self.center.x + offset.x, self.center.y + offset.y)
413
+
414
+ self.animate(options) do
415
+ self.transform = reset_transform
416
+ self.center = reset_center
417
+ end
418
+ end
419
+
392
420
  # Moves the view backwards, similar to what Google has been doing a lot
393
421
  # recently
394
422
  def back_fiend!(options={}, more_options={})
@@ -510,6 +510,7 @@ class Symbol
510
510
  info_dark: UIButtonTypeInfoDark,
511
511
  contact: UIButtonTypeContactAdd,
512
512
  contact_add: UIButtonTypeContactAdd,
513
+ system: UIButtonTypeSystem,
513
514
  }
514
515
 
515
516
  @uicontrolstate = {
@@ -2,7 +2,7 @@
2
2
  class UIControl
3
3
 
4
4
  sugarcube_cleanup do
5
- self.off
5
+ @sugarcube_callbacks = nil
6
6
  end
7
7
 
8
8
  # Add event handlers to UIControls. See symbol.rb for the uicontrolevent
@@ -1,7 +1,7 @@
1
1
  class UITextView
2
2
 
3
3
  sugarcube_cleanup do
4
- self.off
4
+ @sugarcube_callbacks = nil
5
5
  end
6
6
 
7
7
  def sugarcube_callbacks
@@ -5,57 +5,63 @@ class UIButton
5
5
  end
6
6
  def rounded
7
7
  if self != UIButton
8
- raise "Custom subclasses of UIButton most be created using UIButton.custom"
8
+ raise "Custom subclasses of UIButton must be created using UIButton.custom"
9
9
  end
10
10
  self.buttonWithType(UIButtonTypeRoundedRect)
11
11
  end
12
12
  def rounded_rect
13
13
  if self != UIButton
14
- raise "Custom subclasses of UIButton most be created using UIButton.custom"
14
+ raise "Custom subclasses of UIButton must be created using UIButton.custom"
15
15
  end
16
16
  self.buttonWithType(UIButtonTypeRoundedRect)
17
17
  end
18
18
  def detail
19
19
  if self != UIButton
20
- raise "Custom subclasses of UIButton most be created using UIButton.custom"
20
+ raise "Custom subclasses of UIButton must be created using UIButton.custom"
21
21
  end
22
22
  self.buttonWithType(UIButtonTypeDetailDisclosure)
23
23
  end
24
24
  def detail_disclosure
25
25
  if self != UIButton
26
- raise "Custom subclasses of UIButton most be created using UIButton.custom"
26
+ raise "Custom subclasses of UIButton must be created using UIButton.custom"
27
27
  end
28
28
  self.buttonWithType(UIButtonTypeDetailDisclosure)
29
29
  end
30
30
  def info
31
31
  if self != UIButton
32
- raise "Custom subclasses of UIButton most be created using UIButton.custom"
32
+ raise "Custom subclasses of UIButton must be created using UIButton.custom"
33
33
  end
34
34
  self.buttonWithType(UIButtonTypeInfoLight)
35
35
  end
36
36
  def info_light
37
37
  if self != UIButton
38
- raise "Custom subclasses of UIButton most be created using UIButton.custom"
38
+ raise "Custom subclasses of UIButton must be created using UIButton.custom"
39
39
  end
40
40
  self.buttonWithType(UIButtonTypeInfoLight)
41
41
  end
42
42
  def info_dark
43
43
  if self != UIButton
44
- raise "Custom subclasses of UIButton most be created using UIButton.custom"
44
+ raise "Custom subclasses of UIButton must be created using UIButton.custom"
45
45
  end
46
46
  self.buttonWithType(UIButtonTypeInfoDark)
47
47
  end
48
48
  def contact
49
49
  if self != UIButton
50
- raise "Custom subclasses of UIButton most be created using UIButton.custom"
50
+ raise "Custom subclasses of UIButton must be created using UIButton.custom"
51
51
  end
52
52
  self.buttonWithType(UIButtonTypeContactAdd)
53
53
  end
54
54
  def contact_add
55
55
  if self != UIButton
56
- raise "Custom subclasses of UIButton most be created using UIButton.custom"
56
+ raise "Custom subclasses of UIButton must be created using UIButton.custom"
57
57
  end
58
58
  self.buttonWithType(UIButtonTypeContactAdd)
59
59
  end
60
+ def system
61
+ if self != UIButton
62
+ raise "Custom subclasses of UIButton must be created using UIButton.custom"
63
+ end
64
+ self.buttonWithType(UIButtonTypeSystem)
65
+ end
60
66
  end
61
67
  end
@@ -4,7 +4,7 @@
4
4
  class UIView
5
5
 
6
6
  sugarcube_cleanup do
7
- self.off_gestures
7
+ @sugarcube_recognizers = nil
8
8
  end
9
9
 
10
10
  # A generic gesture adder, but accepts a block like the other gesture methods
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '1.3.5'
2
+ Version = '1.3.6'
3
3
  end
@@ -203,6 +203,7 @@ describe "Symbol - constants" do
203
203
  :info_dark.uibuttontype.should == UIButtonTypeInfoDark
204
204
  :contact.uibuttontype.should == UIButtonTypeContactAdd
205
205
  :contact_add.uibuttontype.should == UIButtonTypeContactAdd
206
+ :system.uibuttontype.should == UIButtonTypeSystem
206
207
  end
207
208
 
208
209
  it 'should support `uicontrolstate`' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugarcube
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.5
4
+ version: 1.3.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-11-01 00:00:00.000000000 Z
15
+ date: 2013-12-05 00:00:00.000000000 Z
16
16
  dependencies: []
17
17
  description: ! '== Description
18
18
 
@@ -273,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
273
273
  version: '0'
274
274
  requirements: []
275
275
  rubyforge_project:
276
- rubygems_version: 1.8.25
276
+ rubygems_version: 1.8.11
277
277
  signing_key:
278
278
  specification_version: 3
279
279
  summary: Extensions for Ruby to make Rubymotion development more enjoyable, and hopefully