motion-prime 0.6.0 → 0.7.0

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.
Files changed (46) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +6 -1
  5. data/ROADMAP.md +7 -6
  6. data/bin/prime +31 -16
  7. data/doc/code/models.rb +5 -1
  8. data/doc/code/tables.rb +54 -0
  9. data/doc/docs/getting_started.html +7 -0
  10. data/doc/docs/index.html +205 -0
  11. data/doc/docs/models.html +13 -0
  12. data/doc/docs/screens.html +7 -0
  13. data/doc/docs/sections.html +7 -0
  14. data/doc/docs/tables.html +128 -0
  15. data/files/Gemfile +3 -3
  16. data/lib/motion-prime.rb +2 -0
  17. data/motion-prime.gemspec +3 -2
  18. data/motion-prime/api_client.rb +35 -36
  19. data/motion-prime/config/base.rb +0 -2
  20. data/motion-prime/core_ext/kernel.rb +2 -1
  21. data/motion-prime/elements/base_element.rb +7 -2
  22. data/motion-prime/elements/spinner.rb +7 -0
  23. data/motion-prime/elements/table_view.rb +7 -0
  24. data/motion-prime/helpers/has_search_bar.rb +11 -5
  25. data/motion-prime/models/_finder_mixin.rb +5 -12
  26. data/motion-prime/models/_nano_bag_mixin.rb +1 -1
  27. data/motion-prime/models/_sync_mixin.rb +52 -37
  28. data/motion-prime/screens/_base_mixin.rb +4 -0
  29. data/motion-prime/screens/_navigation_mixin.rb +3 -3
  30. data/motion-prime/screens/screen.rb +1 -1
  31. data/motion-prime/sections/base_section.rb +12 -12
  32. data/motion-prime/sections/form/base_field_section.rb +1 -1
  33. data/motion-prime/sections/form/date_field_section.rb +5 -0
  34. data/motion-prime/sections/form/password_field_section.rb +1 -1
  35. data/motion-prime/sections/form/string_field_section.rb +1 -1
  36. data/motion-prime/sections/form/text_field_section.rb +1 -1
  37. data/motion-prime/sections/table.rb +7 -0
  38. data/motion-prime/sections/table/table_delegate.rb +14 -4
  39. data/motion-prime/support/mp_spinner.rb +16 -0
  40. data/motion-prime/support/mp_table_view.rb +6 -0
  41. data/motion-prime/support/tab_bar_controller.rb +3 -3
  42. data/motion-prime/support/temp_fixes.rb +6 -0
  43. data/motion-prime/version.rb +1 -1
  44. data/motion-prime/views/layout.rb +2 -1
  45. data/motion-prime/views/view_builder.rb +1 -1
  46. metadata +24 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZWRhN2JlZjVhMjI4YjI5YzFhNjE2ZWI0NDg3OTk3YmY0M2RlMDFhMQ==
4
+ YmU3NjAzNmZmNTZhOTZmZjczN2Y4MjFiMTcxOTI5ODVhZDdmZTI5OA==
5
5
  data.tar.gz: !binary |-
6
- NDliNzIxYjg0NDhhYWU5MDk5MzdlODJhZDM5NTE1MmE0OGQ1NjQzNQ==
6
+ ZWI3ZDRiMWVkYzE2MmJkNzYzZjRmNTc1MGY2YjE1ZTUyYWJhNDNhNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- M2JjZjdkZjE0YWRjMjg5MzdkYzAyMTM2MTYxY2NkMDZiZmI4ODNiZmFjOTZm
10
- NDFmODM0YzhjNDljNzk3YzA1YjU2ZDU5M2RjY2ViOTUzOTY4ZmNiNDAyNTAx
11
- MmM0YzM2MGZkNTMxYzQ2ZGEzOWE0YTY3NDYyNDlhZDE4OWY3OWE=
9
+ NDgyODhmMjQyMzhiNTM0OTA1OWE5NTQ0OGM0ZTYwZDkxNjk1NDVmOTU1MmY1
10
+ N2RmNzA2NDY1YzA2Yjc1YWNlZjgxY2JmODcyODdmOTBiYzA5ZmQ1ZGVjZTAy
11
+ OGI5ZmRiNWRmMTEzNmI4OTYzZjc5ZTZiZGViNWRlMTMzNDliNGM=
12
12
  data.tar.gz: !binary |-
13
- M2FkMzI4ZjYzZjZkYTNkNDI0ODRjZGNlNTQ0MDZmYjc4MWY1ZmFiY2E1ZWYy
14
- ZTVmNTQ0NTcxZGQ0YzIxYzU3MTQxOTRjMjk3OGRmYTczMWNhMzlmYzgzMjdj
15
- NjBiMzgyNzNkNjYyMjkyNWI1YzhkZTIyNmM1YTY0OTU3ZGM0ZWE=
13
+ ZGU5ZDFmMzczNWI5ODVlYjc5OWUyNDIyYjQ2OTdmNjlkNGJmYWQ4MjI3MjZi
14
+ MGQwMTg0ZWYwMTYzYTBlNGIwYjc0MzQ1MGQ1NWE3MDlmYzljN2M4NmI0YjRl
15
+ NGMzNjA0NjNhZGYxZmY2M2I5NzdkNzU4OGMzOTlmZDdiYThhNGI=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.7.0
2
+ * Added Model.find(1) syntax support where 1 is :id attribute.
3
+ * Migrate to AFMotion.
4
+
1
5
  === 0.6.0
2
6
  * Fix executable.
3
7
  * Stable release.
data/Gemfile CHANGED
@@ -4,4 +4,5 @@ gem 'motion-cocoapods', '~> 1.4.0'
4
4
  gem 'motion-support', '~> 0.2.4'
5
5
  gem 'sugarcube', '~> 1.3.7', require: 'sugarcube-classic'
6
6
  gem 'bubble-wrap', '~> 1.3.0'
7
+ gem 'afmotion', '~> 2.0.0'
7
8
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- motion-prime (0.6.0)
4
+ motion-prime (0.7.0)
5
+ afmotion (~> 2.0.0)
5
6
  bubble-wrap
6
7
  cocoapods
7
8
  methadone
@@ -17,6 +18,9 @@ GEM
17
18
  activesupport (3.2.16)
18
19
  i18n (~> 0.6, >= 0.6.4)
19
20
  multi_json (~> 1.0)
21
+ afmotion (2.0.0)
22
+ motion-cocoapods (~> 1.4.0)
23
+ motion-require (~> 0.0.7)
20
24
  bubble-wrap (1.3.0)
21
25
  claide (0.4.0)
22
26
  cocoapods (0.28.0)
@@ -65,6 +69,7 @@ PLATFORMS
65
69
  ruby
66
70
 
67
71
  DEPENDENCIES
72
+ afmotion (~> 2.0.0)
68
73
  bubble-wrap (~> 1.3.0)
69
74
  motion-cocoapods (~> 1.4.0)
70
75
  motion-prime!
data/ROADMAP.md CHANGED
@@ -1,10 +1,11 @@
1
- === 0.6.0
1
+ === 0.8.0
2
+ * handle and fix memory leaks for UITabbarController
2
3
  * deprecate root level :title option for submit field
3
4
  * rename submit element in submit field to button element
4
5
  * rename date_picker element in date_picker field to input element
5
6
  * add more and better default options for fields
6
7
 
7
- === 0.7.0
8
+ === 0.9.0
8
9
  * bug: if mp label do not have text and was set as hidden, it should unhide after setting text
9
10
  * add cleanup for section events
10
11
  * add dsl for push notifications
@@ -12,10 +13,10 @@
12
13
  * create "display_network_error" extension.
13
14
  * add different templates. some templates should be more like final app.
14
15
 
15
- === 0.8.0
16
+ === 1.0.0
17
+ * add sections/screens/models generator
18
+
19
+ === 1.1.0
16
20
  * add computed_options.get(), this will allow to make sure that options is computed.
17
21
  * add testing framework
18
-
19
- === 0.9.0
20
- * add sections/screens/models generator
21
22
  * add DSL for ViewStyles#setValue conditions
data/bin/prime CHANGED
@@ -27,23 +27,38 @@ class App
27
27
  def self.create(name)
28
28
  return puts "Usage: prime new <appname>" unless name.to_s.length > 0
29
29
  info "Creating new MotionPrime iOS app: #{name}"
30
- result = sh "motion create #{name} --template=git://github.com/droidlabs/motion-prime.git"
31
- if result == 0
32
- info "Command: bundle instal"
33
- sh "cd ./#{name}; bundle install"
34
- info "Command: pod setup"
35
- sh "cd ./#{name}; pod setup"
36
- info "Command: rake pod:install"
37
- sh "cd ./#{name}; rake pod:install"
30
+ if false
31
+ sh "motion create #{name} --template=git://github.com/droidlabs/motion-prime.git"
38
32
  else
39
- info "-------------------------------------"
40
- info "Unable to create RubyMotion template"
41
- info "Please create template manually"
42
- info "1. git clone git://github.com/droidlabs/motion-prime.git"
43
- info "2. cp motion-prime/files #{name}"
44
- info "3. cd ./#{name}"
45
- info "4. bundle"
46
- info "-------------------------------------"
33
+ clone_template
34
+ sh "motion create #{name} --template=motion-prime"
35
+ end
36
+ info "Command: bundle instal"
37
+ sh "cd ./#{name}; bundle install"
38
+ info "Command: pod setup"
39
+ sh "cd ./#{name}; pod setup"
40
+ info "Command: rake pod:install"
41
+ sh "cd ./#{name}; rake pod:install"
42
+ end
43
+
44
+ def self.home_path
45
+ ENV['HOME'].split('/')[0..2].join('/')
46
+ end
47
+
48
+ def self.repo_url
49
+ "git://github.com/droidlabs/motion-prime.git"
50
+ end
51
+
52
+ def self.clone_template
53
+ path = File.expand_path(File.join(home_path, 'Library/RubyMotion/template', 'motion-prime'))
54
+ git_clone(path)
55
+ end
56
+
57
+ def self.git_clone(path)
58
+ if File.exist?(path)
59
+ system("git --work-tree=#{path} --git-dir=#{path}/.git pull origin master")
60
+ else
61
+ system("git clone #{repo_url} #{path}")
47
62
  end
48
63
  end
49
64
 
data/doc/code/models.rb CHANGED
@@ -29,4 +29,8 @@ event = Event.create(
29
29
 
30
30
  # ** Retrieve all events **
31
31
 
32
- Event.all
32
+ Event.all
33
+
34
+ # ** Next **
35
+ #
36
+ # [Read more about Tables](tables.html)
@@ -0,0 +1,54 @@
1
+ # ** What is a TableSection? **
2
+ #
3
+ # "TableSection" is a "Section" which have some sugar to work with UITableViews.
4
+
5
+ # ** Create a Cell Section. **
6
+ #
7
+ # Inherit it from `Prime::Section`.
8
+ #
9
+ # Each element inside this section will be part of one cell.
10
+
11
+ class FooCellSection < Prime::Section
12
+ element :title, text: proc { model[:title] }
13
+ end
14
+
15
+ # ** Create a Table Section. **
16
+ #
17
+ # Just inherit it from `Prime::TableSection`.
18
+ #
19
+ # The key method which should be created is `table_data`. It should return array of any sections.
20
+
21
+ class FooTableSection < Prime::TableSection
22
+ def table_data
23
+ my_foo_items.map do |fruit_name|
24
+ model = {title: fruit_name}
25
+ FooCellSection.new(model: model)
26
+ end
27
+ end
28
+
29
+ def my_foo_items
30
+ %w[Orange Apricot Banana]
31
+ end
32
+ end
33
+
34
+ # ** Render table to a Screen. **
35
+ #
36
+
37
+ class FooScreen < Prime::Screen
38
+ def render
39
+ @main_section = FooTableSection.new(screen: self)
40
+ @main_section.render
41
+ end
42
+ end
43
+
44
+ # ** Style it. **
45
+ #
46
+ # Of course, don't forget to add styles for table cells.
47
+
48
+ Prime::Styles.define :foo_cell do
49
+ style :title,
50
+ left: 20,
51
+ top: 5,
52
+ width: 200,
53
+ height: 20
54
+ end
@@ -49,6 +49,13 @@
49
49
  </a>
50
50
  </li>
51
51
 
52
+
53
+ <li>
54
+ <a class="source" href="tables.html">
55
+ tables.rb
56
+ </a>
57
+ </li>
58
+
52
59
  </ol>
53
60
  </div>
54
61
 
@@ -0,0 +1,205 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>MotionPrime - the new RubyMotion framework.</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
7
+ <link rel="stylesheet" media="all" href="public/stylesheets/normalize.css" />
8
+ <link rel="stylesheet" media="all" href="docco.css" />
9
+ </head>
10
+ <body>
11
+ <a href="https://github.com/droidlabs/motion-prime"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
12
+ <div class="container">
13
+ <div class="page">
14
+
15
+ <div class="header">
16
+
17
+ <h1>Motion Prime</h1>
18
+
19
+
20
+
21
+ <div class="toc">
22
+ <h3>Table of Contents</h3>
23
+ <ol>
24
+
25
+
26
+ <li>
27
+ <a class="source" href="getting_started.html">
28
+ getting_started.rb
29
+ </a>
30
+ </li>
31
+
32
+
33
+ <li>
34
+ <a class="source" href="models.html">
35
+ models.rb
36
+ </a>
37
+ </li>
38
+
39
+
40
+ <li>
41
+ <a class="source" href="screens.html">
42
+ screens.rb
43
+ </a>
44
+ </li>
45
+
46
+
47
+ <li>
48
+ <a class="source" href="sections.html">
49
+ sections.rb
50
+ </a>
51
+ </li>
52
+
53
+ <li>
54
+ <a class="source" href="tables.html">
55
+ tables.rb
56
+ </a>
57
+ </li>
58
+
59
+ </ol>
60
+ </div>
61
+
62
+ </div>
63
+
64
+
65
+
66
+ <p><strong> Why MotionPrime? </strong></p>
67
+ <p>Did you ever notice that table views in your RubyMotion application scrolls not smoothly?</p>
68
+ <p>Let&#39;s see why:</p>
69
+ <p><img src="https://s3.amazonaws.com/motionprime/prime.png" alt="MotionPrime"></p>
70
+ <p>Each table cell will create 5 UIViews inside and it&#39;s very slow operation for mobile device.
71
+ The main feature of MotionPrime is that it creates abstraction layer for &quot;elements&quot; in screen.
72
+ If it&#39;s possible in current context, MotionPrime will draw elements directly in table cell using CoreGraphics.
73
+ Just add &#39;label&#39; element to the section:</p>
74
+
75
+
76
+ <div class='highlight'><pre><span class="class"><span class="keyword">class</span> <span class="title">MySection</span> <span class="inheritance">&lt; <span class="parent">Prime::Section</span></span></span>
77
+ element <span class="symbol">:greeting</span>, <span class="symbol">text:</span> <span class="string">'Hello World'</span>, <span class="symbol">type:</span> <span class="symbol">:label</span>
78
+ <span class="keyword">end</span></pre></div>
79
+
80
+
81
+
82
+ <p>It will be rendered 5 times faster in iPhone 4/4s for cells containing 5 elements.</p>
83
+ <p>You can force it to use UIView instead of CoreGraphics:</p>
84
+
85
+
86
+ <div class='highlight'><pre><span class="class"><span class="keyword">class</span> <span class="title">MySection</span> <span class="inheritance">&lt; <span class="parent">Prime::Section</span></span></span>
87
+ element <span class="symbol">:greeting</span>, <span class="symbol">text:</span> <span class="string">'Hello World'</span>, <span class="symbol">type:</span> <span class="symbol">:label</span>, <span class="symbol">as:</span> <span class="symbol">:view</span>
88
+ <span class="keyword">end</span></pre></div>
89
+
90
+
91
+
92
+ <p>MotionPrime contains other features to improve application performance, but performance is not the only feature.</p>
93
+ <p>So let&#39;s get started.</p>
94
+ <p><strong>1. Install required tools.</strong></p>
95
+ <ul>
96
+ <li>Ruby 1.9.3 or newer.</li>
97
+ </ul>
98
+
99
+
100
+ <div class='highlight'><pre><span class="variable">$ </span>rvm install <span class="number">2.0</span>.<span class="number">0</span></pre></div>
101
+
102
+
103
+
104
+ <ul>
105
+ <li>RubyMotion.</li>
106
+ </ul>
107
+
108
+
109
+ <div class='highlight'><pre>Visit http://www.rubymotion.com</pre></div>
110
+
111
+
112
+
113
+ <p><strong>2. Create MotionPrime project.</strong></p>
114
+
115
+
116
+ <div class='highlight'><pre><span class="variable">$ </span>gem install motion-prime
117
+ <span class="variable">$ </span>prime new hello</pre></div>
118
+
119
+
120
+
121
+ <p><strong>3. Create application delegate.</strong></p>
122
+ <p>E.g. <code>hello/app/app_delegate.rb</code></p>
123
+ <p>Inherit <code>AppDelegate</code> class from <code>Prime::BaseAppDelegate</code> and rewrite the <code>on_load</code> method, which will be runned after starting application.</p>
124
+
125
+
126
+ <div class='highlight'><pre><span class="class"><span class="keyword">class</span> <span class="title">AppDelegate</span> <span class="inheritance">&lt; <span class="parent">Prime::BaseAppDelegate</span></span></span>
127
+ <span class="function"><span class="keyword">def</span> <span class="title">on_load</span><span class="params">(app, options)</span></span>
128
+ open_screen <span class="symbol">:main</span>
129
+ <span class="keyword">end</span>
130
+ <span class="keyword">end</span></pre></div>
131
+
132
+
133
+
134
+ <p><strong>4. Create the main screen.</strong></p>
135
+ <p>E.g. <code>hello/app/screens/home.rb</code></p>
136
+ <p>Inherit screen from <code>Prime::Screen</code> and rewrite the <code>render</code> method, which will be runned after first opening screen.</p>
137
+
138
+
139
+ <div class='highlight'><pre><span class="class"><span class="keyword">class</span> <span class="title">MainScreen</span> <span class="inheritance">&lt; <span class="parent">Prime::Screen</span></span></span>
140
+ title <span class="string">'Main screen'</span>
141
+
142
+ <span class="function"><span class="keyword">def</span> <span class="title">render</span></span>
143
+ <span class="variable">@main_section</span> = <span class="constant">MyProfileSection</span>.new(<span class="symbol">screen:</span> <span class="keyword">self</span>, <span class="symbol">model:</span> <span class="constant">User</span>.first)
144
+ <span class="variable">@main_section</span>.render
145
+ <span class="keyword">end</span>
146
+ <span class="keyword">end</span></pre></div>
147
+
148
+
149
+
150
+ <p><strong>5. Create your first section.</strong></p>
151
+ <p>E.g. <code>hello/app/sections/home/section.rb</code></p>
152
+ <p>&quot;Section&quot; is something like helper, which contains &quot;Elements&quot;.</p>
153
+ <p>Each element will be added to the parent screen when you run <code>section.render</code></p>
154
+
155
+
156
+ <div class='highlight'><pre><span class="class"><span class="keyword">class</span> <span class="title">HomeSection</span> <span class="inheritance">&lt; <span class="parent">Prime::Section</span></span></span>
157
+ element <span class="symbol">:title</span>, <span class="symbol">text:</span> <span class="string">"Hello World"</span>
158
+ element <span class="symbol">:avatar</span>, <span class="symbol">image:</span> <span class="string">"images/avatar.png"</span>, <span class="symbol">type:</span> <span class="symbol">:image</span>
159
+ <span class="keyword">end</span></pre></div>
160
+
161
+
162
+
163
+ <p><strong>6. Create your first stylesheet file.</strong></p>
164
+ <p>E.g. <code>hello/app/styles/home.rb</code></p>
165
+ <p>Styles will be applied to each element in section.
166
+ The simplest rule by default is: <code>:section-name_:element-name</code>.</p>
167
+ <p>E.g. if you have &quot;MyProfileSection&quot; (the name for section by default will be - <code>my_profile</code>)
168
+ and &quot;title&quot; element, then you should use <code>my_profile_title</code> style name.</p>
169
+
170
+
171
+ <div class='highlight'><pre><span class="constant">Prime::Styles</span>.define <span class="keyword">do</span>
172
+ style <span class="symbol">:my_profile_title</span>, <span class="symbol">width:</span> <span class="number">300</span>, <span class="symbol">height:</span> <span class="number">20</span>
173
+ <span class="keyword">end</span></pre></div>
174
+
175
+
176
+
177
+ <p>You can pass namespace to <code>define</code> method.</p>
178
+
179
+
180
+ <div class='highlight'><pre><span class="constant">Prime::Styles</span>.define <span class="symbol">:my_profile</span> <span class="keyword">do</span>
181
+ style <span class="symbol">:title</span>, <span class="symbol">width:</span> <span class="number">300</span>, <span class="symbol">height:</span> <span class="number">20</span>
182
+ <span class="keyword">end</span></pre></div>
183
+
184
+
185
+
186
+ <p><strong> Next </strong></p>
187
+ <p><a href="screens.html">Read more about Screens</a></p>
188
+
189
+
190
+
191
+ <div class="fleur">h</div>
192
+ </div>
193
+ </div>
194
+ </body>
195
+ </html>
196
+ <script>
197
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
198
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
199
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
200
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
201
+
202
+ ga('create', 'UA-26217236-7', 'droidlabs.pro');
203
+ ga('send', 'pageview');
204
+
205
+ </script>
data/doc/docs/models.html CHANGED
@@ -49,6 +49,13 @@
49
49
  </a>
50
50
  </li>
51
51
 
52
+
53
+ <li>
54
+ <a class="source" href="tables.html">
55
+ tables.rb
56
+ </a>
57
+ </li>
58
+
52
59
  </ol>
53
60
  </div>
54
61
 
@@ -95,6 +102,12 @@
95
102
  <div class='highlight'><pre><span class="constant">Event</span>.all</pre></div>
96
103
 
97
104
 
105
+
106
+ <p><strong> Next </strong></p>
107
+ <p><a href="tables.html">Read more about Tables</a></p>
108
+
109
+
110
+
98
111
  <div class="fleur">h</div>
99
112
  </div>
100
113
  </div>