sugarcube 0.20.11 → 0.20.12

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sugarcube (0.20.10)
4
+ sugarcube (0.20.12)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -67,7 +67,7 @@ Installation
67
67
  Examples
68
68
  ========
69
69
 
70
- Array
70
+ Array
71
71
  -------
72
72
 
73
73
  ```ruby
@@ -76,7 +76,7 @@ Examples
76
76
  [160, 210, 242].uicolor(0.5) # => UIColor.colorWithRed(0.6274, green:0.8235, blue:0.9490, alpha:0.5)
77
77
  ```
78
78
 
79
- Hash => Object
79
+ Hash => Object
80
80
  --------
81
81
 
82
82
  ```ruby
@@ -101,7 +101,7 @@ h.baz # => NoMethodError
101
101
  h.baz = 'baz' # => NoMethodError
102
102
  ```
103
103
 
104
- Fixnum
104
+ Fixnum
105
105
  --------
106
106
 
107
107
  ```ruby
@@ -129,7 +129,7 @@ NSDate.new # => 2013-01-03 11:42:24 -0700
129
129
  # later => NSTimer
130
130
  ```
131
131
 
132
- Numeric
132
+ Numeric
133
133
  ---------
134
134
 
135
135
  ```ruby
@@ -156,7 +156,7 @@ distance.miles # => 0.932056427001953
156
156
  10000.string_with_style(:currency) # => "$10,000.00"
157
157
  ```
158
158
 
159
- NSAttributedString
159
+ NSAttributedString
160
160
  ---------
161
161
 
162
162
  ```ruby
@@ -195,7 +195,7 @@ view << (("We just met\n".attrd +
195
195
  "so give me SSH access.").uilabel
196
196
  ```
197
197
 
198
- NSCoder
198
+ NSCoder
199
199
  ---------
200
200
 
201
201
  Shorthands and hash-like access to the coder/decoder objects.
@@ -245,7 +245,7 @@ string_data.nsstring # => 'String'
245
245
  image_data.nsimage # => whatever 'an image' was
246
246
  ```
247
247
 
248
- NSDate
248
+ NSDate
249
249
  --------
250
250
 
251
251
  `NSDate` objects are converted to `Time` objects automatically by rubymotion.
@@ -490,7 +490,7 @@ NSError.new('Error Message', code: 404)
490
490
  NSError.new('Error Message', code: 404, userInfo: { warnings: ['blabla'] })
491
491
  ```
492
492
 
493
- NSURL
493
+ NSURL
494
494
  -------
495
495
 
496
496
  ```ruby
@@ -498,7 +498,7 @@ NSError.new('Error Message', code: 404, userInfo: { warnings: ['blabla'] })
498
498
  "https://github.com".nsurl.open # => UIApplication.sharedApplication.openURL(NSURL.URLWithString("https://github.com"))
499
499
  ```
500
500
 
501
- NSString
501
+ NSString
502
502
  ----------
503
503
 
504
504
  ```ruby
@@ -543,7 +543,7 @@ NSError.new('Error Message', code: 404, userInfo: { warnings: ['blabla'] })
543
543
  "pi".nan? # => NSNumberFormatter.alloc.init.numberFromString("pi").nil?
544
544
  ```
545
545
 
546
- NSIndexPath
546
+ NSIndexPath
547
547
  -------------
548
548
 
549
549
  Use the `IndexPath` class to match `NSIndexPath` objects, for instance in a
@@ -559,7 +559,7 @@ end
559
559
  [0, 2].nsindexpath.to_a == [0, 2] # => true
560
560
  ```
561
561
 
562
- Symbol
562
+ Symbol
563
563
  --------
564
564
 
565
565
  This is the "big daddy". Lots of sugar here...
@@ -597,7 +597,7 @@ This is the "big daddy". Lots of sugar here...
597
597
  :blue.uitablecellselectionstyle # or .uitableviewcellselectionstyle
598
598
  ```
599
599
 
600
- UIImage
600
+ UIImage
601
601
  ---------
602
602
 
603
603
  ```ruby
@@ -725,7 +725,7 @@ UIActionSheet.alert 'I mean, is this cool?', buttons: ['Nah', 'With fire!', 'Sur
725
725
  success: proc { |pressed| self.proceed if pressed == 'Sure' }
726
726
  ```
727
727
 
728
- UIColor
728
+ UIColor
729
729
  ---------
730
730
 
731
731
  Methods to merge or manipulate a color, or to get information about a color.
@@ -749,7 +749,7 @@ image patterns can't easily be inverted or mixed.
749
749
  :white.uicolor.mix_with(:black.uicolor, 1) # => :black
750
750
  ```
751
751
 
752
- UIView
752
+ UIView
753
753
  --------
754
754
 
755
755
  ```ruby
@@ -799,22 +799,22 @@ provides it to all its completion handlers).
799
799
  view.fade_out
800
800
 
801
801
  # with a callback
802
- view.fade_out {
802
+ view.fade_out do
803
803
  view.removeFromSuperview
804
- }
804
+ end
805
805
 
806
806
  # and the completed argument
807
- view.fade_out { |completed|
807
+ view.fade_out do |completed|
808
808
  view.removeFromSuperview
809
- }
809
+ end
810
810
 
811
811
  # fade_out options
812
812
  view.fade_out(duration: 0.5,
813
813
  delay: 0,
814
814
  options: UIViewAnimationOptionCurveLinear,
815
- opacity: 0.5) {
815
+ opacity: 0.5) do
816
816
  view.removeFromSuperview
817
- }
817
+ end
818
818
 
819
819
  view.move_to([0, 100]) # move to position 0, 100
820
820
  view.delta_to([0, 100]) # move over 0, down 100, from current position
@@ -823,7 +823,10 @@ view.rotate_to Math::PI # rotate view upside down
823
823
  view.rotate 45.degrees # rotate *an additional* 45 degrees
824
824
  view.rotate_to(duration: 0.5, angle: 45.degrees) # using options
825
825
 
826
- view.slide :left # slides the entire view one "page" to the left, right, up, or down
826
+ view.slide :left # slides the entire view left, right, up, or down. The
827
+ # default amount is the width of the view being moved, but
828
+ # you can override
829
+ view.slide :left, 320
827
830
 
828
831
  view.shake # shakes the view.
829
832
  # options w/ default values:
@@ -843,19 +846,48 @@ view.shake offset: 0.1, repeat: 2, duration: 0.5, keypath: 'transform.rotation'
843
846
  view.tumble # the view will fall and rotate - a good 'cancel button effect'
844
847
  ```
845
848
 
849
+ The default behavior on all the animation methods is to animate from "the
850
+ current" position (`UIViewAnimationOptionBeginFromCurrentState`). To disable
851
+ that, you can either assign `options:` to something else, or you can disable
852
+
853
+ ```ruby
854
+ # *just* that option.
855
+ view.slide :left, from_current: false
856
+ ```
857
+
858
+ Other options can be assigned this way, like the curve
859
+
860
+ ```ruby
861
+ view.slide :left, from_current: false, curve: :ease_in # :ease_in_out, :ease_in, :ease_out, :linear
862
+ ```
863
+
864
+ Allow/disallow user interaction
865
+
866
+ ```ruby
867
+ view.slide :left, allow_interaction: true
868
+ ```
869
+
870
+ Not all options are configurable this way. Refer to `UIViewAnimationOptions` and
871
+ assign them direcly to `options:` if there are options you need that are not
872
+ listed here.
873
+
874
+ ```ruby
875
+ view.slide :left, options: UIViewAnimationOptionAllowAnimatedContent | UIViewAnimationOptionCurveEaseInOut
876
+ ```
877
+
846
878
  Using the completed callback you can string animations together for a low-tech
847
879
  animation sequence.
848
880
 
849
881
  ```ruby
850
- view.slide(:left, 20) {
851
- view.slide(:up, 20) {
852
- view.slide(:right, 20) {
853
- view.slide(:down, 20) {
882
+ view.slide(:left, 20) do
883
+ view.slide(:up, 20) do
884
+ view.slide(:right, 20) do
885
+ view.slide(:down, 20) do
854
886
  view.fade_out
855
- }
856
- }
857
- }
858
- }
887
+ end
888
+ end
889
+ end
890
+ end
859
891
  ```
860
892
 
861
893
  Those be some gnarly callbacks. You can write this as a chain instead!
@@ -925,7 +957,7 @@ chain.loop(10) # would loop 10 times
925
957
  # if you're impatient
926
958
  chain.abort
927
959
  # will stop the animation at the end of whatever block it is in, so it could be
928
- # in a strange position, depending on where in the chain it is. better to call
960
+ # in a strange position, depending on where in the chain it is. Better to call
929
961
  # `stop`
930
962
  ```
931
963
 
@@ -971,6 +1003,24 @@ UITableView.plain([[0, 0], [320, 568]])
971
1003
  UITableView.grouped([[0, 0], [320, 400]])
972
1004
  ```
973
1005
 
1006
+ ###### UITableViewCell
1007
+
1008
+ ```ruby
1009
+ # factory methods, named for the cell style. cell identifier is required.
1010
+ UITableViewCell.default('cell_identifier')
1011
+ UITableViewCell.value1('cell_identifier')
1012
+ UITableViewCell.value2('cell_identifier')
1013
+ UITableViewCell.subtitle('cell_identifier')
1014
+
1015
+ # you can options for the common settings
1016
+ cell = UITableViewCell.default('cell_identifier',
1017
+ accessory: :disclosure,
1018
+ selection: :blue,
1019
+ text: 'text',
1020
+ image: 'icon', # coerced into a UIImage
1021
+ )
1022
+ ```
1023
+
974
1024
  ###### UISegmentedControl
975
1025
 
976
1026
  ```ruby
@@ -996,7 +1046,7 @@ UIActivityIndicatorView.large
996
1046
  UIActivityIndicatorView.gray
997
1047
  ```
998
1048
 
999
- UIControl
1049
+ UIControl
1000
1050
  -----------
1001
1051
 
1002
1052
  Inspired by [BubbleWrap's][BubbleWrap] `when` method, but I prefer jQuery-style
@@ -1019,7 +1069,7 @@ button.off(:all)
1019
1069
  You can only remove handlers by "type", not by the action. e.g. If you bind
1020
1070
  three `:touch` events, calling `button.off(:touch)` will remove all three.
1021
1071
 
1022
- UIViewController
1072
+ UIViewController
1023
1073
  ------------------
1024
1074
 
1025
1075
  It is nice that *any* `UIViewController` can present a modal, but if you have
@@ -1051,7 +1101,7 @@ re-defined on `UIViewController` for this purpose:
1051
1101
  controller.present_modal(other_controller) { puts "presented" }
1052
1102
  ```
1053
1103
 
1054
- UINavigationController
1104
+ UINavigationController
1055
1105
  ------------------------
1056
1106
 
1057
1107
  `push`, `<<` and `pop` instead of `pushViewController` and `popViewController`.
@@ -1073,7 +1123,7 @@ nav_ctlr.pop new_ctlr # => pops to new_ctlr
1073
1123
  nav_ctlr.pop :root # => pops to root_ctlr, because it's on the bottom
1074
1124
  ```
1075
1125
 
1076
- UITabBarController
1126
+ UITabBarController
1077
1127
  ------------------------
1078
1128
 
1079
1129
  I have mixed feelings about adding this extension, but **I** needed it, so maybe
@@ -1091,7 +1141,7 @@ tabbar_ctlr.setViewControllers(controllers, animated: true)
1091
1141
  tabbar_ctlr << new_ctlr
1092
1142
  ```
1093
1143
 
1094
- UITextView
1144
+ UITextView
1095
1145
  ------------
1096
1146
 
1097
1147
  Added some `UIControl`-like event binding. You MUST call the `off` methods,
@@ -1122,21 +1172,23 @@ end
1122
1172
  text_view.off :change, :end, :begin
1123
1173
  ```
1124
1174
 
1125
- UILabel
1175
+ UILabel
1126
1176
  ----------
1127
1177
 
1128
- Added simple `fit_to_size` function to the label, which will start at the supplied font size
1129
- and then squeeze down until all the text fits. This way you can assure any dynamic text will completely display
1130
- in a given label frame.
1178
+ Added simple `fit_to_size` function to the label, which will start at the supplied font size
1179
+ and then squeeze down until all the text fits. This way you can assure any dynamic text will completely display
1180
+ in a given label frame.
1131
1181
 
1132
- The font size changes instead of the frame size.
1133
- ```ruby
1134
- #this will try to make the containing text fit at font size 40, but squeeze as needed.
1182
+ The font size changes instead of the frame size.
1183
+ ```ruby
1184
+ # this will try to make the containing text fit at font size 40, but squeeze as needed.
1135
1185
  @label.fit_to_size(40)
1136
1186
  puts @label.font.pointSize # => Will be 40 or less depending on the font type and label frame.
1137
- ```
1187
+ ```
1188
+
1189
+
1138
1190
 
1139
- UIBarButtonItem
1191
+ UIBarButtonItem
1140
1192
  ----------------------
1141
1193
 
1142
1194
  ```ruby
@@ -1227,7 +1279,7 @@ Makes it easy to post a notification to some or all objects.
1227
1279
  "my notification".remove_observer(observer, object)
1228
1280
  ```
1229
1281
 
1230
- NSTimer
1282
+ NSTimer
1231
1283
  ---------
1232
1284
 
1233
1285
  ```ruby
@@ -1325,7 +1377,7 @@ test['my'] = 'new'
1325
1377
  NSUserDefaults['test'] = test # saved
1326
1378
  ```
1327
1379
 
1328
- CoreGraphics
1380
+ CoreGraphics
1329
1381
  --------------
1330
1382
 
1331
1383
  ###### Is it `CGMakeRect` or `CGRectMake`? What arguments does `CGRect.new` take?
@@ -1365,7 +1417,7 @@ f = Rect(p, [w, h])
1365
1417
  f = Rect([x, y], s)
1366
1418
  ```
1367
1419
 
1368
- CoreLocation
1420
+ CoreLocation
1369
1421
  --------------
1370
1422
 
1371
1423
  Open up `CLLocationCoordinate2D` to provide handy-dandies
@@ -1387,7 +1439,7 @@ Open up `CLLocationCoordinate2D` to provide handy-dandies
1387
1439
  => 0.00502094626426697
1388
1440
  ```
1389
1441
 
1390
- REPL View adjustments
1442
+ REPL View adjustments
1391
1443
  -----------------------
1392
1444
 
1393
1445
  Pixel pushing is an unfortunate but necessary evil. Well, at least we can make
@@ -1664,7 +1716,7 @@ $sugarcube_items # => the list of views that was output using `tree`
1664
1716
  ```
1665
1717
 
1666
1718
 
1667
- Pointers
1719
+ Pointers
1668
1720
  ----------
1669
1721
 
1670
1722
  These are not UIKit-related, so I reverted to Ruby's preferred `to_foo`
@@ -1680,7 +1732,7 @@ floats[1] = 1.1
1680
1732
  floats[2] = 2.2
1681
1733
  ```
1682
1734
 
1683
- UUID
1735
+ UUID
1684
1736
  ------
1685
1737
 
1686
1738
  Quick wrapper for `CFUUIDCreate()` and `CFUUIDCreateString()`. Identical to the
@@ -1696,7 +1748,7 @@ Quick wrapper for `CFUUIDCreate()` and `CFUUIDCreateString()`. Identical to the
1696
1748
  # => "0A3A76C6-9738-4458-969E-3B9DF174A3D9"
1697
1749
  ```
1698
1750
 
1699
- Ruby on Rails Ripoffs (RoR-R?)
1751
+ Ruby on Rails Ripoffs (RoR-R?)
1700
1752
  ---------------
1701
1753
 
1702
1754
  aka `ActiveSupport`.
@@ -1763,7 +1815,7 @@ view.on_press(1.5) # duration
1763
1815
  view.on_press(duration: 1.5, taps: 1, fingers: 1)
1764
1816
  ```
1765
1817
 
1766
- Unholy
1818
+ Unholy
1767
1819
  --------
1768
1820
 
1769
1821
  These methods are just about as opinionated as they get - even more than the RoR
@@ -56,12 +56,12 @@ module SugarCube
56
56
  }
57
57
  options[:after] = @after_block
58
58
 
59
- UIView.animate(options) {
59
+ UIView.animate(options) do
60
60
  Thread.current[:sugarcube_chaining] = true
61
61
  block.call
62
62
  Thread.current[:sugarcube_chaining] = nil
63
63
  @block_index += 1
64
- }
64
+ end
65
65
  true
66
66
  end
67
67
 
@@ -52,7 +52,8 @@ class Symbol
52
52
  attr :activityindicator_styles
53
53
  attr :segmented_styles
54
54
  attr :datepicker_modes
55
- attr :content_modes
55
+ attr :uiview_content_modes
56
+ attr :uiview_animation_curve
56
57
 
57
58
  attr :tableview_styles
58
59
  attr :tableview_rowanimation
@@ -274,7 +275,7 @@ class Symbol
274
275
  countdowntimer: UIDatePickerModeCountDownTimer
275
276
  }
276
277
 
277
- @content_modes = {
278
+ @uiview_content_modes = {
278
279
  scale: UIViewContentModeScaleToFill,
279
280
  scale_to_fill: UIViewContentModeScaleToFill,
280
281
  scaletofill: UIViewContentModeScaleToFill,
@@ -300,6 +301,13 @@ class Symbol
300
301
  bottom_right: UIViewContentModeBottomRight,
301
302
  }
302
303
 
304
+ @uiview_animation_curve = {
305
+ ease_in_out: UIViewAnimationCurveEaseInOut,
306
+ ease_in: UIViewAnimationCurveEaseIn,
307
+ ease_out: UIViewAnimationCurveEaseOut,
308
+ linear: UIViewAnimationCurveLinear
309
+ }
310
+
303
311
  @tableview_styles = {
304
312
  plain: UITableViewStylePlain,
305
313
  grouped: UITableViewStyleGrouped,
@@ -581,10 +589,15 @@ class Symbol
581
589
  end
582
590
 
583
591
  def uicontentmode
584
- sugarcube_look_in(Symbol.content_modes)
592
+ sugarcube_look_in(Symbol.uiview_content_modes)
585
593
  end
586
594
  alias uiviewcontentmode uicontentmode
587
595
 
596
+ def uianimationcurve
597
+ sugarcube_look_in(Symbol.uiview_animation_curve)
598
+ end
599
+ alias uiviewanimationcurve uianimationcurve
600
+
588
601
  def uitablestyle
589
602
  sugarcube_look_in(Symbol.tableview_styles)
590
603
  end
@@ -600,10 +613,11 @@ class Symbol
600
613
  end
601
614
  alias uitableviewcellstyle uitablecellstyle
602
615
 
603
- def uitableviewcellaccessorytype
616
+ def uitablecellaccessorytype
604
617
  sugarcube_look_in(Symbol.tableview_cellaccessorytype)
605
618
  end
606
- alias uitablecellaccessory uitableviewcellaccessorytype
619
+ alias uitablecellaccessory uitablecellaccessorytype
620
+ alias uitableviewcellaccessorytype uitablecellaccessorytype
607
621
 
608
622
  def uitablecellselectionstyle
609
623
  sugarcube_look_in(Symbol.tableview_cellselectionstyle)
@@ -0,0 +1,84 @@
1
+ # Factory methods for UITableViewCell
2
+ class UITableViewCell
3
+
4
+ class << self
5
+
6
+ # returns a cell in the default style, with reuse identifier
7
+ # `cell_identifier`. Options are passed on to the
8
+ # `sugarcube_cell_factory` method.
9
+ def default(cell_identifier, options={})
10
+ return sugarcube_cell_factory(cell_identifier, :default, options)
11
+ end
12
+
13
+ # returns a cell in the value1 style, with reuse identifier
14
+ # `cell_identifier`. Options are passed on to the
15
+ # `sugarcube_cell_factory` method.
16
+ def value1(cell_identifier, options={})
17
+ return sugarcube_cell_factory(cell_identifier, :value1, options)
18
+ end
19
+
20
+ # returns a cell in the value2 style, with reuse identifier
21
+ # `cell_identifier`. Options are passed on to the
22
+ # `sugarcube_cell_factory` method.
23
+ def value2(cell_identifier, options={})
24
+ return sugarcube_cell_factory(cell_identifier, :value2, options)
25
+ end
26
+
27
+ # returns a cell in the subtitle style, with reuse identifier
28
+ # `cell_identifier`. Options are passed on to the
29
+ # `sugarcube_cell_factory` method.
30
+ def subtitle(cell_identifier, options={})
31
+ return sugarcube_cell_factory(cell_identifier, :subtitle, options)
32
+ end
33
+
34
+ private
35
+
36
+ # Available options:
37
+ # accessory - accessoryType. Valid values:
38
+ # :none, :disclosure, :disclosureindicator, :detail,
39
+ # :detaildisclosurebutton, :checkmark
40
+ # or any UITableViewCellAccessory constant
41
+ # text - textLabel.text content
42
+ # detail - detailTextLabel.text content
43
+ # selection - selectionStyle
44
+ def sugarcube_cell_factory(cell_identifier, cell_style, options)
45
+ cell_style = cell_style.uitablecellstyle if cell_style.is_a?(Symbol)
46
+ cell = UITableViewCell.alloc.initWithStyle(cell_style, reuseIdentifier: cell_identifier)
47
+
48
+ if options[:accessory]
49
+ accessory = options[:accessory]
50
+ if accessory.is_a?(Symbol)
51
+ accessory = accessory.uitablecellaccessorytype
52
+ end
53
+ cell.accessoryType = accessory
54
+ end
55
+
56
+ if options[:selection]
57
+ selection = options[:selection]
58
+ if selection.is_a?(Symbol)
59
+ selection = selection.uitablecellselectionstyle
60
+ end
61
+ cell.selectionStyle = selection
62
+ end
63
+
64
+ if options[:image]
65
+ raise "cell type #{cell_style} does not support imageView" unless cell.imageView
66
+ image = options[:image]
67
+ cell.imageView.image = image && image.uiimage
68
+ end
69
+
70
+ if options[:text]
71
+ cell.textLabel.text = options[:text]
72
+ end
73
+
74
+ if options[:detail]
75
+ raise "cell type #{cell_style} does not support detailTextLabel" unless cell.detailTextLabel
76
+ cell.detailTextLabel.text = options[:detail]
77
+ end
78
+
79
+ return cell
80
+ end
81
+
82
+ end
83
+
84
+ end
@@ -51,16 +51,30 @@ class UIView
51
51
  after_adjusted = nil
52
52
  end
53
53
 
54
+ animation_options = options[:options]
55
+ unless animation_options
56
+ curve = options.fetch(:curve, UIViewAnimationOptionCurveEaseInOut)
57
+ curve = curve.uianimationcurve if curve.is_a?(Symbol)
58
+
59
+ from_current = options.fetch(:from_current, true) ? UIViewAnimationOptionBeginFromCurrentState : 0
60
+ allow_interaction = options.fetch(:allow_interaction, false) ? UIViewAnimationOptionAllowUserInteraction : 0
61
+
62
+ animation_options = curve | from_current
63
+ end
64
+
54
65
  if duration == 0 && delay == 0
55
66
  animations.call
56
67
  after_adjusted.call(true) if after_adjusted
57
68
  else
69
+ prev_value = Thread.current[:sugarcube_chaining]
70
+ Thread.current[:sugarcube_chaining] = true
58
71
  UIView.animateWithDuration( duration,
59
72
  delay: delay,
60
- options: options[:options] || (UIViewAnimationOptionCurveEaseInOut|UIViewAnimationOptionBeginFromCurrentState),
73
+ options: animation_options,
61
74
  animations: animations,
62
75
  completion: after_adjusted
63
76
  )
77
+ Thread.current[:sugarcube_chaining] = prev_value
64
78
  end
65
79
  nil
66
80
  end
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '0.20.11'
2
+ Version = '0.20.12'
3
3
  end
@@ -0,0 +1,63 @@
1
+ describe UITableViewCell do
2
+
3
+ it 'should create a default cell' do
4
+ cell = UITableViewCell.default('cell_identifier')
5
+ UITableViewCell.should === cell
6
+ cell.reuseIdentifier.should == 'cell_identifier'
7
+ # there's no way to test for the style :-/
8
+ end
9
+
10
+ it 'should create a value1 cell' do
11
+ cell = UITableViewCell.value1('cell_identifier')
12
+ UITableViewCell.should === cell
13
+ cell.reuseIdentifier.should == 'cell_identifier'
14
+ # there's no way to test for the style :-/
15
+ end
16
+
17
+ it 'should create a value2 cell' do
18
+ cell = UITableViewCell.value2('cell_identifier')
19
+ UITableViewCell.should === cell
20
+ cell.reuseIdentifier.should == 'cell_identifier'
21
+ # there's no way to test for the style :-/
22
+ end
23
+
24
+ it 'should create a subtitle cell' do
25
+ cell = UITableViewCell.subtitle('cell_identifier')
26
+ UITableViewCell.should === cell
27
+ cell.reuseIdentifier.should == 'cell_identifier'
28
+ # there's no way to test for the style :-/
29
+ end
30
+
31
+ it 'should accept options (image)' do
32
+ cell = UITableViewCell.default('cell_identifier',
33
+ accessory: :disclosure,
34
+ selection: :blue,
35
+ text: 'text',
36
+ image: 'little_square',
37
+ )
38
+ cell.accessoryType.should == UITableViewCellAccessoryDisclosureIndicator
39
+ cell.selectionStyle.should == UITableViewCellSelectionStyleBlue
40
+ cell.textLabel.text.should == 'text'
41
+ cell.imageView.image.should == 'little_square'.uiimage
42
+ end
43
+
44
+ it 'should accept options (detail)' do
45
+ cell = UITableViewCell.value2('cell_identifier',
46
+ accessory: :disclosure,
47
+ selection: :blue,
48
+ text: 'text',
49
+ detail: 'detail text',
50
+ )
51
+ cell.accessoryType.should == UITableViewCellAccessoryDisclosureIndicator
52
+ cell.selectionStyle.should == UITableViewCellSelectionStyleBlue
53
+ cell.textLabel.text.should == 'text'
54
+ cell.detailTextLabel.text.should == 'detail text'
55
+ end
56
+
57
+ end
58
+
59
+ # accessory
60
+ # selection
61
+ # text
62
+ # image
63
+ # detail
@@ -7,6 +7,10 @@ describe "UIView animation methods" do
7
7
  @view.delta_to([1,2]).frame.should == CGRectMake(2,4,3,4)
8
8
  end
9
9
 
10
+ it 'should delta_to x:1 y:2' do
11
+ @view.move_to([2,4]).frame.should == CGRectMake(2,4,3,4)
12
+ end
13
+
10
14
  it 'should rotate 45 degrees' do
11
15
  angle = 45.degrees
12
16
  @view.rotate_to(angle)
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: 0.20.11
4
+ version: 0.20.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-04-21 00:00:00.000000000 Z
16
+ date: 2013-04-22 00:00:00.000000000 Z
17
17
  dependencies: []
18
18
  description: ! '== Description
19
19
 
@@ -119,6 +119,7 @@ files:
119
119
  - lib/sugarcube/uipickerview.rb
120
120
  - lib/sugarcube/uisegmentedcontrol.rb
121
121
  - lib/sugarcube/uitableview.rb
122
+ - lib/sugarcube/uitableviewcell.rb
122
123
  - lib/sugarcube/uitextview.rb
123
124
  - lib/sugarcube/uiview.rb
124
125
  - lib/sugarcube/uiviewcontroller.rb
@@ -167,6 +168,7 @@ files:
167
168
  - spec/uiimage_color_at_spec.rb
168
169
  - spec/uiimage_scale_spec.rb
169
170
  - spec/uilabel_spec.rb
171
+ - spec/uitableviewcell_spec.rb
170
172
  - spec/uiview_animation_spec.rb
171
173
  - spec/uiview_attr_updates_spec.rb
172
174
  - spec/uiview_spec.rb
@@ -232,6 +234,7 @@ test_files:
232
234
  - spec/uiimage_color_at_spec.rb
233
235
  - spec/uiimage_scale_spec.rb
234
236
  - spec/uilabel_spec.rb
237
+ - spec/uitableviewcell_spec.rb
235
238
  - spec/uiview_animation_spec.rb
236
239
  - spec/uiview_attr_updates_spec.rb
237
240
  - spec/uiview_spec.rb