sugarcube 1.5.3 → 1.5.4

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c97e80c9fbc0c25b20886461e3e5aa41d48df97
4
- data.tar.gz: c380e00cb3e5ebf62e8a22a362382013c8f3a08c
3
+ metadata.gz: 741a9f9b789c05eb8ad6b99f579ae571401faf73
4
+ data.tar.gz: abc4c71c5bbf61b4efc1ba21fb5b62496714ed67
5
5
  SHA512:
6
- metadata.gz: e0f45b6a1954c134c693dbaca76453223c5c3be81ca9567072a06078d55da35f29beaa4361ee04e4de02f73b4eb3a92f87c92daf3a19eb2b24b33c9941469016
7
- data.tar.gz: cc81fb3b7dbf13739cec164203069062afc2d196c381e14edefe2ecc8fe18053a1bd60723861005bf155c9efa221612ff3bebcefee813e60e4b5f11cbedc1e5a
6
+ metadata.gz: 40fb96d9a125f15272b70cd1872d305bfdcf187cb8cec9e58f37f1bdff5478c51e81b93e0b768585760f7f8f500c4a981ced8553eb502fda0d4592d5bfe7f517
7
+ data.tar.gz: 8b20303cf731e9e64596c6595a43de7f8e9cdafbf53440122c4ec6a7455ec9188af5f257e9af72bc5f44872fc31a0f6cae2ec87c4311157cabc5e5c60784ac81
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sugarcube (1.5.3)
4
+ sugarcube (1.5.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -873,6 +873,13 @@ view.slide :left, 100
873
873
  view.rotate_to 180.degrees
874
874
  view.shake # great for showing invalid form elements
875
875
  view.tumble # great way to dismiss an alert-like-view
876
+ # tumbles in the other direction (towards the right side instead of left)
877
+ view.tumble(side: :right)
878
+
879
+ # the complement to 'tumble' is 'tumble_in' - the view starts above the window
880
+ # and drops in with the same kind of animation as 'tumble'. Before you call
881
+ # this method, set the view.frame to the *destination* location.
882
+ view.tumble_in(side: :right)
876
883
  ```
877
884
 
878
885
  These helpers all delegate to the `UIView.animate` method, which accepts all the
@@ -423,8 +423,23 @@ class UIView
423
423
  if options.is_a? Numeric
424
424
  default_duration = options
425
425
  options = more_options
426
+ side = options[:side] || :left
427
+ elsif options.is_a? Symbol
428
+ side = options
429
+ options = more_options
430
+ default_duration = 0.3
426
431
  else
427
432
  default_duration = 0.3
433
+ side = options[:side] || :left
434
+ end
435
+
436
+ case side
437
+ when :left
438
+ angle = -Math::PI/4
439
+ when :right
440
+ angle = Math::PI/4
441
+ else
442
+ raise "Unknown direction #{side.inspect}"
428
443
  end
429
444
 
430
445
  options[:duration] ||= default_duration
@@ -454,7 +469,7 @@ class UIView
454
469
  height = window.frame.size.height - top
455
470
  offset = CGPoint.new(0, height * 1.5)
456
471
  offset = CGPointApplyAffineTransform(offset, self.transform)
457
- self.transform = CGAffineTransformConcat(self.transform, CGAffineTransformMakeRotation(-Math::PI/4))
472
+ self.transform = CGAffineTransformConcat(self.transform, CGAffineTransformMakeRotation(angle))
458
473
  self.center = CGPointMake(self.center.x + offset.x, self.center.y + offset.y)
459
474
  end
460
475
  end
@@ -462,12 +477,27 @@ class UIView
462
477
  # Moves the view on screen while slowly rotating it.
463
478
  #
464
479
  # Based on https://github.com/warrenm/AHAlertView/blob/master/AHAlertView/AHAlertView.m
465
- def tumble_in(options={}, &after)
480
+ def tumble_in(options={}, more_options={}, &after)
466
481
  if options.is_a? Numeric
467
482
  default_duration = options
468
- options = {}
483
+ options = more_options
484
+ side = options[:side] || :left
485
+ elsif options.is_a? Symbol
486
+ side = options
487
+ options = more_options
488
+ default_duration = 0.3
469
489
  else
470
490
  default_duration = 0.3
491
+ side = options[:side] || :left
492
+ end
493
+
494
+ case side
495
+ when :left
496
+ angle = -Math::PI/4
497
+ when :right
498
+ angle = Math::PI/4
499
+ else
500
+ raise "Unknown direction #{side.inspect}"
471
501
  end
472
502
 
473
503
  reset_transform = self.transform
@@ -482,7 +512,7 @@ class UIView
482
512
  height = window.frame.size.height - top
483
513
  offset = CGPoint.new(0, height * -1.5)
484
514
  offset = CGPointApplyAffineTransform(offset, self.transform)
485
- self.transform = CGAffineTransformConcat(self.transform, CGAffineTransformMakeRotation(Math::PI/4))
515
+ self.transform = CGAffineTransformConcat(self.transform, CGAffineTransformMakeRotation(angle))
486
516
  self.center = CGPointMake(self.center.x + offset.x, self.center.y + offset.y)
487
517
 
488
518
  self.animate(options) do
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '1.5.3'
2
+ Version = '1.5.4'
3
3
  end
@@ -192,6 +192,21 @@ describe "Symbol - constants" do
192
192
  :done.uibarbuttonstyle.should == UIBarButtonItemStyleDone
193
193
  end
194
194
 
195
+ it 'should support `uitabbarsystemitem`' do
196
+ :more.uitabbarsystemitem.should == UITabBarSystemItemMore
197
+ :favorites.uitabbarsystemitem.should == UITabBarSystemItemFavorites
198
+ :featured.uitabbarsystemitem.should == UITabBarSystemItemFeatured
199
+ :top_rated.uitabbarsystemitem.should == UITabBarSystemItemTopRated
200
+ :recents.uitabbarsystemitem.should == UITabBarSystemItemRecents
201
+ :contacts.uitabbarsystemitem.should == UITabBarSystemItemContacts
202
+ :history.uitabbarsystemitem.should == UITabBarSystemItemHistory
203
+ :bookmarks.uitabbarsystemitem.should == UITabBarSystemItemBookmarks
204
+ :search.uitabbarsystemitem.should == UITabBarSystemItemSearch
205
+ :downloads.uitabbarsystemitem.should == UITabBarSystemItemDownloads
206
+ :most_recent.uitabbarsystemitem.should == UITabBarSystemItemMostRecent
207
+ :most_viewed.uitabbarsystemitem.should == UITabBarSystemItemMostViewed
208
+ end
209
+
195
210
  it 'should support `uibuttontype`' do
196
211
  :custom.uibuttontype.should == UIButtonTypeCustom
197
212
  :rounded.uibuttontype.should == UIButtonTypeRoundedRect
@@ -0,0 +1,140 @@
1
+ describe "UIView animation methods" do
2
+ # the 'tumble' animation requires an app window to be present
3
+ tests UIViewController
4
+
5
+ before do
6
+ @view = UIView.alloc.initWithFrame([[1,2],[3,4]])
7
+ controller.view.addSubview(@view)
8
+ end
9
+
10
+ it 'should have a tumble animation' do
11
+ @done = false
12
+ @view.tumble
13
+ @view.center.y.should > UIScreen.mainScreen.bounds.size.height
14
+ end
15
+
16
+ it 'should have a tumble_in animation' do
17
+ @done = false
18
+ @view.tumble_in
19
+ @view.frame.origin.y.should == 2
20
+ end
21
+
22
+ it 'should have a tumble animation with duration' do
23
+ @done = false
24
+ @view.tumble(0.4) do |finished|
25
+ @done = finished ? :done : :unfinished
26
+ end
27
+ @view.center.y.should > UIScreen.mainScreen.bounds.size.height
28
+ wait 0.3 do
29
+ @done.should == false
30
+ wait 0.3 do
31
+ @done.should == :done
32
+ end
33
+ end
34
+ end
35
+
36
+ it 'should have a tumble_in animation with duration' do
37
+ @done = false
38
+ @view.tumble_in(0.4) do |finished|
39
+ @done = finished ? :done : :unfinished
40
+ end
41
+ @view.frame.origin.y.should == 2
42
+ wait 0.3 do
43
+ @done.should == false
44
+ wait 0.3 do
45
+ @done.should == :done
46
+ end
47
+ end
48
+ end
49
+
50
+ it 'should have a tumble animation with side as parameter' do
51
+ -> do
52
+ @view.tumble(:left)
53
+ end.should.not.raise
54
+ end
55
+
56
+ it 'should have a tumble_in animation with side as parameter' do
57
+ -> do
58
+ @view.tumble_in(:left)
59
+ end.should.not.raise
60
+ end
61
+
62
+ it 'should have a tumble animation with duration as option' do
63
+ @done = false
64
+ @view.tumble(duration: 0.4) do
65
+ @done = :done
66
+ end
67
+ @view.center.y.should > UIScreen.mainScreen.bounds.size.height
68
+ wait 0.3 do
69
+ @done.should == false
70
+ wait 0.2 do
71
+ @done.should == :done
72
+ end
73
+ end
74
+ end
75
+
76
+ it 'should have a tumble_in animation with duration as option' do
77
+ @done = false
78
+ @view.tumble_in(duration: 0.4) do
79
+ @done = :done
80
+ end
81
+ @view.frame.origin.y.should == 2
82
+ wait 0.3 do
83
+ @done.should == false
84
+ wait 0.2 do
85
+ @done.should == :done
86
+ end
87
+ end
88
+ end
89
+
90
+ it 'should have a tumble animation with side as option' do
91
+ @view.tumble(side: :left)
92
+ @view.center.y.should > UIScreen.mainScreen.bounds.size.height
93
+ end
94
+
95
+ it 'should have a tumble_in animation with side as option' do
96
+ @view.tumble_in(side: :left)
97
+ @view.frame.origin.y.should == 2
98
+ end
99
+
100
+ it 'should have a tumble animation with invalid side option raising exception' do
101
+ -> do
102
+ @view.tumble(side: :this_is_silly)
103
+ end.should.raise
104
+ end
105
+
106
+ it 'should have a tumble_in animation with invalid side option raising exception' do
107
+ -> do
108
+ @view.tumble_in(side: :this_is_silly)
109
+ end.should.raise
110
+ end
111
+
112
+ it 'should have a tumble animation with duration and options' do
113
+ @done = false
114
+ @view.tumble(0.4, options: UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionBeginFromCurrentState) do
115
+ @done = :done
116
+ end
117
+ @view.center.y.should > UIScreen.mainScreen.bounds.size.height
118
+ wait 0.3 do
119
+ @done.should == false
120
+ wait 0.2 do
121
+ @done.should == :done
122
+ end
123
+ end
124
+ end
125
+
126
+ it 'should have a tumble_in animation with duration and options' do
127
+ @done = false
128
+ @view.tumble_in(0.4, options: UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionBeginFromCurrentState) do
129
+ @done = :done
130
+ end
131
+ @view.frame.origin.y.should == 2
132
+ wait 0.3 do
133
+ @done.should == false
134
+ wait 0.2 do
135
+ @done.should == :done
136
+ end
137
+ end
138
+ end
139
+
140
+ end
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.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin T.A. Gray
@@ -241,6 +241,7 @@ files:
241
241
  - spec/uitabbaritem_spec.rb
242
242
  - spec/uitableviewcell_spec.rb
243
243
  - spec/uiview_animation_spec.rb
244
+ - spec/uiview_animation_tumble_spec.rb
244
245
  - spec/uiview_attr_updates_spec.rb
245
246
  - spec/uiview_spec.rb
246
247
  - spec/uiviewcontroller_spec.rb
@@ -319,6 +320,7 @@ test_files:
319
320
  - spec/uitabbaritem_spec.rb
320
321
  - spec/uitableviewcell_spec.rb
321
322
  - spec/uiview_animation_spec.rb
323
+ - spec/uiview_animation_tumble_spec.rb
322
324
  - spec/uiview_attr_updates_spec.rb
323
325
  - spec/uiview_spec.rb
324
326
  - spec/uiviewcontroller_spec.rb