ruby_motion_query 0.5.6 → 0.5.7
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 +4 -4
- data/README.md +185 -106
- data/bin/rmq +5 -4
- data/motion/ruby_motion_query/animations.rb +49 -0
- data/motion/ruby_motion_query/app.rb +10 -2
- data/motion/ruby_motion_query/device.rb +4 -3
- data/motion/ruby_motion_query/stylers/ui_button_styler.rb +0 -28
- data/motion/ruby_motion_query/stylers/ui_page_control_styler.rb +13 -1
- data/motion/ruby_motion_query/stylers/ui_scroll_view_styler.rb +16 -0
- data/motion/ruby_motion_query/stylers/ui_table_view_cell_styler.rb +9 -0
- data/motion/ruby_motion_query/stylers/ui_text_view_styler.rb +4 -2
- data/motion/ruby_motion_query/stylers/ui_view_styler.rb +57 -5
- data/motion/ruby_motion_query/stylesheet.rb +16 -10
- data/motion/ruby_motion_query/subviews.rb +9 -2
- data/motion/ruby_motion_query/utils.rb +1 -0
- data/motion/ruby_motion_query/version.rb +1 -1
- data/templates/table_view_controller/app/controllers/name_controller.rb +3 -0
- data/templates/table_view_controller/app/views/name_cell.rb +10 -9
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e5ff3ba1784ba4853de389ef894f7f88133be26
|
4
|
+
data.tar.gz: 3c8c609b0d461f2e381b5a17598eed68548cda93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b66320409149b8836ae9cbb1ef7453b365ffe9961216254a1c21429b5000df8b397d0390160a94f6b5ce0f12f1016e2c802fea0c457e4b03264f2f40dc0fedbb
|
7
|
+
data.tar.gz: cbc448fef154692862a6b52b477bab49a3fa9d270fde94140010089990e1521c847c241187faecf25f7c782ba4aaad87c08ad24c95e85c4b47ab5ed4ebb656a7
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ A fast, non-polluting, chaining, front-end library. It’s like jQuery for [Ruby
|
|
13
13
|
|
14
14
|
Also this 6 minute **[intro video](https://www.youtube.com/watch?v=2ihGjCI2DYE)**
|
15
15
|
|
16
|
-
And this 36 minute video: **[Creating an Image Browser app in RubyMotion and RubyMotionQuery](
|
16
|
+
And this 36 minute video: **[Creating an Image Browser app in RubyMotion and RubyMotionQuery](http://infinitered.com/2013/12/26/creating-an-image-browser-app-in-rubymotion-and-rubymotionquery-rmq/)**
|
17
17
|
|
18
18
|
----------
|
19
19
|
|
@@ -102,7 +102,7 @@ for **bleeding edge**, add this to your `Gemfile`:
|
|
102
102
|
|
103
103
|
- **RubyMotionQuery::RMQ.weak_ref(object)** - no longer needed post RubyMotion 2.18
|
104
104
|
- **UIView#rmq_did_create(self_in_rmq)** - *Use rmq_build instead*
|
105
|
-
|
105
|
+
- **RubyMotionQuery::RMQ.weak_ref_to_strong_ref(object)** - no longer needed post RubyMotion 2.24
|
106
106
|
|
107
107
|
<br />
|
108
108
|
|
@@ -119,9 +119,9 @@ for **bleeding edge**, add this to your `Gemfile`:
|
|
119
119
|
|
120
120
|
*Clone this repo and run the example app to see an example of use.*
|
121
121
|
|
122
|
-
|
123
|
-
|
124
|
-
|
122
|
+
git clone git@github.com:infinitered/rmq.git
|
123
|
+
cd rmq
|
124
|
+
rake
|
125
125
|
|
126
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.
|
127
127
|
|
@@ -256,7 +256,6 @@ I recomend you play around with it, do this:
|
|
256
256
|
```
|
257
257
|
|
258
258
|
|
259
|
-
|
260
259
|
<br />
|
261
260
|
|
262
261
|
### Selectors
|
@@ -270,6 +269,94 @@ I recomend you play around with it, do this:
|
|
270
269
|
- text: 'you can select via attributes also'
|
271
270
|
- :another_tag, UILabel, text: 'an array' <- this is an "or", use .and for and
|
272
271
|
|
272
|
+
The more common use is to select any view or views you have assigned to variables, then perform actions on them. For example:
|
273
|
+
|
274
|
+
```ruby
|
275
|
+
view_1 = UIView.alloc.initWithFrame([[10,10],[100, 10]])
|
276
|
+
view_2 = UIView.alloc.initWithFrame([[10,20],[100, 10]])
|
277
|
+
@view_3 = rmq.append(UIView, :some_style).get
|
278
|
+
|
279
|
+
rmq(view_1).layout(l: 20, t: 40, w: 80, h: 20)
|
280
|
+
|
281
|
+
rmq(view_1, view_2, @view_3).hide
|
282
|
+
a = [view_1, view_2, @view_3]
|
283
|
+
|
284
|
+
rmq(a).distribute(:vertical, margin: 10)
|
285
|
+
|
286
|
+
rmq(a).on(:tap) do |sender|
|
287
|
+
puts 'Tapped'
|
288
|
+
end
|
289
|
+
```
|
290
|
+
|
291
|
+
|
292
|
+
<br />
|
293
|
+
|
294
|
+
### Subviews - appending, creating, etc
|
295
|
+
|
296
|
+
----
|
297
|
+
|
298
|
+
* build: takes an existing view, applies the style if it exists, then calls rmq_build method
|
299
|
+
* create: creates the view when given the class, or uses an existing view you pass it, then does a [build]
|
300
|
+
* append: [create] + appends the view to the end of the subview tree or to then end of the children of a view (if called on an rmq object with that view in it)
|
301
|
+
* prepend: Same as [append], but inserts the view to beginning of the subview tree (overall or view's children)
|
302
|
+
* insert: Same as [append], but inserts the view at the index of the subview tree (overall or view's children)
|
303
|
+
|
304
|
+
```ruby
|
305
|
+
rmq.append(UILabel) # Creates a UILabel in the current controller
|
306
|
+
rmq.append(UILabel, :my_label_style)
|
307
|
+
rmq.append(UILabel.alloc.initWithFrame([[0,0],[10,10]]), :my_label_style)
|
308
|
+
|
309
|
+
rmq(my_view).append(UIButton)
|
310
|
+
rmq(my_view).remove
|
311
|
+
rmq(my_vuew).children.remove
|
312
|
+
|
313
|
+
rmq(UIView).append(UIButton, :delete_me) # A custom button for all views
|
314
|
+
|
315
|
+
rmq.unshift(UILabel) # Adds to index 0 of the subviews
|
316
|
+
rmq.unshift(UILabel, :my_style)
|
317
|
+
rmq.insert(UILabel, at_index: 2)
|
318
|
+
rmq.insert(UILabel, at_index: 2, style: :my_style)
|
319
|
+
rmq.insert(UILabel, below_view: some_view_of_mine)
|
320
|
+
rmq.insert(UILabel, below_view: some_view_of_mine, style: :my_style)
|
321
|
+
|
322
|
+
rmq(my_view).parent # .superview works too
|
323
|
+
rmq(my_view).parents # all parents up the tree, up to the root
|
324
|
+
rmq(my_view).children
|
325
|
+
rmq(my_view).find # children, grandchildren, etc
|
326
|
+
rmq.root_view
|
327
|
+
rmq.view_controller
|
328
|
+
```
|
329
|
+
|
330
|
+
#### Create a view
|
331
|
+
If you want to create a view but not add it to the subviews of any other view, you can
|
332
|
+
use #create. It's basically #append without the actual appending.
|
333
|
+
This is very handy for stuff like table cells:
|
334
|
+
|
335
|
+
```ruby
|
336
|
+
# In your controller that is a delegate for a UITableView
|
337
|
+
def tableView(table_view, cellForRowAtIndexPath: index_path)
|
338
|
+
cell = table_view.dequeueReusableCellWithIdentifier(CELL_IDENTIFIER) || begin
|
339
|
+
rmq.create(StoreCell, :store_cell, reuse_identifier: CELL_IDENTIFIER).get
|
340
|
+
|
341
|
+
# If you want to change the style of the cell, you can do something like this:
|
342
|
+
# rmq.create(StoreCell, :store_cell, reuse_identifier: CELL_IDENTIFIER, cell_style: UITableViewCellStyleSubtitle).get
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
# Your cell
|
347
|
+
class StoreCell < UITableViewCell
|
348
|
+
def rmq_build
|
349
|
+
q = rmq(self.contentView)
|
350
|
+
q.append(UILabel, :title_label) # <- this works even though this object isn't in a controller
|
351
|
+
|
352
|
+
# Use built in views, this assumes you're using the UITableViewCellStyleSubtitle style for the cell
|
353
|
+
q.build(self.textLabel, :cell_label)
|
354
|
+
q.build(self.imageView, :cell_image)
|
355
|
+
q.build(self.detailTextLabel, :cell_label_detail)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
```
|
359
|
+
|
273
360
|
|
274
361
|
<br />
|
275
362
|
|
@@ -277,23 +364,33 @@ I recomend you play around with it, do this:
|
|
277
364
|
|
278
365
|
----
|
279
366
|
|
367
|
+
Moving around the subview tree.
|
368
|
+
|
369
|
+
Used often:
|
370
|
+
|
371
|
+
- view_controller
|
372
|
+
- root_view # View of the view_controller
|
373
|
+
|
374
|
+
The rest of traversing isn't used too often, but when you need it, it's super handy. The most common methods used are:
|
375
|
+
|
376
|
+
- window # Window of the root_view
|
280
377
|
- all
|
378
|
+
- closest
|
379
|
+
- find
|
380
|
+
|
381
|
+
These are less common:
|
382
|
+
|
281
383
|
- and
|
282
384
|
- not
|
283
385
|
- and_self
|
284
|
-
- back -
|
285
|
-
- find
|
386
|
+
- back - _rmq(test_view).find(UIImageView).tag(:foo).back.find(UILabel).tag(:bar)_
|
286
387
|
- children
|
287
388
|
- siblings
|
288
389
|
- next
|
289
390
|
- prev
|
290
|
-
- closest
|
291
391
|
- parent
|
292
392
|
- parents
|
293
393
|
- filter
|
294
|
-
- view_controller
|
295
|
-
- root_view # View of the view_controller
|
296
|
-
- window # Window of the root_view
|
297
394
|
|
298
395
|
|
299
396
|
<br />
|
@@ -323,6 +420,70 @@ You can also do **rmq.length** and **rmq[0]** like an array
|
|
323
420
|
**.to_a** gives you an actual array, so will **.get** (this is preferred)
|
324
421
|
|
325
422
|
|
423
|
+
|
424
|
+
<br />
|
425
|
+
|
426
|
+
### Layout/Frame System & Position
|
427
|
+
|
428
|
+
----
|
429
|
+
|
430
|
+
|
431
|
+
```
|
432
|
+
Options for layout, move, and frame:
|
433
|
+
|
434
|
+
:full
|
435
|
+
:left :l :from_right :fr
|
436
|
+
:top :t :from_right :fb
|
437
|
+
:width :w
|
438
|
+
:height :h
|
439
|
+
|
440
|
+
Options for nudge:
|
441
|
+
|
442
|
+
:left :l
|
443
|
+
:right :r
|
444
|
+
:up :u
|
445
|
+
:down :d
|
446
|
+
|
447
|
+
Values for each option can be:
|
448
|
+
|
449
|
+
signed int
|
450
|
+
float
|
451
|
+
```
|
452
|
+
|
453
|
+
```ruby
|
454
|
+
# In a style
|
455
|
+
def some_style(st)
|
456
|
+
st.frame = {l: 20, t: 20, w: 100, h: 50}
|
457
|
+
end
|
458
|
+
|
459
|
+
|
460
|
+
# Layout, move, or resize selected views
|
461
|
+
rmq(your_view).layout(left: 20, top: 20, width: 100, height: 50)
|
462
|
+
rmq(your_view).layout(l: 20)
|
463
|
+
rmq(your_view).layout(left: 20)
|
464
|
+
rmq(your_view).layout(l: 20, t: 20, w: 100, h: 50)
|
465
|
+
rmq(your_view).layout(left: 20, top: 20, width: 100, height: 50)
|
466
|
+
|
467
|
+
rmq(your_view).move(left: 20) # alias for layout
|
468
|
+
rmq(your_view).move(l: 30, t: 50) # alias for layout
|
469
|
+
rmq(your_view).resize(width: 100, height: 50) # alias for layout
|
470
|
+
|
471
|
+
# Nudge pushes them in a direction
|
472
|
+
rmq(your_view).nudge(d: 20)
|
473
|
+
rmq(your_view).nudge(down: 20)
|
474
|
+
rmq(your_view).nudge(l: 20, r: 20, u: 100, d: 50)
|
475
|
+
rmq(your_view).nudge(left: 20, right: 20, up: 100, down: 50)
|
476
|
+
|
477
|
+
# Distribute
|
478
|
+
rmq(UIButton).distribute
|
479
|
+
rmq(UIButton).distribute(:vertical)
|
480
|
+
rmq(UIButton).distribute(:horizontal)
|
481
|
+
rmq(UIButton).distribute(:vertical, margin: 20)
|
482
|
+
rmq(my_view, my_other_view, third_view).distribute(:vertical, margin: 10)
|
483
|
+
rmq(UIButton).distribute(:vertical, margins: [5,5,10,5,10,5,10,20])
|
484
|
+
```
|
485
|
+
|
486
|
+
|
326
487
|
<br />
|
327
488
|
|
328
489
|
### Events and Gestures
|
@@ -339,7 +500,7 @@ rmq(UIView).on(:tap){|sender| rmq(sender).hide}
|
|
339
500
|
|
340
501
|
# Adding an Event during creation
|
341
502
|
view_q = rmq.append(UIView).on(:tap) do |sender, event|
|
342
|
-
|
503
|
+
# do something here
|
343
504
|
end
|
344
505
|
|
345
506
|
# removing an Event
|
@@ -471,60 +632,6 @@ rmq(my_text_field).focus # or .become_first_responder
|
|
471
632
|
```
|
472
633
|
|
473
634
|
|
474
|
-
<br />
|
475
|
-
|
476
|
-
### Subviews - appending, creating, etc
|
477
|
-
|
478
|
-
----
|
479
|
-
|
480
|
-
```ruby
|
481
|
-
rmq.append(UILabel) # Creates a UILabel in the current controller
|
482
|
-
rmq.append(UILabel, :my_label_style)
|
483
|
-
rmq.append(UILabel.alloc.initWithFrame([[0,0],[10,10]]), :my_label_style)
|
484
|
-
|
485
|
-
rmq(my_view).append(UIButton)
|
486
|
-
rmq(my_view).remove
|
487
|
-
rmq(my_vuew).children.remove
|
488
|
-
|
489
|
-
rmq(UIView).append(UIButton, :delete_me) # A custom button for all views
|
490
|
-
|
491
|
-
rmq.unshift(UILabel) # Adds to index 0 of the subviews
|
492
|
-
rmq.unshift(UILabel, :my_style)
|
493
|
-
rmq.insert(UILabel, at_index: 2)
|
494
|
-
rmq.insert(UILabel, at_index: 2, style: :my_style)
|
495
|
-
rmq.insert(UILabel, below_view: some_view_of_mine)
|
496
|
-
rmq.insert(UILabel, below_view: some_view_of_mine, style: :my_style)
|
497
|
-
|
498
|
-
rmq(my_view).parent # .superview works too
|
499
|
-
rmq(my_view).parents # all parents up the tree, up to the root
|
500
|
-
rmq(my_view).children
|
501
|
-
rmq(my_view).find # children, grandchildren, etc
|
502
|
-
rmq.root_view
|
503
|
-
rmq.view_controller
|
504
|
-
```
|
505
|
-
|
506
|
-
#### Create a view
|
507
|
-
If you want to create a view but not add it to the subviews of any other view, you can
|
508
|
-
use #create. It's basically #append without the actual appending.
|
509
|
-
This is very handy for stuff like table cells:
|
510
|
-
|
511
|
-
```ruby
|
512
|
-
# In your controller that is a delegate for a UITableView
|
513
|
-
def tableView(table_view, cellForRowAtIndexPath: index_path)
|
514
|
-
cell = table_view.dequeueReusableCellWithIdentifier(CELL_IDENTIFIER) || begin
|
515
|
-
rmq.create(StoreCell, :store_cell, cell_identifier: CELL_IDENTIFIER).get
|
516
|
-
end
|
517
|
-
end
|
518
|
-
|
519
|
-
# Your cell
|
520
|
-
class StoreCell < UITableViewCell
|
521
|
-
def rmq_build
|
522
|
-
rmq(self).append(UILabel, :title_label) # <- this works even though this object isn't in a controller
|
523
|
-
end
|
524
|
-
end
|
525
|
-
```
|
526
|
-
|
527
|
-
|
528
635
|
<br />
|
529
636
|
|
530
637
|
### Animate
|
@@ -634,39 +741,6 @@ font.system(14)
|
|
634
741
|
```
|
635
742
|
|
636
743
|
|
637
|
-
<br />
|
638
|
-
|
639
|
-
### Position (moving, sizing, and nudging)
|
640
|
-
|
641
|
-
----
|
642
|
-
|
643
|
-
```ruby
|
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
|
654
|
-
|
655
|
-
# Nudge pushes them in a direction
|
656
|
-
rmq(your_view).nudge(d: 20)
|
657
|
-
rmq(your_view).nudge(down: 20)
|
658
|
-
rmq(your_view).nudge(l: 20, r: 20, u: 100, d: 50)
|
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])
|
668
|
-
```
|
669
|
-
|
670
744
|
<br />
|
671
745
|
|
672
746
|
### Images
|
@@ -771,7 +845,7 @@ rmq.device.iphone?
|
|
771
845
|
rmq.device.four_inch?
|
772
846
|
rmq.device.retina?
|
773
847
|
|
774
|
-
# return values are :unknown, :portrait, :portrait_upside_down, :
|
848
|
+
# return values are :unknown, :portrait, :portrait_upside_down, :landscape_left,
|
775
849
|
# :landscape_right, :face_up, :face_down
|
776
850
|
rmq.device.orientation
|
777
851
|
rmq.device.landscape?
|
@@ -1061,7 +1135,7 @@ class MainStylesheet < ApplicationStylesheet
|
|
1061
1135
|
end
|
1062
1136
|
|
1063
1137
|
def section(st)
|
1064
|
-
st.frame = {w: 270, h: 110}
|
1138
|
+
st.frame = {from_bottom: PADDING, w: 270, h: 110}
|
1065
1139
|
|
1066
1140
|
if landscape? && iphone?
|
1067
1141
|
st.left = PADDING
|
@@ -1069,8 +1143,6 @@ class MainStylesheet < ApplicationStylesheet
|
|
1069
1143
|
st.centered = :horizontal
|
1070
1144
|
end
|
1071
1145
|
|
1072
|
-
st.from_bottom = PADDING
|
1073
|
-
|
1074
1146
|
st.z_position = 1
|
1075
1147
|
st.background_color = color.battleship_gray
|
1076
1148
|
end
|
@@ -1204,7 +1276,8 @@ Here is a silly example, showing you a bunch of methods the UIViewStyler gives y
|
|
1204
1276
|
def ui_view_kitchen_sink(st)
|
1205
1277
|
st.frame = {l: 1, t: 2, w: 3, h: 4}
|
1206
1278
|
st.frame = {left: 1, top: 2, width: 3, height: 4}
|
1207
|
-
st.frame = {
|
1279
|
+
st.frame = {from_right: 1, from_bottom: 2, width: 3, height: 4}
|
1280
|
+
st.frame = {fr: 1, fb: 2, w: 3, h: 4}
|
1208
1281
|
st.left = 20
|
1209
1282
|
st.top = 30
|
1210
1283
|
st.width = 40
|
@@ -1226,16 +1299,22 @@ def ui_view_kitchen_sink(st)
|
|
1226
1299
|
st.hidden = false
|
1227
1300
|
st.z_position = 66
|
1228
1301
|
st.opaque = false
|
1302
|
+
st.clips_to_bounds = false
|
1303
|
+
st.hidden = true
|
1304
|
+
st.content_mode = UIViewContentModeBottomLeft
|
1229
1305
|
|
1230
1306
|
st.background_color = color.red
|
1307
|
+
# TODO test background_image
|
1231
1308
|
|
1232
1309
|
st.scale = 1.5
|
1233
1310
|
st.rotation = 45
|
1311
|
+
st.tint_color = color.blue
|
1312
|
+
st.layer.cornerRadius = 5
|
1234
1313
|
end
|
1235
1314
|
```
|
1236
1315
|
|
1237
1316
|
##### UIControlStyler
|
1238
|
-
|
1317
|
+
Nothing yet
|
1239
1318
|
|
1240
1319
|
##### UILabelStyler
|
1241
1320
|
|
data/bin/rmq
CHANGED
@@ -47,7 +47,7 @@ class RmqCommandLine
|
|
47
47
|
puts "RMQ - Invalid command, do something like this: rmq create controller my_controller\n"
|
48
48
|
end
|
49
49
|
else
|
50
|
-
ensure_template_dir
|
50
|
+
#ensure_template_dir
|
51
51
|
create_app(template_or_app_name)
|
52
52
|
end
|
53
53
|
end
|
@@ -55,7 +55,7 @@ class RmqCommandLine
|
|
55
55
|
def create_app(app_name)
|
56
56
|
puts ' Creating app'
|
57
57
|
|
58
|
-
|
58
|
+
`motion create --template=git@github.com:infinitered/rmq-template.git #{app_name}`
|
59
59
|
|
60
60
|
puts %{
|
61
61
|
Complete. Things you should do:
|
@@ -77,9 +77,10 @@ class RmqCommandLine
|
|
77
77
|
"#{Dir.home}/Library/RubyMotion/template/rmq-template"
|
78
78
|
end
|
79
79
|
|
80
|
+
# TODO Disabling for now, this needs to get latest template
|
80
81
|
def ensure_template_dir
|
81
82
|
return if Dir.exists?(template_dir)
|
82
|
-
|
83
|
+
`git clone git@github.com:infinitered/rmq-template.git #{template_dir}`
|
83
84
|
end
|
84
85
|
|
85
86
|
def template_path(template_name)
|
@@ -106,7 +107,7 @@ class RmqCommandLine
|
|
106
107
|
return unless (@template_path = template_path(template_name))
|
107
108
|
files = Dir["#{@template_path}**/*"].select {|f| !File.directory? f}
|
108
109
|
|
109
|
-
@name = name.gsub(/(controller|stylesheet)/,'')
|
110
|
+
@name = name.gsub(/_?(controller|stylesheet)/,'')
|
110
111
|
@name_camel_case = @name.split('_').map{|word| word.capitalize}.join
|
111
112
|
|
112
113
|
files.each do |template_file_path_and_name|
|
@@ -108,6 +108,55 @@ module RubyMotionQuery
|
|
108
108
|
out
|
109
109
|
end
|
110
110
|
|
111
|
+
# @return [RMQ]
|
112
|
+
def sink_and_throb(opts = {})
|
113
|
+
opts.merge!({
|
114
|
+
duration: 0.3,
|
115
|
+
animations: ->(cq) {
|
116
|
+
cq.animations.throb(duration: 0.6)
|
117
|
+
}
|
118
|
+
})
|
119
|
+
|
120
|
+
out = @rmq.animate(
|
121
|
+
duration: 0.1,
|
122
|
+
animations: ->(q) {
|
123
|
+
q.style {|st| st.scale = 0.9}
|
124
|
+
},
|
125
|
+
completion: ->(did_finish, completion_rmq) {
|
126
|
+
if did_finish
|
127
|
+
completion_rmq.animate(opts)
|
128
|
+
end
|
129
|
+
}
|
130
|
+
)
|
131
|
+
out
|
132
|
+
end
|
133
|
+
|
134
|
+
# @return [RMQ]
|
135
|
+
def land_and_sink_and_throb(opts = {})
|
136
|
+
@rmq.hide.style do |st|
|
137
|
+
st.opacity = 0.1
|
138
|
+
st.scale = 8.0
|
139
|
+
st.hidden = false
|
140
|
+
end
|
141
|
+
|
142
|
+
opts.merge!({
|
143
|
+
duration: 0.5,
|
144
|
+
animations: ->(cq) {
|
145
|
+
cq.style do |st|
|
146
|
+
st.opacity = 1.0
|
147
|
+
st.scale = 0.8
|
148
|
+
end
|
149
|
+
},
|
150
|
+
completion: ->(did_finish, last_completion_rmq) {
|
151
|
+
if did_finish
|
152
|
+
last_completion_rmq.animations.throb
|
153
|
+
end
|
154
|
+
}
|
155
|
+
})
|
156
|
+
|
157
|
+
@rmq.animate(opts)
|
158
|
+
end
|
159
|
+
|
111
160
|
# @return [RMQ]
|
112
161
|
def drop_and_spin(opts = {})
|
113
162
|
remove_view = opts[:remove_view]
|
@@ -73,7 +73,7 @@ module RubyMotionQuery
|
|
73
73
|
end
|
74
74
|
|
75
75
|
# Returns the current view controller in the app. If the current controller is a tab or
|
76
|
-
# navigation controller, then it gets the current tab or topmost controller in the nav
|
76
|
+
# navigation controller, then it gets the current tab or topmost controller in the nav, etc
|
77
77
|
#
|
78
78
|
# This mostly works... mostly. As there really isn't a "current view_controller"
|
79
79
|
#
|
@@ -86,7 +86,15 @@ module RubyMotionQuery
|
|
86
86
|
when UITabBarController
|
87
87
|
current_view_controller(root_view_controller.selectedViewController)
|
88
88
|
else
|
89
|
-
root_view_controller
|
89
|
+
if root_view_controller.respond_to?(:visibleViewController)
|
90
|
+
current_view_controller(root_view_controller.visibleViewController)
|
91
|
+
elsif root_view_controller.respond_to?(:topViewController)
|
92
|
+
current_view_controller(root_view_controller.topViewController)
|
93
|
+
elsif root_view_controller.childViewControllers.count > 0
|
94
|
+
current_view_controller(root_view_controller.childViewControllers.first)
|
95
|
+
else
|
96
|
+
root_view_controller
|
97
|
+
end
|
90
98
|
end
|
91
99
|
end
|
92
100
|
end
|
@@ -58,11 +58,12 @@ module RubyMotionQuery
|
|
58
58
|
|
59
59
|
# @return :unknown or from ORIENTATIONS
|
60
60
|
def orientation
|
61
|
-
|
61
|
+
orientation = UIApplication.sharedApplication.statusBarOrientation
|
62
|
+
ORIENTATIONS[orientation] || :unknown
|
62
63
|
end
|
63
64
|
|
64
65
|
def landscape?
|
65
|
-
Device.orientation == :
|
66
|
+
Device.orientation == :landscape_left || Device.orientation == :landscape_right
|
66
67
|
end
|
67
68
|
|
68
69
|
def portrait?
|
@@ -77,7 +78,7 @@ module RubyMotionQuery
|
|
77
78
|
UIDeviceOrientationUnknown => :unknown,
|
78
79
|
UIDeviceOrientationPortrait => :portrait,
|
79
80
|
UIDeviceOrientationPortraitUpsideDown => :portrait_upside_down,
|
80
|
-
UIDeviceOrientationLandscapeLeft => :
|
81
|
+
UIDeviceOrientationLandscapeLeft => :landscape_left,
|
81
82
|
UIDeviceOrientationLandscapeRight => :landscape_right,
|
82
83
|
UIDeviceOrientationFaceUp => :face_up,
|
83
84
|
UIDeviceOrientationFaceDown => :face_down
|
@@ -45,34 +45,6 @@ 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
|
-
|
76
48
|
end
|
77
49
|
end
|
78
50
|
end
|
@@ -1,7 +1,19 @@
|
|
1
1
|
module RubyMotionQuery
|
2
2
|
module Stylers
|
3
3
|
|
4
|
-
class UIPageControlStyler < UIControlStyler
|
4
|
+
class UIPageControlStyler < UIControlStyler
|
5
|
+
def current_page; @view.currentPage; end
|
6
|
+
def current_page=(value); @view.currentPage=value; end
|
7
|
+
|
8
|
+
def number_of_pages; @view.numberOfPages; end
|
9
|
+
def number_of_pages=(value); @view.numberOfPages = value; end
|
10
|
+
|
11
|
+
def page_indicator_tint_color; @view.pageIndicatorTintColor; end
|
12
|
+
def page_indicator_tint_color=(color); @view.pageIndicatorTintColor = color;end
|
13
|
+
|
14
|
+
def current_page_indicator_tint_color; @view.currentPageIndicatorTintColor;end
|
15
|
+
def current_page_indicator_tint_color=(color);@view.currentPageIndicatorTintColor = color;end
|
16
|
+
|
5
17
|
end
|
6
18
|
|
7
19
|
end
|
@@ -17,6 +17,22 @@ module RubyMotionQuery
|
|
17
17
|
def content_inset=(value) ; @view.contentInset = value ; end
|
18
18
|
def content_inset ; @view.contentInset ; end
|
19
19
|
|
20
|
+
def bounces=(value); @view.bounces = value; end
|
21
|
+
def bounces; @view.bounces; end
|
22
|
+
|
23
|
+
def content_size=(value); @view.contentSize = value; end
|
24
|
+
def content_size; @view.contentSize; end
|
25
|
+
|
26
|
+
def shows_horizontal_scroll_indicator=(value); @view.showsHorizontalScrollIndicator = value; end
|
27
|
+
def shows_horizontal_scroll_indicator; @view.showsHorizontalScrollIndicator; end
|
28
|
+
|
29
|
+
def shows_vertical_scroll_indicator=(value); @view.showsVerticalScrollIndicator = value; end
|
30
|
+
def shows_vertical_scroll_indicator; @view.showsVerticalScrollIndicator; end
|
31
|
+
|
32
|
+
def scroll_indicator_insets=(value); @view.scrollIndicatorInsets = value; end
|
33
|
+
def scroll_indicator_insets; @view.scrollIndicatorInsets; end
|
34
|
+
|
35
|
+
|
20
36
|
end
|
21
37
|
|
22
38
|
end
|
@@ -54,7 +54,17 @@ module RubyMotionQuery
|
|
54
54
|
f.origin.x = h[:l] || h[:left] || f.origin.x
|
55
55
|
f.origin.y = h[:t] || h[:top] || f.origin.y
|
56
56
|
f.size.width = h[:w] || h[:width] || f.size.width
|
57
|
-
f.size.height =h[:h] || h[:height] || f.size.height
|
57
|
+
f.size.height = h[:h] || h[:height] || f.size.height
|
58
|
+
|
59
|
+
if sv = @view.superview
|
60
|
+
if fr = (h[:from_right] || h[:fr])
|
61
|
+
f.origin.x = sv.bounds.size.width - f.size.width - fr
|
62
|
+
end
|
63
|
+
|
64
|
+
if fb = (h[:from_bottom] || h[:fb])
|
65
|
+
f.origin.y = sv.bounds.size.height - f.size.height - fb
|
66
|
+
end
|
67
|
+
end
|
58
68
|
|
59
69
|
@view.frame = f
|
60
70
|
else
|
@@ -132,13 +142,13 @@ module RubyMotionQuery
|
|
132
142
|
end
|
133
143
|
|
134
144
|
def from_bottom=(value)
|
135
|
-
if
|
136
|
-
self.top =
|
145
|
+
if sv = @view.superview
|
146
|
+
self.top = sv.bounds.size.height - self.height - value
|
137
147
|
end
|
138
148
|
end
|
139
149
|
def from_bottom
|
140
|
-
if
|
141
|
-
|
150
|
+
if sv = @view.superview
|
151
|
+
sv.bounds.size.height - self.top
|
142
152
|
end
|
143
153
|
end
|
144
154
|
|
@@ -283,6 +293,48 @@ module RubyMotionQuery
|
|
283
293
|
@view.layer
|
284
294
|
end
|
285
295
|
|
296
|
+
def opacity=(value)
|
297
|
+
@view.layer.opacity = value
|
298
|
+
end
|
299
|
+
def opacity
|
300
|
+
@view.layer.opacity
|
301
|
+
end
|
302
|
+
|
303
|
+
def border_width=(value)
|
304
|
+
@view.layer.borderWidth = value
|
305
|
+
end
|
306
|
+
def border_width
|
307
|
+
@view.layer.borderWidth
|
308
|
+
end
|
309
|
+
|
310
|
+
def border_color=(value)
|
311
|
+
if value.is_a?(UICachedDeviceRGBColor)
|
312
|
+
@view.layer.setBorderColor(value.CGColor)
|
313
|
+
else
|
314
|
+
@view.layer.setBorderColor value
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
def border_color
|
319
|
+
@view.layer.borderColor
|
320
|
+
end
|
321
|
+
|
322
|
+
def corner_radius=(value = 2)
|
323
|
+
@view.layer.cornerRadius = value
|
324
|
+
end
|
325
|
+
|
326
|
+
def corner_radius
|
327
|
+
@view.layer.cornerRadius
|
328
|
+
end
|
329
|
+
|
330
|
+
def masks_to_bounds=(value)
|
331
|
+
@view.layer.masksToBounds = value
|
332
|
+
end
|
333
|
+
|
334
|
+
def masks_to_bounds
|
335
|
+
@view.layer.masksToBounds
|
336
|
+
end
|
337
|
+
|
286
338
|
end
|
287
339
|
end
|
288
340
|
end
|
@@ -52,7 +52,7 @@ module RubyMotionQuery
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def styler_for(view)
|
55
|
-
# TODO should have a pool of stylers to reuse, or just assume single threaded and
|
55
|
+
# TODO should have a pool of stylers to reuse, or just assume single threaded and
|
56
56
|
# memoize this, however if you do that, make sure the dev doesn't retain them in a var
|
57
57
|
custom_stylers(view) || begin
|
58
58
|
case view
|
@@ -110,13 +110,13 @@ module RubyMotionQuery
|
|
110
110
|
|
111
111
|
unless Stylesheet.application_was_setup
|
112
112
|
Stylesheet.application_was_setup = true
|
113
|
-
application_setup
|
113
|
+
application_setup
|
114
114
|
end
|
115
115
|
setup
|
116
116
|
end
|
117
117
|
|
118
118
|
def application_setup
|
119
|
-
# Override to do your overall setup for your applications. This
|
119
|
+
# Override to do your overall setup for your applications. This
|
120
120
|
# is where you want to add your custom fonts and colors
|
121
121
|
# This only gets called once
|
122
122
|
end
|
@@ -130,12 +130,18 @@ module RubyMotionQuery
|
|
130
130
|
end
|
131
131
|
|
132
132
|
# Convenience methods -------------------
|
133
|
-
def rmq
|
134
|
-
if @controller.nil?
|
135
|
-
RMQ.new
|
133
|
+
def rmq(*working_selectors)
|
134
|
+
q = if @controller.nil?
|
135
|
+
RubyMotionQuery::RMQ.new
|
136
136
|
else
|
137
137
|
@controller.rmq
|
138
138
|
end
|
139
|
+
|
140
|
+
if working_selectors.length > 0
|
141
|
+
q.wrap(working_selectors)
|
142
|
+
else
|
143
|
+
q
|
144
|
+
end
|
139
145
|
end
|
140
146
|
|
141
147
|
def device
|
@@ -169,11 +175,11 @@ module RubyMotionQuery
|
|
169
175
|
end
|
170
176
|
|
171
177
|
def app_width
|
172
|
-
app_size.width
|
178
|
+
portrait? ? app_size.width : app_size.height
|
173
179
|
end
|
174
180
|
|
175
181
|
def app_height
|
176
|
-
app_size.height
|
182
|
+
portrait? ? app_size.height : app_size.width
|
177
183
|
end
|
178
184
|
|
179
185
|
def app_size
|
@@ -181,11 +187,11 @@ module RubyMotionQuery
|
|
181
187
|
end
|
182
188
|
|
183
189
|
def screen_width
|
184
|
-
screen_size.width
|
190
|
+
portrait? ? screen_size.width : screen_size.height
|
185
191
|
end
|
186
192
|
|
187
193
|
def screen_height
|
188
|
-
screen_size.height
|
194
|
+
portrait? ? screen_size.height : screen_size.width
|
189
195
|
end
|
190
196
|
|
191
197
|
def screen_size
|
@@ -118,13 +118,20 @@ module RubyMotionQuery
|
|
118
118
|
protected
|
119
119
|
|
120
120
|
def create_view(klass, opts)
|
121
|
-
if klass == UIButton
|
121
|
+
if (klass == UIButton) || klass < UIButton
|
122
122
|
klass.buttonWithType(UIButtonTypeCustom).tap do |o|
|
123
123
|
o.hidden = false
|
124
124
|
o.opaque = true
|
125
125
|
end
|
126
126
|
elsif reuse_identifier = opts[:reuse_identifier]
|
127
|
-
|
127
|
+
style = opts[:cell_style] || UITableViewCellStyleDefault
|
128
|
+
klass.alloc.initWithStyle(style, reuseIdentifier: reuse_identifier).tap do |o|
|
129
|
+
o.hidden = false
|
130
|
+
o.opaque = true
|
131
|
+
end
|
132
|
+
elsif (klass == UITableView) || klass < UITableView
|
133
|
+
style = opts[:table_style] || UITableViewStylePlain
|
134
|
+
klass.alloc.initWithFrame(CGRectZero, style: style).tap do |o|
|
128
135
|
o.hidden = false
|
129
136
|
o.opaque = true
|
130
137
|
end
|
@@ -80,6 +80,7 @@ module RubyMotionQuery
|
|
80
80
|
#a == b # For future release
|
81
81
|
end
|
82
82
|
|
83
|
+
# @deprecated, this has been fixed in RubyMotion 2.24, so this method is no longer needed.
|
83
84
|
# Gets a strong reference from a weak reference
|
84
85
|
def weak_ref_to_strong_ref(weak_ref)
|
85
86
|
# This is a hack but it works, is there a better way?
|
@@ -38,6 +38,9 @@ class <%= @name_camel_case %>Controller < UITableViewController
|
|
38
38
|
|
39
39
|
cell = table_view.dequeueReusableCellWithIdentifier(<%= @name.upcase %>_CELL_ID) || begin
|
40
40
|
rmq.create(<%= @name_camel_case %>Cell, :<%= @name %>_cell, reuse_identifier: <%= @name.upcase %>_CELL_ID).get
|
41
|
+
|
42
|
+
# If you want to change the style of the cell, you can do something like this:
|
43
|
+
#rmq.create(<%= @name_camel_case %>Cell, :<%= @name %>_cell, reuse_identifier: <%= @name.upcase %>_CELL_ID, cell_style: UITableViewCellStyleSubtitle).get
|
41
44
|
end
|
42
45
|
|
43
46
|
cell.update(data_row)
|
@@ -1,15 +1,16 @@
|
|
1
1
|
class <%= @name_camel_case %>Cell < UITableViewCell
|
2
2
|
|
3
3
|
def rmq_build
|
4
|
-
rmq(self.contentView)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
q = rmq(self.contentView)
|
5
|
+
|
6
|
+
# Add your subviews, init stuff here
|
7
|
+
# @foo = q.append(UILabel, :foo).get
|
8
|
+
|
9
|
+
# Or use the built-in table cell controls, if you don't use
|
10
|
+
# these, they won't exist at runtime
|
11
|
+
# q.build(self.imageView, :cell_image)
|
12
|
+
# q.build(self.detailTextLabel, :cell_label_detail)
|
13
|
+
@name = q.build(self.textLabel, :cell_label).get
|
13
14
|
end
|
14
15
|
|
15
16
|
def update(data)
|
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.
|
4
|
+
version: 0.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Werth
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bacon
|
@@ -144,3 +144,4 @@ signing_key:
|
|
144
144
|
specification_version: 4
|
145
145
|
summary: RubyMotionQuery - RMQ
|
146
146
|
test_files: []
|
147
|
+
has_rdoc:
|