motion-prime 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +6 -1
- data/ROADMAP.md +7 -6
- data/bin/prime +31 -16
- data/doc/code/models.rb +5 -1
- data/doc/code/tables.rb +54 -0
- data/doc/docs/getting_started.html +7 -0
- data/doc/docs/index.html +205 -0
- data/doc/docs/models.html +13 -0
- data/doc/docs/screens.html +7 -0
- data/doc/docs/sections.html +7 -0
- data/doc/docs/tables.html +128 -0
- data/files/Gemfile +3 -3
- data/lib/motion-prime.rb +2 -0
- data/motion-prime.gemspec +3 -2
- data/motion-prime/api_client.rb +35 -36
- data/motion-prime/config/base.rb +0 -2
- data/motion-prime/core_ext/kernel.rb +2 -1
- data/motion-prime/elements/base_element.rb +7 -2
- data/motion-prime/elements/spinner.rb +7 -0
- data/motion-prime/elements/table_view.rb +7 -0
- data/motion-prime/helpers/has_search_bar.rb +11 -5
- data/motion-prime/models/_finder_mixin.rb +5 -12
- data/motion-prime/models/_nano_bag_mixin.rb +1 -1
- data/motion-prime/models/_sync_mixin.rb +52 -37
- data/motion-prime/screens/_base_mixin.rb +4 -0
- data/motion-prime/screens/_navigation_mixin.rb +3 -3
- data/motion-prime/screens/screen.rb +1 -1
- data/motion-prime/sections/base_section.rb +12 -12
- data/motion-prime/sections/form/base_field_section.rb +1 -1
- data/motion-prime/sections/form/date_field_section.rb +5 -0
- data/motion-prime/sections/form/password_field_section.rb +1 -1
- data/motion-prime/sections/form/string_field_section.rb +1 -1
- data/motion-prime/sections/form/text_field_section.rb +1 -1
- data/motion-prime/sections/table.rb +7 -0
- data/motion-prime/sections/table/table_delegate.rb +14 -4
- data/motion-prime/support/mp_spinner.rb +16 -0
- data/motion-prime/support/mp_table_view.rb +6 -0
- data/motion-prime/support/tab_bar_controller.rb +3 -3
- data/motion-prime/support/temp_fixes.rb +6 -0
- data/motion-prime/version.rb +1 -1
- data/motion-prime/views/layout.rb +2 -1
- data/motion-prime/views/view_builder.rb +1 -1
- metadata +24 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmU3NjAzNmZmNTZhOTZmZjczN2Y4MjFiMTcxOTI5ODVhZDdmZTI5OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWI3ZDRiMWVkYzE2MmJkNzYzZjRmNTc1MGY2YjE1ZTUyYWJhNDNhNw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDgyODhmMjQyMzhiNTM0OTA1OWE5NTQ0OGM0ZTYwZDkxNjk1NDVmOTU1MmY1
|
10
|
+
N2RmNzA2NDY1YzA2Yjc1YWNlZjgxY2JmODcyODdmOTBiYzA5ZmQ1ZGVjZTAy
|
11
|
+
OGI5ZmRiNWRmMTEzNmI4OTYzZjc5ZTZiZGViNWRlMTMzNDliNGM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGU5ZDFmMzczNWI5ODVlYjc5OWUyNDIyYjQ2OTdmNjlkNGJmYWQ4MjI3MjZi
|
14
|
+
MGQwMTg0ZWYwMTYzYTBlNGIwYjc0MzQ1MGQ1NWE3MDlmYzljN2M4NmI0YjRl
|
15
|
+
NGMzNjA0NjNhZGYxZmY2M2I5NzdkNzU4OGMzOTlmZDdiYThhNGI=
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
motion-prime (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.
|
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.
|
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.
|
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
|
-
|
31
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
data/doc/code/tables.rb
ADDED
@@ -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
|
data/doc/docs/index.html
ADDED
@@ -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'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's very slow operation for mobile device.
|
71
|
+
The main feature of MotionPrime is that it creates abstraction layer for "elements" in screen.
|
72
|
+
If it's possible in current context, MotionPrime will draw elements directly in table cell using CoreGraphics.
|
73
|
+
Just add 'label' 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">< <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">< <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'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">< <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">< <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>"Section" is something like helper, which contains "Elements".</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">< <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 "MyProfileSection" (the name for section by default will be - <code>my_profile</code>)
|
168
|
+
and "title" 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>
|