ruby_motion_query 0.4.0 → 0.4.1
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 +8 -8
- data/README.md +19 -1
- data/bin/rmq +3 -1
- data/motion/ruby_motion_query/color.rb +4 -0
- data/motion/ruby_motion_query/event.rb +11 -1
- data/motion/ruby_motion_query/events.rb +87 -2
- data/motion/ruby_motion_query/stylers/ui_view_styler.rb +7 -0
- data/motion/ruby_motion_query/version.rb +1 -1
- data/templates/collection_view_controller/app/controllers/name_controller.rb +78 -0
- data/templates/collection_view_controller/app/stylesheets/name_cell_stylesheet.rb +13 -0
- data/templates/collection_view_controller/app/stylesheets/name_controller_stylesheet.rb +26 -0
- data/templates/collection_view_controller/app/views/name_cell.rb +17 -0
- data/templates/collection_view_controller/spec/controllers/name_controller.rb +9 -0
- data/templates/collection_view_controller/spec/views/name_cell.rb +9 -0
- data/templates/view/app/views/name.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWFmNzE0NjljMGNjYTRhYmYxYTIxMWQ3MGE1YTY1ODI0Y2E0M2EyNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2RjODk1NDgyMmQ2ODc1MDFlZjc2ODg3YWVkMzMwZTk5YWNiMTMxZA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2MxY2YyZGU0ZDdiZmQxNzAwNTk3NWFlNjA2NGUzNmJhMzVkYTMzMWUxN2Ri
|
10
|
+
NjBlNmZiYjEzNWY2Nzc2ZDcyZTlmNmU4NDZlOTk3MDM3ZmQ2MWExYjY3YjI2
|
11
|
+
ODkzZWFlNmI4ZThlODAzMTczYjU4MTAzOWI5YWI3Yjk3MzgzNTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjRlNjg1YjRkNzk5MmYwYzZiZWY2MjJmYTc5ZWRjZWRhZmZlMTVjZWZlNTVm
|
14
|
+
ZTQ3Yjg5M2I4YWJjZDM0MDk4ODBiMzJhYzUxOGRlOTI3NGIwYzZlOWJlOGE1
|
15
|
+
YzljNTlhMTkzMDZlNGVkMzE3MjhjZWEzM2U5M2RhMDY1NDQ5YTc=
|
data/README.md
CHANGED
@@ -26,7 +26,7 @@ A fast, muggle, nonpolluting, jQuery-like library for [RubyMotion](http://rubymo
|
|
26
26
|
|
27
27
|
----------
|
28
28
|
|
29
|
-
**Tested
|
29
|
+
**Tested on iOS, not OS X (nor is there any OS X specific code)**
|
30
30
|
|
31
31
|
----------
|
32
32
|
|
@@ -183,6 +183,8 @@ Here are the commands available to you:
|
|
183
183
|
> rmq create shared some_class_used_app_wide
|
184
184
|
> rmq create lib some_class_used_by_multiple_apps
|
185
185
|
|
186
|
+
> rmq create collection_view_controller foos
|
187
|
+
|
186
188
|
# To test the create command without actually creating any files, do:
|
187
189
|
> rmq create view my_view dry_run
|
188
190
|
|
@@ -354,6 +356,12 @@ rmq(my_view).tag(your_tag: 22, your_other_tag: 'Hello world')
|
|
354
356
|
# You can use a tag or tags as selecors
|
355
357
|
rmq(:selected).hide
|
356
358
|
rmq(:your_tag).and(:selected).hide
|
359
|
+
|
360
|
+
# Get tags for a view
|
361
|
+
your_view.rmq_data.tags
|
362
|
+
# Also
|
363
|
+
your_view.rmq_data.has_tag?(:foo)
|
364
|
+
your_view.rmq_data.tag_names
|
357
365
|
```
|
358
366
|
|
359
367
|
### Actions
|
@@ -1102,6 +1110,16 @@ end
|
|
1102
1110
|
rmq.append(YourView, :your_style)
|
1103
1111
|
```
|
1104
1112
|
|
1113
|
+
### Future features
|
1114
|
+
|
1115
|
+
Future features that I plan on adding
|
1116
|
+
|
1117
|
+
- rmq.push_sub_controller(my_controller) and rmq.pop_sub_controller and rmq.pop_this_controller
|
1118
|
+
- add borders to UIView styler: st.borders = {l: {w: 2, color: color.black}, r: {w: 2, color: color.black}}
|
1119
|
+
- add templates for: nav controller, tab controller, table controller, collection controller
|
1120
|
+
- add from_right, from_bottom, and centered to both st.frame and to move
|
1121
|
+
- add binding that combines KVO and events to bind an attribute of one object to the attribute of selected view(s), keeping both in sync, like so: rmq.append(UITextField).bind(@person, attr: :name, to: :text)
|
1122
|
+
|
1105
1123
|
|
1106
1124
|
## Contact
|
1107
1125
|
|
data/bin/rmq
CHANGED
@@ -21,11 +21,13 @@ class RmqCommandLine
|
|
21
21
|
> rmq create shared some_class_used_app_wide
|
22
22
|
> rmq create lib some_class_used_by_multiple_apps
|
23
23
|
|
24
|
+
> rmq create collection_view_controller foos
|
25
|
+
|
24
26
|
> rmq -h, --help
|
25
27
|
> rmq -v, --version }
|
26
28
|
|
27
29
|
class << self
|
28
|
-
VALID_CREATE_TYPES = [:model, :controller, :view, :shared, :lib]
|
30
|
+
VALID_CREATE_TYPES = [:model, :controller, :view, :shared, :lib, :collection_view_controller]
|
29
31
|
|
30
32
|
def create(template_or_app_name, name, options)
|
31
33
|
@dry_run = true if options == 'dry_run'
|
@@ -44,7 +44,17 @@ module RubyMotionQuery
|
|
44
44
|
o.delegate = opts[:delegate] if opts.include?(:delegate)
|
45
45
|
o.numberOfTapsRequired = opts[:taps_required] if opts.include?(:taps_required)
|
46
46
|
o.numberOfTouchesRequired = opts[:fingers_required] if opts.include?(:fingers_required)
|
47
|
-
|
47
|
+
o.maximumNumberOfTouches = opts[:maximum_number_of_touches] if opts.include?(:maximum_number_of_touches)
|
48
|
+
o.minimumNumberOfTouches = opts[:minimum_number_of_touches] if opts.include?(:minimum_number_of_touches)
|
49
|
+
o.allowableMovement = opts[:allowable_movement] if opts.include?(:allowable_movement)
|
50
|
+
o.minimumPressDuration = opts[:minimum_press_duration] if opts.include?(:minimum_press_duration)
|
51
|
+
o.direction = opts[:direction] if opts.include?(:direction)
|
52
|
+
o.rotation = opts[:rotation] if opts.include?(:rotation)
|
53
|
+
o.scale = opts[:scale] if opts.include?(:scale)
|
54
|
+
|
55
|
+
if opts.include?(:init)
|
56
|
+
opts[:init].call(@recognizer)
|
57
|
+
end
|
48
58
|
end
|
49
59
|
end
|
50
60
|
end
|
@@ -1,6 +1,85 @@
|
|
1
1
|
module RubyMotionQuery
|
2
2
|
class RMQ
|
3
|
+
# Adds an event/gesture to all selected views
|
4
|
+
#
|
3
5
|
# @return [RMQ]
|
6
|
+
#
|
7
|
+
# on(event_or_gesture, options) do |sender, event|
|
8
|
+
# # your code when event fires
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# Events for UIControl
|
12
|
+
# :touch
|
13
|
+
# :touch_up
|
14
|
+
# :touch_down
|
15
|
+
# :touch_start
|
16
|
+
# :touch_stop
|
17
|
+
# :change
|
18
|
+
|
19
|
+
# :touch_down_repeat
|
20
|
+
# :touch_drag_inside
|
21
|
+
# :touch_drag_outside
|
22
|
+
# :touch_drag_enter
|
23
|
+
# :touch_drag_exit
|
24
|
+
# :touch_up_inside
|
25
|
+
# :touch_up_outside
|
26
|
+
# :touch_cancel
|
27
|
+
|
28
|
+
# :value_changed
|
29
|
+
|
30
|
+
# :editing_did_begin
|
31
|
+
# :editing_changed
|
32
|
+
# :editing_did_change
|
33
|
+
# :editing_did_end
|
34
|
+
# :editing_did_endonexit
|
35
|
+
|
36
|
+
# :all_touch
|
37
|
+
# :all_editing
|
38
|
+
|
39
|
+
# :application
|
40
|
+
# :system
|
41
|
+
# :all
|
42
|
+
|
43
|
+
# Gestures for UIView
|
44
|
+
# :tap
|
45
|
+
# :pinch
|
46
|
+
# :rotate
|
47
|
+
# :swipe
|
48
|
+
# :pan
|
49
|
+
# :long_press
|
50
|
+
|
51
|
+
# Options for gestures
|
52
|
+
# :cancels_touches_in_view
|
53
|
+
# :delegate
|
54
|
+
# :taps_required
|
55
|
+
# :fingers_required
|
56
|
+
# :maximum_number_of_touches
|
57
|
+
# :minimum_number_of_touches
|
58
|
+
# :allowable_movement
|
59
|
+
# :minimum_press_duration
|
60
|
+
# :direction
|
61
|
+
# :rotation
|
62
|
+
# :scale
|
63
|
+
#
|
64
|
+
# @example
|
65
|
+
# rmq.append(UIButton).on(:touch) do |sender|
|
66
|
+
# # Do something when button is touched
|
67
|
+
# end
|
68
|
+
#
|
69
|
+
# @example
|
70
|
+
# rmq(my_view).on(:tap, taps_required: 2 ) do |sender, event|
|
71
|
+
# # Do something when event fires
|
72
|
+
# end
|
73
|
+
#
|
74
|
+
# @example
|
75
|
+
# # These both are the same
|
76
|
+
# rmq(button).on(:tap, init: ->(recongnizer){recongnizer.numberOfTapsRequired = 2) do |sender|
|
77
|
+
# puts 'tapped'
|
78
|
+
# end
|
79
|
+
#
|
80
|
+
# rmq(button).on(:tap, taps_required: 2) do |sender|
|
81
|
+
# puts 'tapped'
|
82
|
+
# end
|
4
83
|
def on(event, args = {}, &block)
|
5
84
|
selected.each do |view|
|
6
85
|
events(view).on(view, event, args, &block)
|
@@ -9,6 +88,8 @@ module RubyMotionQuery
|
|
9
88
|
self
|
10
89
|
end
|
11
90
|
|
91
|
+
# Removes events/gestures from all views selected
|
92
|
+
#
|
12
93
|
# @return [RMQ]
|
13
94
|
def off(*events)
|
14
95
|
selected.each do |view|
|
@@ -30,12 +111,16 @@ module RubyMotionQuery
|
|
30
111
|
@event_set = {}
|
31
112
|
end
|
32
113
|
|
114
|
+
def [](sdk_event_or_recognizer)
|
115
|
+
@event_set[sdk_event_or_recognizer]
|
116
|
+
end
|
117
|
+
|
33
118
|
def has_events?
|
34
119
|
!RMQ.is_blank?(@event_set)
|
35
120
|
end
|
36
121
|
|
37
|
-
def has_event?(
|
38
|
-
@event_set.include?(
|
122
|
+
def has_event?(sdk_event_or_recognizer)
|
123
|
+
@event_set.include?(sdk_event_or_recognizer)
|
39
124
|
end
|
40
125
|
|
41
126
|
def on(view, event, args = {}, &block)
|
@@ -250,6 +250,13 @@ module RubyMotionQuery
|
|
250
250
|
@view.transform = CGAffineTransformMakeRotation(radians)
|
251
251
|
end
|
252
252
|
|
253
|
+
def content_mode=(value)
|
254
|
+
@view.contentMode = value
|
255
|
+
end
|
256
|
+
def content_mode
|
257
|
+
@view.contentMode
|
258
|
+
end
|
259
|
+
|
253
260
|
end
|
254
261
|
end
|
255
262
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
class <%= @name_camel_case %>Controller < UICollectionViewController
|
2
|
+
# In app_delegate.rb or wherever you use this controller, just call .new like so:
|
3
|
+
# @window.rootViewController = <%= @name_camel_case %>Controller.new
|
4
|
+
#
|
5
|
+
# Or if you're adding using it in a navigation controller, do this
|
6
|
+
# main_controller = <%= @name_camel_case %>Controller.new
|
7
|
+
# @window.rootViewController = UINavigationController.alloc.initWithRootViewController(main_controller)
|
8
|
+
|
9
|
+
<%= @name.upcase %>_CELL_ID = "<%= @name_camel_case %>Cell"
|
10
|
+
|
11
|
+
def self.new(args = {})
|
12
|
+
# Set layout
|
13
|
+
layout = UICollectionViewFlowLayout.alloc.init
|
14
|
+
self.alloc.initWithCollectionViewLayout(layout)
|
15
|
+
end
|
16
|
+
|
17
|
+
def viewDidLoad
|
18
|
+
super
|
19
|
+
|
20
|
+
rmq.stylesheet = <%= @name_camel_case %>ControllerStylesheet
|
21
|
+
|
22
|
+
collectionView.tap do |cv|
|
23
|
+
cv.registerClass(<%= @name_camel_case %>Cell, forCellWithReuseIdentifier: <%= @name.upcase %>_CELL_ID)
|
24
|
+
cv.delegate = self
|
25
|
+
cv.dataSource = self
|
26
|
+
cv.allowsSelection = true
|
27
|
+
cv.allowsMultipleSelection = false
|
28
|
+
rmq(cv).apply_style :collection_view
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Remove if you are only supporting portrait
|
33
|
+
def supportedInterfaceOrientations
|
34
|
+
UIInterfaceOrientationMaskAll
|
35
|
+
end
|
36
|
+
|
37
|
+
# Remove if you are only supporting portrait
|
38
|
+
def willAnimateRotationToInterfaceOrientation(orientation, duration: duration)
|
39
|
+
rmq(:reapply_style).reapply_styles
|
40
|
+
end
|
41
|
+
|
42
|
+
def numberOfSectionsInCollectionView(view)
|
43
|
+
1
|
44
|
+
end
|
45
|
+
|
46
|
+
def collectionView(view, numberOfItemsInSection: section)
|
47
|
+
200
|
48
|
+
end
|
49
|
+
|
50
|
+
def collectionView(view, cellForItemAtIndexPath: index_path)
|
51
|
+
view.dequeueReusableCellWithReuseIdentifier(<%= @name.upcase %>_CELL_ID, forIndexPath: index_path).tap do |cell|
|
52
|
+
cell.setup_with(rmq)
|
53
|
+
|
54
|
+
# Update cell's data here
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def collectionView(view, didSelectItemAtIndexPath: index_path)
|
59
|
+
cell = view.cellForItemAtIndexPath(index_path)
|
60
|
+
puts "Selected at section: #{index_path.section}, row: #{index_path.row}"
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
__END__
|
66
|
+
|
67
|
+
# You don't have to reapply styles to all UIViews, if you want to optimize,
|
68
|
+
# another way to do it is tag the views you need to restyle in your stylesheet,
|
69
|
+
# then only reapply the tagged views, like so:
|
70
|
+
def logo(st)
|
71
|
+
st.frame = {t: 10, w: 200, h: 96}
|
72
|
+
st.centered = :horizontal
|
73
|
+
st.image = image.resource('logo')
|
74
|
+
st.tag(:reapply_style)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Then in willAnimateRotationToInterfaceOrientation
|
78
|
+
rmq(:reapply_style).reapply_styles
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class <%= @name_camel_case %>ControllerStylesheet < ApplicationStylesheet
|
2
|
+
|
3
|
+
include <%= @name_camel_case %>CellStylesheet
|
4
|
+
|
5
|
+
def setup
|
6
|
+
# Add sytlesheet specific setup stuff here.
|
7
|
+
# Add application specific setup stuff in application_stylesheet.rb
|
8
|
+
|
9
|
+
@margin = ipad? ? 12 : 8
|
10
|
+
end
|
11
|
+
|
12
|
+
def collection_view(st)
|
13
|
+
st.view.contentInset = [@margin, @margin, @margin, @margin]
|
14
|
+
st.background_color = color.white
|
15
|
+
|
16
|
+
st.view.collectionViewLayout.tap do |cl|
|
17
|
+
cl.itemSize = cell_size
|
18
|
+
#cl.scrollDirection = UICollectionViewScrollDirectionHorizontal
|
19
|
+
#cl.headerReferenceSize = cell_size
|
20
|
+
cl.minimumInteritemSpacing = @margin
|
21
|
+
cl.minimumLineSpacing = @margin
|
22
|
+
#cl.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight,
|
23
|
+
#cl.sectionInsert = [0,0,0,0]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class <%= @name_camel_case %>Cell < UICollectionViewCell
|
2
|
+
def setup_with(controller_rmq)
|
3
|
+
unless @initialized
|
4
|
+
@initialized = true
|
5
|
+
|
6
|
+
controller_rmq.wrap(self).tap do |q|
|
7
|
+
q.apply_style :<%= @name %>_cell
|
8
|
+
|
9
|
+
# Add your subviews, init stuff here
|
10
|
+
# @foo = q.append(UILabel, :foo).get
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def prepareForReuse
|
16
|
+
end
|
17
|
+
end
|
@@ -17,7 +17,7 @@ end
|
|
17
17
|
# To style this view include its stylesheet at the top of each controller's
|
18
18
|
# stylesheet that is going to use it:
|
19
19
|
# class SomeStylesheet < ApplicationStylesheet
|
20
|
-
# include <%= @
|
20
|
+
# include <%= @name_camel_case %>Stylesheet
|
21
21
|
|
22
22
|
# Another option is to use your controller's stylesheet to style this view. This
|
23
23
|
# works well if only one controller uses it. If you do that, delete the
|
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.4.
|
4
|
+
version: 0.4.1
|
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: 2013-10-
|
12
|
+
date: 2013-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bacon
|
@@ -92,6 +92,12 @@ files:
|
|
92
92
|
- motion/ruby_motion_query/traverse.rb
|
93
93
|
- motion/ruby_motion_query/utils.rb
|
94
94
|
- motion/ruby_motion_query/version.rb
|
95
|
+
- templates/collection_view_controller/app/controllers/name_controller.rb
|
96
|
+
- templates/collection_view_controller/app/stylesheets/name_cell_stylesheet.rb
|
97
|
+
- templates/collection_view_controller/app/stylesheets/name_controller_stylesheet.rb
|
98
|
+
- templates/collection_view_controller/app/views/name_cell.rb
|
99
|
+
- templates/collection_view_controller/spec/controllers/name_controller.rb
|
100
|
+
- templates/collection_view_controller/spec/views/name_cell.rb
|
95
101
|
- templates/controller/app/controllers/name_controller.rb
|
96
102
|
- templates/controller/app/stylesheets/name_controller_stylesheet.rb
|
97
103
|
- templates/controller/spec/controllers/name_controller.rb
|