ruby_motion_query 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OTg1MDhiZjc4MDZkZjM4NDBmMGQyZTI4MmJkZWYwNjJlOTJjMDQwYw==
5
- data.tar.gz: !binary |-
6
- MjI2OGY0ZTUzYmUyZmY1OWNhZWIzNThiZWY0OTRjMTEwMDQ2ZmFkMA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- ZTI0NmFhZWRkOTk4NTg1MGUyMjYyZDdkZjBlZjQwYjMyZDRlN2I3YzBiNGU2
10
- YTQ1NDUwYjg3OWE3ZjY4Njk4MDc2OWVmMzQzNzliNzUzMzViZWZhMzVmZmZl
11
- OWE5MDU0YzJjYmE4NTY3ZWI0MWZlYTgxZmIxMzIxZDgwOTc3ZTg=
12
- data.tar.gz: !binary |-
13
- NWZjYzBlNDk4NmY0ZGJjOTQyMDdiMTg4YjZiMWY0YjI5NDVmNzZmNjMwYzhi
14
- NDc3YTE0Mzg1NzliNWFkYjQ5YjkzMTI5MDVhZjU1ZTMyYTRlZWVkMTZhNWZl
15
- YTNjOWYyNzNiYWUxN2E0ODdhMmJmNzkzZmVhNGQ3NTEzZjRlM2Y=
2
+ SHA1:
3
+ metadata.gz: 0db67ccbb3871d29450e042e10ef976af9b1b834
4
+ data.tar.gz: d293ed839bfaab3257682fcba9c0f86cd878b9b3
5
+ SHA512:
6
+ metadata.gz: b66cebbe7fc507a99bc32ed3a5f25ddaef95bec17d2b97b197fb11f25cbe0a4b0dd73efcddfa09f8c62efdc2cda155681bba5c38f7703a7d0eba9c7468e7965e
7
+ data.tar.gz: 2e5cef0c9eaabaf461194d363ddd25b557f55d989db69ba177f72f5839adef08e85d71fdeee9f8f89fbff19169d3d6d6333882839446f2b29300fc0ef3b08ff1
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Gem Version](https://badge.fury.io/rb/ruby_motion_query.png)](http://badge.fury.io/rb/ruby_motion_query)
8
8
  [![Crusher.io optimized](http://www.crusher.io/repo/infinitered/rmq/badge)](http://www.crusher.io/repo/infinitered/rmq)
9
9
 
10
- A fast, non-polluting, chaining, front-end library. It’s jQuery for [RubyMotion](http://rubymotion.com), plus stylesheets and templates
10
+ A fast, non-polluting, chaining, front-end library. It’s like jQuery for [RubyMotion](http://rubymotion.com). Templates, stylesheets, events, animations, etc.
11
11
 
12
12
  **The [RMQ website][1] is a great place to start.**
13
13
 
@@ -20,21 +20,27 @@ And this 36 minute video: **[Creating an Image Browser app in RubyMotion and Rub
20
20
  ## General
21
21
 
22
22
  ### Some of the very cool features:
23
- - **selecting** (*querying*) views
24
- - **traversal** through view hierarchy (moving around the tree)
25
- - tagging
26
- - **events and gestures**
23
+ - events and gestures
24
+ - view factory
25
+ - stylesheets
26
+ - actions
27
+ - position
28
+ - selecting (_querying views_)
29
+ - templates
30
+ - traversal through view hierarchy (moving around the tree)
27
31
  - animations
28
- - **stylers and stylesheets**
32
+ - tagging
29
33
  - colors
30
34
  - fonts
31
35
  - image utilities
32
36
  - app
33
37
  - device
34
38
 
39
+ [![features](https://ir_wp.s3.amazonaws.com/wp-content/uploads/sites/11/2014/03/rmq_parts-300x231.png)](https://ir_wp.s3.amazonaws.com/wp-content/uploads/sites/11/2014/03/rmq_parts.png)
40
+
35
41
  ----------
36
42
 
37
- **Tested on iOS, not OS X (nor is there any OS X specific code)**
43
+ **RMQ only works in iOS, not OS X**
38
44
 
39
45
  ----------
40
46
 
@@ -61,8 +67,8 @@ Or, if you use **rbenv**:
61
67
 
62
68
  ```
63
69
  gem install ruby_motion_query
64
- rmq create my_app
65
70
  rbenv rehash
71
+ rmq create my_app
66
72
  cd my_app
67
73
  bundle
68
74
  rake
@@ -98,9 +104,19 @@ for **bleeding edge**, add this to your `Gemfile`:
98
104
  - **UIView#rmq_did_create(self_in_rmq)** - *Use rmq_build instead*
99
105
 
100
106
 
107
+ <br />
108
+
101
109
  ## Usage
102
110
 
111
+ ----
112
+
113
+
114
+ <br />
115
+
103
116
  ### Example App
117
+
118
+ ----
119
+
104
120
  *Clone this repo and run the example app to see an example of use.*
105
121
 
106
122
  git clone git@github.com:infinitered/rmq.git
@@ -109,8 +125,14 @@ for **bleeding edge**, add this to your `Gemfile`:
109
125
 
110
126
  The example app works in any orientation, on both iPhone and iPad. Notice how the benchmark popup is done with RMQ, then think about how you'd do that without it.
111
127
 
128
+
129
+
130
+ <br />
131
+
112
132
  ### What's an rmq instance?
113
133
 
134
+ ----
135
+
114
136
  - an rmq instance is an array-like object containing UIViews
115
137
  - rmq() never returns nil. If nothing is selected, it's an empty [ ] array-like
116
138
  object
@@ -124,8 +146,13 @@ The example app works in any orientation, on both iPhone and iPad. Notice how th
124
146
  controller that the view is currently in or to the current screen's
125
147
  controller
126
148
 
149
+
150
+ <br />
151
+
127
152
  ### Basic syntax
128
153
 
154
+ ----
155
+
129
156
  The main command is `rmq` and you use it everywhere. You can rename this by aliasing the methods in `ext.rb`.
130
157
 
131
158
  ```ruby
@@ -179,19 +206,30 @@ rmq(my_view).get
179
206
  rmq(UILabel).get
180
207
  ```
181
208
 
182
- ### Command-line Tool
183
209
 
184
- RMQ provides a command-line tool, mostly for generating files:
210
+ <br />
211
+
212
+ ### Command-line Tool and Generators
213
+
214
+ ----
215
+
216
+
217
+
218
+ Like Rails, RMQ provides a command-line tool, mostly for generating files. **Create a new app**:
219
+
185
220
  ```
186
221
  > rmq create my_app
187
222
  ```
188
223
 
189
- Here are the commands available to you:
224
+ To get all the commands available just do:
225
+
190
226
  ```
191
- > rmq api
192
- > rmq docs
227
+ > rmq
228
+ ```
229
+
230
+ To generate **controllers, models, views**, etc, do the following:
193
231
 
194
- > rmq create my_new_app
232
+ ```
195
233
  > rmq create model foo
196
234
  > rmq create controller bar
197
235
  > rmq create view foo_bar
@@ -201,16 +239,30 @@ Here are the commands available to you:
201
239
  > rmq create collection_view_controller foos
202
240
  > rmq create table_view_controller bars
203
241
 
204
- # To test the create command without actually creating any files, do:
205
242
  > rmq create view my_view dry_run
243
+ ```
244
+
245
+ I recomend you play around with it, do this:
206
246
 
207
- > rmq help
208
247
  ```
248
+ > cd
249
+ > cd Desktop
250
+ > rmq create test_rmq_app
251
+ > cd test_rmq_app
252
+ > rmq create table_view_controller people
253
+ > rmq create view group
254
+ > bundle
255
+ > rake
256
+ ```
257
+
209
258
 
210
259
 
260
+ <br />
211
261
 
212
262
  ### Selectors
213
263
 
264
+ ----
265
+
214
266
  - Constant
215
267
  - :a_tag
216
268
  - :a_style_name
@@ -218,13 +270,18 @@ Here are the commands available to you:
218
270
  - text: 'you can select via attributes also'
219
271
  - :another_tag, UILabel, text: 'an array' <- this is an "or", use .and for and
220
272
 
273
+
274
+ <br />
275
+
221
276
  ### Traversing
222
277
 
278
+ ----
279
+
223
280
  - all
224
281
  - and
225
282
  - not
226
283
  - and_self
227
- - back - rmq(test_view).find(UIImageView).tag(:foo).back.find(UILabel).tag(:bar)
284
+ - back - rmq(test_view).find(UIImageView).tag(:foo).back.find(UILabel).tag(:bar)
228
285
  - find
229
286
  - children
230
287
  - siblings
@@ -239,7 +296,12 @@ Here are the commands available to you:
239
296
  - window # Window of the root_view
240
297
 
241
298
 
299
+ <br />
300
+
242
301
  ### Enumerablish
302
+
303
+ ----
304
+
243
305
  A rmq object is like an enumerable, but each method returns a rmq object instead of a enumerable. For example, these methods:
244
306
 
245
307
  - each
@@ -260,8 +322,13 @@ You can also do **rmq.length** and **rmq[0]** like an array
260
322
 
261
323
  **.to_a** gives you an actual array, so will **.get** (this is preferred)
262
324
 
325
+
326
+ <br />
327
+
263
328
  ### Events and Gestures
264
329
 
330
+ ----
331
+
265
332
  #### On / Off
266
333
 
267
334
  To add an event, use .on, to remove it it, use .off
@@ -292,6 +359,7 @@ In RMQ events and gestures are normalized with the same API. For example removin
292
359
  If you see Event, just remember that's either an event or gesture. I decided to call them Events
293
360
 
294
361
  ##### Type of events and gestures
362
+
295
363
  ```ruby
296
364
  # Events on controls
297
365
  :touch
@@ -355,8 +423,13 @@ TODO, need many examples here
355
423
 
356
424
  The internal store of events in a UIView. It's rmq.events, you won't use it too often
357
425
 
426
+
427
+ <br />
428
+
358
429
  ### Tags
359
430
 
431
+ ----
432
+
360
433
  ```ruby
361
434
  # Add tags
362
435
  rmq(my_view).tag(:your_tag)
@@ -380,7 +453,13 @@ your_view.rmq_data.has_tag?(:foo)
380
453
  your_view.rmq_data.tag_names
381
454
  ```
382
455
 
456
+
457
+ <br />
458
+
383
459
  ### Actions
460
+
461
+ ----
462
+
384
463
  ```ruby
385
464
  rmq(UILabel).attr(text: 'Foo bar')
386
465
  rmq(UILabel).send(:some_method, args)
@@ -391,8 +470,13 @@ rmq(my_view).toggle_enabled
391
470
  rmq(my_text_field).focus # or .become_first_responder
392
471
  ```
393
472
 
473
+
474
+ <br />
475
+
394
476
  ### Subviews - appending, creating, etc
395
477
 
478
+ ----
479
+
396
480
  ```ruby
397
481
  rmq.append(UILabel) # Creates a UILabel in the current controller
398
482
  rmq.append(UILabel, :my_label_style)
@@ -440,8 +524,13 @@ class StoreCell < UITableViewCell
440
524
  end
441
525
  ```
442
526
 
527
+
528
+ <br />
529
+
443
530
  ### Animate
444
531
 
532
+ ----
533
+
445
534
  ```ruby
446
535
  rmq(my_view).animate(
447
536
  duration: 0.3,
@@ -471,8 +560,13 @@ rmq(selectors).animate(
471
560
  # You can pass any options that animateWithDuration allows: options: YOUR_OPTIONS
472
561
  ```
473
562
 
563
+
564
+ <br />
565
+
474
566
  ### Animations
475
567
 
568
+ ----
569
+
476
570
  #### Current animations included:
477
571
 
478
572
  ```ruby
@@ -489,8 +583,13 @@ rmq.animations.start_spinner
489
583
  rmq.animations.stop_spinner
490
584
  ```
491
585
 
586
+
587
+ <br />
588
+
492
589
  ### Color
493
590
 
591
+ ----
592
+
494
593
  ```ruby
495
594
  rmq.color.red
496
595
  rmq.color.from_hex('#ffffff')
@@ -507,8 +606,12 @@ color.pitch_black
507
606
  color.red
508
607
  ```
509
608
 
609
+ <br />
610
+
510
611
  ### Font
511
612
 
613
+ ----
614
+
512
615
  ```ruby
513
616
  rmq.font.system(12)
514
617
  rmq.font_with_name('Helvetica', 18)
@@ -530,25 +633,90 @@ font.medium
530
633
  font.system(14)
531
634
  ```
532
635
 
636
+
637
+ <br />
638
+
533
639
  ### Position (moving, sizing, and nudging)
534
640
 
641
+ ----
642
+
535
643
  ```ruby
536
- # Move/Size changes size and origin of selected view(s)
537
- rmq(your_view).move(l: 20)
538
- rmq(your_view).move(left: 20)
539
- rmq(your_view).move(l: 20, t: 20, w: 100, h: 50)
540
- rmq(your_view).move(left: 20, top: 20, width: 100, height: 50)
541
- rmq(your_view).size(left: 20, top: 20, width: 100, height: 50) # alias
644
+ # Layout, move, or resize selected views
645
+ rmq(your_view).layout(left: 20, top: 20, width: 100, height: 50)
646
+ rmq(your_view).layout(l: 20)
647
+ rmq(your_view).layout(left: 20)
648
+ rmq(your_view).layout(l: 20, t: 20, w: 100, h: 50)
649
+ rmq(your_view).layout(left: 20, top: 20, width: 100, height: 50)
650
+
651
+ rmq(your_view).move(left: 20) # alias for layout
652
+ rmq(your_view).move(l: 30, t: 50) # alias for layout
653
+ rmq(your_view).resize(width: 100, height: 50) # alias for layout
542
654
 
543
655
  # Nudge pushes them in a direction
544
656
  rmq(your_view).nudge(d: 20)
545
657
  rmq(your_view).nudge(down: 20)
546
658
  rmq(your_view).nudge(l: 20, r: 20, u: 100, d: 50)
547
659
  rmq(your_view).nudge(left: 20, right: 20, up: 100, down: 50)
660
+
661
+ # Distribute
662
+ rmq(UIButton).distribute
663
+ rmq(UIButton).distribute(:vertical)
664
+ rmq(UIButton).distribute(:horizontal)
665
+ rmq(UIButton).distribute(:vertical, margin: 20)
666
+ rmq(my_view, my_other_view, third_view).distribute(:vertical, margin: 10)
667
+ rmq(UIButton).distribute(:vertical, margins: [5,5,10,5,10,5,10,20])
548
668
  ```
549
669
 
670
+ <br />
671
+
550
672
  ### Images
551
673
 
674
+ ----
675
+
676
+
677
+ RMQ provides various features for dealing with images.
678
+
679
+ If you want to load an image from your **/resources** folder (_which is where they should be_), you can either load it and cache it (**imageNamed**) or load it and not cache it (**NSBundle.mainBundle.pathForResource**):
680
+
681
+ ```ruby
682
+ rmq.image.resource('foo') # /resources/foo@2x.png
683
+ rmq.image.resource('foo', cached: false)
684
+ # In a stylesheet
685
+ st.background_image = image.resource('foo')
686
+ ```
687
+
688
+ **Capped images**
689
+
690
+ Sometimes when you apply a background_image to a view you want the image to stretch to the size of the view without stretching the corners of the image, for example if you're making a rounded button. The SDK has a nice feature for this, called UIImage#resizableImageWithCapInsets. It stretches the center of your image, but not the corners.
691
+
692
+ Let's say you want to create this, like we did in [Temple](http://app.temple.cx/):
693
+
694
+ ![Bar](https://ir_wp.s3.amazonaws.com/wp-content/uploads/sites/18/2014/03/bar.png)
695
+
696
+ The red bar grows horizontally. But it has rounded caps. So we created this image ![Cap image](https://ir_wp.s3.amazonaws.com/wp-content/uploads/sites/18/2014/03/bar_poor@2x.png), which is the caps, plus one pixel to stretch. Here it is blown up and I dimmed the 4 caps:
697
+
698
+ ![Cap image](https://ir_wp.s3.amazonaws.com/wp-content/uploads/sites/18/2014/03/blown_up.png)
699
+
700
+ Basically just the center line of it stretches, the other 4 quadrants do not. RMQ makes this very easy. You create a UIImageView, then in the style (or anywhere) you set the image like so:
701
+
702
+ ```ruby
703
+ rmq.append(UIImageView, :your_style)
704
+ # Then in your style
705
+ st.image = image.resource_resizable('your_image', top: 4, left: 4, right: 4, bottom: 4)
706
+ ```
707
+
708
+ The top, left, etc, tell which parts of the image not to stretch. You can now resize your view and it will look great.
709
+
710
+ **Snapshot of a view**
711
+
712
+ Lastly you can get an image of a view, meaning a "screenshot" of it:
713
+
714
+ ```ruby
715
+ my_image_view.image = rmq.image.from_view(some_view)
716
+ ```
717
+
718
+ **Other examples**
719
+
552
720
  ```ruby
553
721
  RubyMotionQuery::ImageUtils.resource('logo')
554
722
  rmq.image.resource('logo')
@@ -564,7 +732,13 @@ rmq.image.from_view(my_view)
564
732
  image.resource('logo')
565
733
  ```
566
734
 
735
+
736
+ <br />
737
+
567
738
  ### App
739
+
740
+ ----
741
+
568
742
  ```ruby
569
743
  RubyMotionQuery::App.window
570
744
  rmq.app.window
@@ -580,8 +754,13 @@ rmq.app.resource_path
580
754
  rmq.app.document_path
581
755
  ```
582
756
 
757
+
758
+ <br />
759
+
583
760
  ### Device
584
761
 
762
+ ----
763
+
585
764
  ```ruby
586
765
  RubyMotionQuery::Device.screen
587
766
  rmq.device.screen
@@ -599,7 +778,13 @@ rmq.device.landscape?
599
778
  rmq.device.portrait?
600
779
  ```
601
780
 
781
+
782
+ <br />
783
+
602
784
  ### Format
785
+
786
+ ----
787
+
603
788
  A performant way to format numbers and dates.
604
789
 
605
790
  ```ruby
@@ -610,8 +795,13 @@ rmq.format.date_formatter(your_format_here) # returns cached date formatter
610
795
  ```
611
796
  See <http://www.unicode.org/reports/tr35/tr35-19.html#Date_Format_Patterns> for more information about date format strings.
612
797
 
798
+
799
+ <br />
800
+
613
801
  ### Utils
614
802
 
803
+ ----
804
+
615
805
  These are mostly used internally by rmq.
616
806
 
617
807
  ```ruby
@@ -622,8 +812,13 @@ RubyMotionQuery::RMQ.view_to_s(view)
622
812
  RubyMotionQuery::RMQ.weak_ref(foo)
623
813
  ```
624
814
 
815
+
816
+ <br />
817
+
625
818
  ### Pollution
626
819
 
820
+ ----
821
+
627
822
  The following are the only pollution in RMQ
628
823
 
629
824
  - UIView
@@ -635,17 +830,29 @@ The following are the only pollution in RMQ
635
830
  - Object
636
831
  - rmq
637
832
 
833
+
834
+ <br />
835
+
638
836
  ### Console Fun
639
837
 
640
- rmq.log :tree
641
- rmq.all.log
642
- rmq.all.log :wide
643
- rmq(UIView).show
644
- rmq(UILabel).animations.blink
645
- rmq(UIButton).nudge l: 10
838
+ ----
839
+
840
+ ```ruby
841
+ rmq.log :tree
842
+ rmq.all.log
843
+ rmq.all.log :wide
844
+ rmq(UIView).show
845
+ rmq(UILabel).animations.blink
846
+ rmq(UIButton).nudge l: 10
847
+ ```
848
+
849
+
850
+ <br />
646
851
 
647
852
  ### A recommended project structure
648
853
 
854
+ ----
855
+
649
856
  - app
650
857
  - controllers
651
858
  - your_controller.rb
@@ -672,8 +879,13 @@ The following are the only pollution in RMQ
672
879
  - stylers
673
880
  - views
674
881
 
882
+
883
+ <br />
884
+
675
885
  ### Debugging
676
886
 
887
+ ----
888
+
677
889
  Adding rmq_debug=true to rake turns on some debugging features that are too slow or verbose to include in a normal build. It's great for normal use in the simulator, but you'll want to leave it off if you're measuring performance.
678
890
  ```
679
891
  rake rmq_debug=true
@@ -702,10 +914,13 @@ rmq(UILabel).animations.blink
702
914
  rmq(Section).parent.children.log
703
915
  ```
704
916
 
705
- ----------
917
+
918
+ <br />
706
919
 
707
920
  ### Styles and stylesheets
708
921
 
922
+ ----
923
+
709
924
  A very lightweight style system, designed for a low memory footprint, fast startup, and fast operation. Most everything is done at compile-time, as it's all just ruby code. Low magic.
710
925
 
711
926
  **You don't have to use this system, you can use Teacup instead**, or whatever you like. RMQ works great without using the style system.
@@ -718,7 +933,7 @@ class MainController < UIViewController
718
933
  def viewDidLoad
719
934
  super
720
935
 
721
- rmq.stylesheet = MainStyleSheet
936
+ rmq.stylesheet = MainStyleSheet # Each controller has its own stylesheet
722
937
  view.rmq.apply_style :root_view
723
938
 
724
939
  @title_label = rmq.append(UILabel, :title_label).get
@@ -1099,8 +1314,12 @@ end
1099
1314
  You can also include all of your custom stylers in one file, which works well if you don't have a lot.
1100
1315
 
1101
1316
 
1317
+ <br />
1318
+
1102
1319
  ### Creating your own views
1103
1320
 
1321
+ ----
1322
+
1104
1323
  RMQ calls 3 methods when you create, append, or build a view using rmq. rmq_build is the one you most want to use
1105
1324
  ```ruby
1106
1325
  def rmq_build
@@ -1142,11 +1361,15 @@ end
1142
1361
  rmq.append(YourView, :your_style)
1143
1362
  ```
1144
1363
 
1364
+
1365
+ <br />
1366
+
1145
1367
  ### Future features
1146
1368
 
1369
+ ----
1370
+
1147
1371
  Current roadmap:
1148
1372
 
1149
- - v0.5 new view_controller system: which solves the #1 problem in rmq: having to pass rmq around in things like cells. rmq command will work everywhere
1150
1373
  - v0.6 new frame system: I’ve already designed this, I just have to implement it and use it in the real world and tweak. This is going to be very cool. It adds to the existing frame system. It doesn’t replace constraints, but rather gives you almost all the features you need without the complexity of constraints.
1151
1374
  - v0.6.5 templates and stylers all finished
1152
1375
  - v0.6.7 performance improvements
@@ -1172,7 +1395,12 @@ Random future features that I plan on adding
1172
1395
  - add rmq.help with basic help for when you're in repl
1173
1396
 
1174
1397
 
1175
- ## Contact
1398
+
1399
+ <br />
1400
+
1401
+ ### Contact
1402
+
1403
+ ----
1176
1404
 
1177
1405
  created by **Todd Werth** ([http://toddwerth.com](http://toddwerth.com))
1178
1406
 
@@ -1186,11 +1414,21 @@ with help from the team at **InfiniteRed** ([http://infinitered.com](http://infi
1186
1414
  - [github](https://github.com/infinitered)
1187
1415
 
1188
1416
 
1189
- ## License
1417
+
1418
+ <br />
1419
+
1420
+ ### License
1421
+
1422
+ ----
1190
1423
 
1191
1424
  RMQ is available under the MIT license. See the LICENSE file for more info.
1192
1425
 
1193
- ## Contributing
1426
+
1427
+ <br />
1428
+
1429
+ ### Contributing
1430
+
1431
+ ----
1194
1432
 
1195
1433
  1. Fork it
1196
1434
  2. Create your feature branch (`git checkout -b my-new-feature`)
@@ -312,13 +312,13 @@ module RubyMotionQuery
312
312
  protected
313
313
  def extract_views_from_selectors(view_container, working_selectors)
314
314
  unless RMQ.is_blank?(working_selectors)
315
- working_selectors.each do |selector|
316
- if selector.is_a?(UIView)
317
- view_container << working_selectors.delete(selector)
315
+ working_selectors.delete_if do |selector|
316
+ if selector.is_a?(UIView)
317
+ view_container << selector
318
+ true
318
319
  end
319
320
  end
320
321
  end
321
- [view_container, working_selectors]
322
322
  end
323
323
 
324
324
  def all_subviews_for(view)
@@ -69,13 +69,17 @@ module RubyMotionQuery
69
69
  Device.orientation == :portrait || Device.orientation == :unknown
70
70
  end
71
71
 
72
- ORIENTATIONS = {
73
- UIDeviceOrientationUnknown => :unkown,
72
+ def orientations
73
+ ORIENTATIONS
74
+ end
75
+
76
+ ORIENTATIONS = {
77
+ UIDeviceOrientationUnknown => :unknown,
74
78
  UIDeviceOrientationPortrait => :portrait,
75
79
  UIDeviceOrientationPortraitUpsideDown => :portrait_upside_down,
76
80
  UIDeviceOrientationLandscapeLeft => :landscape_Left,
77
81
  UIDeviceOrientationLandscapeRight => :landscape_right,
78
- UIDeviceOrientationFaceUp => :face_up,
82
+ UIDeviceOrientationFaceUp => :face_up,
79
83
  UIDeviceOrientationFaceDown => :face_down
80
84
  }
81
85
 
@@ -4,7 +4,7 @@ module RubyMotionQuery
4
4
  #
5
5
  # @return [RMQ]
6
6
  #
7
- # on(event_or_gesture, options) do |sender, event|
7
+ # on(event_or_gesture, options) do |sender, rmq_event|
8
8
  # # your code when event fires
9
9
  # end
10
10
  #
@@ -35,6 +35,11 @@ module RubyMotionQuery
35
35
  end
36
36
  end
37
37
 
38
+ # @example
39
+ # image = rmq.image.resource_resizable('foo', top: 4, left: 4, right: 4, bottom: 4)
40
+ # or in styler
41
+ # st.image = image.resource_resizable('foo', top: 4, left: 4, right: 4, bottom: 4)
42
+ #
38
43
  # @return [UIImage]
39
44
  def resource_resizable(file_base_name, opts)
40
45
  # TODO, also alloow short syntax, t: instead of top: etc
@@ -1,8 +1,13 @@
1
1
  module RubyMotionQuery
2
2
  class RMQ
3
3
 
4
+ # @example
5
+ # rmq.append(UILabel).layout(l: 10, t: 100, w: 100, h: 18)
6
+ # rmq(my_view).move(l: 10, t: 100)
7
+ # rmq(my_view).resize(h: 10, w: 100)
8
+ #
4
9
  # @return [RMQ]
5
- def move(opts)
10
+ def layout(opts)
6
11
  # TODO, add centered and from_bottom and from_top, and bottom and top
7
12
  # TODO, add animate option
8
13
  left = opts[:left] || opts[:l] || opts[:x]
@@ -19,7 +24,8 @@ module RubyMotionQuery
19
24
 
20
25
  self
21
26
  end
22
- alias :resize :move
27
+ alias :move :layout
28
+ alias :resize :layout
23
29
 
24
30
  # @return [RMQ]
25
31
  def nudge(opts)
@@ -37,6 +43,15 @@ module RubyMotionQuery
37
43
  self
38
44
  end
39
45
 
46
+ # @example
47
+ # rmq(UIButton).distribute
48
+ # rmq(UIButton).distribute(:vertical)
49
+ # rmq(UIButton).distribute(:horizontal)
50
+ # rmq(UIButton).distribute(:vertical, margin: 20)
51
+ # rmq(my_view, my_other_view, third_view).distribute(:vertical, margin: 10)
52
+ # rmq(UIButton).distribute(:vertical, margins: [5,5,10,5,10,5,10,20])
53
+ #
54
+ # @return [RMQ]
40
55
  def distribute(type = :vertical, params = {})
41
56
  return 0 if selected.length == 0
42
57
 
@@ -0,0 +1,33 @@
1
+ module RubyMotionQuery
2
+ module Stylers
3
+ module Protocols
4
+
5
+ # UITExtInputTraits protocol
6
+ module UITextInputTraits
7
+ def autocapitalization_type ; view.autocapitalizationType ; end
8
+ def autocapitalization_type=(v) ; view.autocapitalizationType = v ; end
9
+
10
+ def autocorrection_type ; view.autocorrectionType ; end
11
+ def autocorrection_type=(v) ; view.autocorrectionType = v ; end
12
+
13
+ def enables_return_key_automatically ; view.enablesReturnKeyAutomatically ; end
14
+ def enables_return_key_automatically=(v) ; view.enablesReturnKeyAutomatically = v ; end
15
+
16
+ def keyboard_appearance ; view.keyboardAppearance ; end
17
+ def keyboard_appearance=(v) ; view.keyboardAppearance = v ; end
18
+
19
+ def keyboard_type ; view.keyboardType ; end
20
+ def keyboard_type=(v) ; view.keyboardType = v ; end
21
+
22
+ def return_key_type ; view.returnKeyType ; end
23
+ def return_key_type=(v) ; view.returnKeyType = v ; end
24
+
25
+ def secure_text_entry ; view.secureTextEntry ; end
26
+ def secure_text_entry=(v) ; view.secureTextEntry = v ; end
27
+
28
+ def spell_checking_type ; view.spellCheckingType ; end
29
+ def spell_checking_type=(v) ; view.spellCheckingType = v ; end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,6 +1,6 @@
1
1
  module RubyMotionQuery
2
2
  module Stylers
3
- class UIButtonStyler < UIControlStyler
3
+ class UIButtonStyler < UIControlStyler
4
4
 
5
5
  def text=(value)
6
6
  @view.setTitle(value, forState: UIControlStateNormal)
@@ -45,6 +45,34 @@ module RubyMotionQuery
45
45
  @view.setBackgroundImage value, forState: UIControlStateHighlighted
46
46
  end
47
47
 
48
+ def border_color=(value)
49
+ if value.is_a?(UICachedDeviceRGBColor)
50
+ @view.layer.setBorderColor(value.CGColor)
51
+ else
52
+ @view.layer.setBorderColor value
53
+ end
54
+ end
55
+
56
+ def border_color
57
+ @view.layer.borderColor
58
+ end
59
+
60
+ def corner_radius=(value = 2)
61
+ @view.layer.cornerRadius = value
62
+ end
63
+
64
+ def corner_radius
65
+ @view.layer.cornerRadius
66
+ end
67
+
68
+ def border_width=(value)
69
+ @view.layer.borderWidth = value
70
+ end
71
+
72
+ def border_width
73
+ @view.layer.borderWidth
74
+ end
75
+
48
76
  end
49
77
  end
50
78
  end
@@ -44,14 +44,6 @@ module RubyMotionQuery
44
44
  def adjusts_font_size
45
45
  @view.adjustsFontSizeToFitWidth
46
46
  end
47
-
48
- TEXT_ALIGNMENTS = {
49
- left: NSTextAlignmentLeft,
50
- center: NSTextAlignmentCenter,
51
- right: NSTextAlignmentRight,
52
- justified: NSTextAlignmentJustified,
53
- natural: NSTextAlignmentNatural
54
- }
55
47
  end
56
48
 
57
49
  end
@@ -11,6 +11,12 @@ module RubyMotionQuery
11
11
  def direction_lock=(value) ; @view.directionalLockEnabled = value ; end
12
12
  def direction_lock ; @view.isDirectionalLockEnabled ; end
13
13
 
14
+ def content_offset=(value) ; @view.contentOffset = value ; end
15
+ def content_offset ; @view.contentOffset ; end
16
+
17
+ def content_inset=(value) ; @view.contentInset = value ; end
18
+ def content_inset ; @view.contentInset ; end
19
+
14
20
  end
15
21
 
16
22
  end
@@ -1,8 +1,82 @@
1
1
  module RubyMotionQuery
2
2
  module Stylers
3
+ class UITextFieldStyler < UIControlStyler
4
+ include Protocols::UITextInputTraits
3
5
 
4
- class UITextFieldStyler < UIControlStyler
5
- end
6
+ # Accessing the Text Attributes
7
+ def text ; view.text ; end
8
+ def text=(v) ; view.text = v ; end
9
+
10
+ def attributed_text ; view.attributedText ; end
11
+ def attributed_text=(v) ; view.attributedText = v ; end
12
+
13
+ def placeholder ; view.placeholder ; end
14
+ def placeholder=(v) ; view.placeholder = v ; end
15
+
16
+ def attributed_placeholder ; view.attributedPlaceholder ; end
17
+ def attributed_placeholder=(v) ; view.attributedPlaceholder = v ; end
18
+
19
+ def default_text_attributes ; view.defaultTextAttributes ; end
20
+ def default_text_attributes=(v) ; view.defaultTextAttributes = v ; end
21
+
22
+ def font ; view.font ; end
23
+ def font=(v) ; view.font = v ; end
24
+
25
+ def text_color ; view.textColor ; end
26
+ def text_color=(v) ; view.textColor = v ; end
27
+ alias :color :text_color
28
+
29
+ def text_alignment ; view.textAlignment ; end
30
+ def text_alignment=(v) ; view.textAlignment = TEXT_ALIGNMENTS[v] || v ; end
31
+
32
+ def typing_attributes ; view.typingAttributes ; end
33
+ def typing_attributes=(v) ; view.typingAttributes = v ; end
34
+
35
+ # Sizing the Text Field's Text
36
+ def adjusts_font_size_to_fit_width ; view.adjustsFontSizeToFitWidth ; end
37
+ def adjusts_font_size_to_fit_width=(v) ; view.adjustsFontSizeToFitWidth = v ; end
38
+
39
+ def minimum_font_size ; view.minimumFontSize ; end
40
+ def minimum_font_size=(v) ; view.minimumFontSize = v ; end
41
+
42
+ # Managing the Eiting Behavior
43
+ def editing ; view.editing ; end
44
+ def editing=(v) ; view.editing = v ; end
6
45
 
46
+ def clears_on_begin_editing ; view.clearsOnBeginEditing ; end
47
+ def clears_on_begin_editing=(v) ; view.clearsOnBeginEditing = v ; end
48
+
49
+ def clears_on_insertion ; view.clearsOnInsertion ; end
50
+ def clears_on_insertion=(v) ; view.clearsOnInsertion = v ; end
51
+
52
+ def allows_editing_text_attributes ; view.allowsEditingTextAttributes ; end
53
+ def allows_editing_text_attributes=(v) ; view.allowsEditingTextAttributes = v ; end
54
+
55
+ # Setting the View's Background Appearance
56
+ def border_style ; view.borderStyle ; end
57
+ def border_style=(v) ; view.borderStyle = v ; end
58
+
59
+ def background ; view.background ; end
60
+ def background=(v) ; view.background = v ; end
61
+
62
+ def disabled_background ; view.disabledBackground ; end
63
+ def disabled_background=(v) ; view.disabledBackground = v ; end
64
+
65
+ # managing overlay views
66
+ def clear_button_mode ; view.clearButtonMode ; end
67
+ def clear_button_mode=(v) ; view.clearButtonMode = v ; end
68
+
69
+ def left_view ; view.leftView ; end
70
+ def left_view=(v) ; view.leftView = v ; end
71
+
72
+ def left_view_mode ; view.leftViewMode ; end
73
+ def left_view_mode=(v) ; view.leftViewMode = v ; end
74
+
75
+ def right_view ; view.rightView ; end
76
+ def right_view=(v) ; view.rightView = v ; end
77
+
78
+ def right_view_mode ; view.rightViewMode ; end
79
+ def right_view_mode=(v) ; view.rightViewMode = v ; end
80
+ end
7
81
  end
8
82
  end
@@ -1,6 +1,14 @@
1
1
  module RubyMotionQuery
2
2
  module Stylers
3
3
 
4
+ TEXT_ALIGNMENTS = {
5
+ left: NSTextAlignmentLeft,
6
+ center: NSTextAlignmentCenter,
7
+ right: NSTextAlignmentRight,
8
+ justified: NSTextAlignmentJustified,
9
+ natural: NSTextAlignmentNatural
10
+ }
11
+
4
12
  # When you create a styler, always inherit UIViewStyler
5
13
  class UIViewStyler
6
14
  def initialize(view)
@@ -1,5 +1,5 @@
1
1
  module RubyMotionQuery
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.6"
3
3
 
4
4
  class RMQ
5
5
  def version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_motion_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Werth
@@ -9,34 +9,34 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-25 00:00:00.000000000 Z
12
+ date: 2014-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bacon
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ! '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ! '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ! '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ! '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  description: RubyMotionQuery - RMQ - A fast, non-magical, non-polluting, jQuery-like
@@ -47,8 +47,9 @@ executables:
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
- - README.md
51
50
  - LICENSE
51
+ - README.md
52
+ - bin/rmq
52
53
  - lib/ruby_motion_query.rb
53
54
  - motion/ext.rb
54
55
  - motion/ruby_motion_query/actions.rb
@@ -68,6 +69,7 @@ files:
68
69
  - motion/ruby_motion_query/image.rb
69
70
  - motion/ruby_motion_query/position.rb
70
71
  - motion/ruby_motion_query/selectors.rb
72
+ - motion/ruby_motion_query/stylers/protocols/ui_text_input_traits.rb
71
73
  - motion/ruby_motion_query/stylers/ui_button_styler.rb
72
74
  - motion/ruby_motion_query/stylers/ui_control_styler.rb
73
75
  - motion/ruby_motion_query/stylers/ui_date_picker_styler.rb
@@ -117,7 +119,6 @@ files:
117
119
  - templates/view/app/stylesheets/name_stylesheet.rb
118
120
  - templates/view/app/views/name.rb
119
121
  - templates/view/spec/views/name.rb
120
- - bin/rmq
121
122
  homepage: http://infinitered.com/rmq
122
123
  licenses:
123
124
  - MIT
@@ -128,19 +129,18 @@ require_paths:
128
129
  - lib
129
130
  required_ruby_version: !ruby/object:Gem::Requirement
130
131
  requirements:
131
- - - ! '>='
132
+ - - ">="
132
133
  - !ruby/object:Gem::Version
133
134
  version: '0'
134
135
  required_rubygems_version: !ruby/object:Gem::Requirement
135
136
  requirements:
136
- - - ! '>='
137
+ - - ">="
137
138
  - !ruby/object:Gem::Version
138
139
  version: '0'
139
140
  requirements: []
140
141
  rubyforge_project:
141
- rubygems_version: 2.0.7
142
+ rubygems_version: 2.2.2
142
143
  signing_key:
143
144
  specification_version: 4
144
145
  summary: RubyMotionQuery - RMQ
145
146
  test_files: []
146
- has_rdoc: