walt 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +14 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +61 -0
- data/LICENSE +26 -0
- data/README.md +193 -0
- data/Rakefile +17 -0
- data/app/app_delegate.rb +71 -0
- data/examples/Apple/.gitignore +13 -0
- data/examples/Apple/Rakefile +14 -0
- data/examples/Apple/app/app_delegate.rb +99 -0
- data/examples/Apple/spec/main_spec.rb +9 -0
- data/examples/Apple/vendor/Podfile.lock +11 -0
- data/examples/Bouncing/.gitignore +13 -0
- data/examples/Bouncing/Rakefile +14 -0
- data/examples/Bouncing/app/app_delegate.rb +49 -0
- data/examples/Bouncing/spec/main_spec.rb +9 -0
- data/examples/Bouncing/vendor/Podfile.lock +11 -0
- data/lib/walt.rb +27 -0
- data/lib/walt/animation.rb +124 -0
- data/lib/walt/animation_set.rb +64 -0
- data/lib/walt/asset/asset.rb +79 -0
- data/lib/walt/asset/image.rb +48 -0
- data/lib/walt/asset/text.rb +64 -0
- data/lib/walt/operation/base.rb +60 -0
- data/lib/walt/operation/fade.rb +35 -0
- data/lib/walt/operation/move.rb +73 -0
- data/lib/walt/operation/rotate.rb +41 -0
- data/lib/walt/operation/scale.rb +41 -0
- data/lib/walt/patch/ui_color.rb +5 -0
- data/lib/walt/support/attr_default.rb +16 -0
- data/lib/walt/support/const_get.rb +60 -0
- data/lib/walt/support/font.rb +87 -0
- data/lib/walt/version.rb +3 -0
- data/lib/walt/walt.rb +53 -0
- data/spec/animation_set_spec.rb +49 -0
- data/spec/animation_spec.rb +128 -0
- data/spec/asset/image_spec.rb +16 -0
- data/spec/asset/text_spec.rb +24 -0
- data/spec/asset_spec.rb +11 -0
- data/spec/main_spec.rb +9 -0
- data/spec/operation/fade_spec.rb +25 -0
- data/spec/operation/move_spec.rb +43 -0
- data/spec/operation_spec.rb +26 -0
- data/spec/support_spec.rb +46 -0
- data/vendor/Podfile.lock +11 -0
- data/walt.gemspec +21 -0
- metadata +172 -0
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
walt (0.1)
|
5
|
+
afmotion (>= 0.4)
|
6
|
+
bubble-wrap (>= 1.1.4)
|
7
|
+
motion-cocoapods (~> 1.2.1)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (3.2.9)
|
13
|
+
i18n (~> 0.6)
|
14
|
+
multi_json (~> 1.0)
|
15
|
+
addressable (2.3.2)
|
16
|
+
afmotion (0.4)
|
17
|
+
motion-cocoapods (>= 1.2.1)
|
18
|
+
bubble-wrap (1.1.4)
|
19
|
+
cocoapods (0.16.0)
|
20
|
+
activesupport (~> 3.2.6)
|
21
|
+
colored (~> 1.2)
|
22
|
+
escape (~> 0.0.4)
|
23
|
+
faraday (~> 0.8.1)
|
24
|
+
json (~> 1.7.3)
|
25
|
+
octokit (~> 1.7)
|
26
|
+
open4 (~> 1.3.0)
|
27
|
+
rake (~> 0.9.4)
|
28
|
+
xcodeproj (~> 0.4.0)
|
29
|
+
colored (1.2)
|
30
|
+
escape (0.0.4)
|
31
|
+
faraday (0.8.4)
|
32
|
+
multipart-post (~> 1.1)
|
33
|
+
faraday_middleware (0.9.0)
|
34
|
+
faraday (>= 0.7.4, < 0.9)
|
35
|
+
hashie (1.2.0)
|
36
|
+
i18n (0.6.1)
|
37
|
+
json (1.7.6)
|
38
|
+
motion-cocoapods (1.2.1)
|
39
|
+
cocoapods (>= 0.14.0)
|
40
|
+
multi_json (1.5.0)
|
41
|
+
multipart-post (1.1.5)
|
42
|
+
netrc (0.7.7)
|
43
|
+
octokit (1.20.0)
|
44
|
+
addressable (~> 2.2)
|
45
|
+
faraday (~> 0.8)
|
46
|
+
faraday_middleware (~> 0.9)
|
47
|
+
hashie (~> 1.2)
|
48
|
+
multi_json (~> 1.3)
|
49
|
+
netrc (~> 0.7.7)
|
50
|
+
open4 (1.3.0)
|
51
|
+
rake (0.9.6)
|
52
|
+
xcodeproj (0.4.0)
|
53
|
+
activesupport (~> 3.2.6)
|
54
|
+
colored (~> 1.2)
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
ruby
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
rake
|
61
|
+
walt!
|
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
LICENSE
|
2
|
+
|
3
|
+
MIT: http://clayallsopp.mit-license.org
|
4
|
+
|
5
|
+
------------------------------------------------
|
6
|
+
|
7
|
+
The MIT License (MIT)
|
8
|
+
Copyright © 2012 Clay Allsopp <clay.allsopp@gmail.com>
|
9
|
+
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
11
|
+
of this software and associated documentation files (the “Software”), to deal
|
12
|
+
in the Software without restriction, including without limitation the rights
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
15
|
+
furnished to do so, subject to the following conditions:
|
16
|
+
|
17
|
+
The above copyright notice and this permission notice shall be included in
|
18
|
+
all copies or substantial portions of the Software.
|
19
|
+
|
20
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
26
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
# Walt
|
2
|
+
|
3
|
+
Make this:
|
4
|
+
|
5
|
+
![Walt animation](http://i.imgur.com/yd4RJ.gif)
|
6
|
+
|
7
|
+
Using this:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
@view = UIView.alloc.initWithFrame(....)
|
11
|
+
|
12
|
+
Walt.animate(
|
13
|
+
assets: [{
|
14
|
+
id: "logo",
|
15
|
+
position: [100, 0],
|
16
|
+
size: [110, 40],
|
17
|
+
url: "http://bit.ly/S98Ta5"
|
18
|
+
}],
|
19
|
+
animations: [{
|
20
|
+
duration: 2,
|
21
|
+
operations: [{
|
22
|
+
move: "logo",
|
23
|
+
to: 150,
|
24
|
+
axis: :y
|
25
|
+
}],
|
26
|
+
after: {
|
27
|
+
duration: 2,
|
28
|
+
operations: [{
|
29
|
+
rotate: "logo",
|
30
|
+
to: 360
|
31
|
+
}]
|
32
|
+
}
|
33
|
+
}],
|
34
|
+
in: @view
|
35
|
+
)
|
36
|
+
```
|
37
|
+
|
38
|
+
## Installation
|
39
|
+
|
40
|
+
First install the `Walt` gem:
|
41
|
+
|
42
|
+
`gem install walt`
|
43
|
+
|
44
|
+
Add `Walt` to your Gemfile or require it in your `Rakefile`:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
require 'walt'
|
48
|
+
```
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
gem 'walt'
|
52
|
+
```
|
53
|
+
|
54
|
+
Finally, add [AFNetworking](https://github.com/AFNetworking/AFNetworking) to your `pods`:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
app.pods do
|
58
|
+
pod "AFNetworking"
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
## Usage
|
63
|
+
|
64
|
+
Walt is organized around `assets`, `animations`, and `operations`. Each `animation` is a collection of `operations` occuring at the same time and configuration.
|
65
|
+
|
66
|
+
### Assets
|
67
|
+
|
68
|
+
Walt supports arbitrary `UIView`s as assets, and can also build some types of views from hashes. Constructor hashes include:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
# Uses an existing `UIView`
|
72
|
+
{ id: "my_id", view: UIView.alloc.initWithFrame(...) }
|
73
|
+
|
74
|
+
# Creates a new `UIView`
|
75
|
+
# All Walt::Assets support these options:
|
76
|
+
# :position, :size, :view, :content_mode, :clips_to_bounds, :background_color
|
77
|
+
{ id: "my_id", size: [100,100], background_color: "0088cc" }
|
78
|
+
|
79
|
+
# Creates a new `UILabel`; also supports:
|
80
|
+
# :text_color, :background_color, :number_of_lines, :font, :text_alignment
|
81
|
+
{ id: "my_id", text: "Hello World" }
|
82
|
+
|
83
|
+
# Creates a new `UIImageView`
|
84
|
+
# No animations will start until all
|
85
|
+
# remotely-loaded assets have loaded
|
86
|
+
{ id: "my_id", url: "http://imgur.com/hello.png" }
|
87
|
+
|
88
|
+
```
|
89
|
+
|
90
|
+
### Operations
|
91
|
+
|
92
|
+
Walt comes with a few nifty operations, and adding your own is easy.
|
93
|
+
|
94
|
+
#### `Move`
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
{
|
98
|
+
move: "my_id",
|
99
|
+
from: [10, 10],
|
100
|
+
to: [50, 50]
|
101
|
+
}
|
102
|
+
```
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
{
|
106
|
+
move: "my_id",
|
107
|
+
from: 0,
|
108
|
+
to: 100,
|
109
|
+
axis: :y # also supports :x
|
110
|
+
}
|
111
|
+
```
|
112
|
+
|
113
|
+
#### `Rotate`
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
{
|
117
|
+
fade: "my_id",
|
118
|
+
from: 20, # in degrees
|
119
|
+
to: 50
|
120
|
+
}
|
121
|
+
```
|
122
|
+
|
123
|
+
#### `Fade`
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
{
|
127
|
+
fade: "my_id",
|
128
|
+
from: 1.0,
|
129
|
+
to: 0.2
|
130
|
+
}
|
131
|
+
```
|
132
|
+
|
133
|
+
#### `Scale`
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
{
|
137
|
+
scale: "my_id",
|
138
|
+
from: 1.0,
|
139
|
+
to: 1.3
|
140
|
+
}
|
141
|
+
```
|
142
|
+
|
143
|
+
#### Adding your own
|
144
|
+
|
145
|
+
Create a subclass of `Walt::Operation::Base` with a name of the form `____Operation` (i.e. `FancyOperation`). In your class, implement `def setup(view, animation)` and `def finalize(view, animation)`. Then, you can use a hash of the form `{fancy: "my_id"}` to use that operation.
|
146
|
+
|
147
|
+
Example:
|
148
|
+
|
149
|
+
```ruby
|
150
|
+
module Walt
|
151
|
+
module Operation
|
152
|
+
class FancyOperation < Base
|
153
|
+
|
154
|
+
# run before animation starts
|
155
|
+
def setup(view, animation)
|
156
|
+
...
|
157
|
+
end
|
158
|
+
|
159
|
+
# make changes to animate
|
160
|
+
def finalize(view, animation)
|
161
|
+
...
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
Walt.animate(...
|
167
|
+
{
|
168
|
+
fancy: "my_id"
|
169
|
+
}
|
170
|
+
)
|
171
|
+
```
|
172
|
+
|
173
|
+
|
174
|
+
### Animations
|
175
|
+
|
176
|
+
Animations control the timing and configuration of operations. They support `:delay` and `:duration` settings which affect timing, and a `:options` setting which you can pass a list of `UIViewAnimationOption`s for that animation.
|
177
|
+
|
178
|
+
Animations can be chained using an animation's `:after` property, which takes another animation hash.
|
179
|
+
|
180
|
+
```ruby
|
181
|
+
# Also applies to Walt.animate
|
182
|
+
{
|
183
|
+
delay: 0.3,
|
184
|
+
duration: 2.2,
|
185
|
+
options: [:curve_ease_in, :begin_from_current_state],
|
186
|
+
operations: [...],
|
187
|
+
after: {
|
188
|
+
delay: 1.0,
|
189
|
+
duration: 1.0,
|
190
|
+
...
|
191
|
+
}
|
192
|
+
}
|
193
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
$:.unshift("/Library/RubyMotion/lib")
|
3
|
+
require 'motion/project'
|
4
|
+
require "bundler/gem_tasks"
|
5
|
+
require "bundler/setup"
|
6
|
+
|
7
|
+
$:.unshift("./lib/")
|
8
|
+
require './lib/walt'
|
9
|
+
|
10
|
+
Motion::Project::App.setup do |app|
|
11
|
+
# Use `rake config' to see complete project settings.
|
12
|
+
app.name = 'Walt'
|
13
|
+
|
14
|
+
app.pods do
|
15
|
+
pod "AFNetworking"
|
16
|
+
end
|
17
|
+
end
|
data/app/app_delegate.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
class AppDelegate
|
2
|
+
attr_reader :animation, :asset
|
3
|
+
def application(application, didFinishLaunchingWithOptions:launchOptions)
|
4
|
+
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
|
5
|
+
|
6
|
+
@window.makeKeyAndVisible
|
7
|
+
|
8
|
+
Walt.animate(
|
9
|
+
assets: [{
|
10
|
+
id: :blue,
|
11
|
+
url: "http://upload.wikimedia.org/wikipedia/commons/3/30/Googlelogo.png",
|
12
|
+
size: [300,100]
|
13
|
+
}, {
|
14
|
+
id: :red,
|
15
|
+
text: "Hello World",
|
16
|
+
text_color: "white",
|
17
|
+
position: [20, 50]
|
18
|
+
}],
|
19
|
+
animations:[{
|
20
|
+
duration: 3,
|
21
|
+
operations:[{
|
22
|
+
fade: :red,
|
23
|
+
from: 0.0,
|
24
|
+
to: 1.0
|
25
|
+
}, {
|
26
|
+
scale: :blue,
|
27
|
+
from: 1.0,
|
28
|
+
to: 2.0
|
29
|
+
}, {
|
30
|
+
move: :blue,
|
31
|
+
to: 100
|
32
|
+
}, {
|
33
|
+
fade: :blue,
|
34
|
+
from: 0.0,
|
35
|
+
to: 0.5
|
36
|
+
}],
|
37
|
+
after: {
|
38
|
+
duration: 2,
|
39
|
+
operations:[{
|
40
|
+
rotate: :blue,
|
41
|
+
to: 40
|
42
|
+
},{
|
43
|
+
scale: :blue,
|
44
|
+
to: 1.0
|
45
|
+
}, {
|
46
|
+
move: :blue,
|
47
|
+
to: 50
|
48
|
+
}, {
|
49
|
+
fade: :blue,
|
50
|
+
from: 0.5,
|
51
|
+
to: 1.0
|
52
|
+
}],
|
53
|
+
after: {
|
54
|
+
duration: 2,
|
55
|
+
operations: [{
|
56
|
+
rotate: :blue,
|
57
|
+
to: 0
|
58
|
+
},{
|
59
|
+
move: :blue,
|
60
|
+
axis: :y,
|
61
|
+
to: 150
|
62
|
+
}]
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}],
|
66
|
+
in: @window
|
67
|
+
)
|
68
|
+
|
69
|
+
true
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
$:.unshift("/Library/RubyMotion/lib")
|
3
|
+
require 'motion/project'
|
4
|
+
$:.unshift("../../lib")
|
5
|
+
require '../../lib/walt'
|
6
|
+
|
7
|
+
Motion::Project::App.setup do |app|
|
8
|
+
# Use `rake config' to see complete project settings.
|
9
|
+
app.name = 'Apple'
|
10
|
+
|
11
|
+
app.pods do
|
12
|
+
pod "AFNetworking"
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
class AppDelegate
|
2
|
+
def application(application, didFinishLaunchingWithOptions:launchOptions)
|
3
|
+
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
|
4
|
+
@window.backgroundColor = UIColor.whiteColor
|
5
|
+
@window.makeKeyAndVisible
|
6
|
+
|
7
|
+
Walt.animate(
|
8
|
+
assets: [{
|
9
|
+
id: "google",
|
10
|
+
position: [105, 0],
|
11
|
+
size: [110, 40],
|
12
|
+
url: "http://bit.ly/S98Ta5"
|
13
|
+
}, {
|
14
|
+
id: "apple",
|
15
|
+
position: [110, UIScreen.mainScreen.bounds.size.height],
|
16
|
+
size: [90, 80],
|
17
|
+
url: "http://i.imgur.com/2ibBO.png"
|
18
|
+
}, {
|
19
|
+
id: "think",
|
20
|
+
text: "Think Different",
|
21
|
+
position: [100, 130]
|
22
|
+
}],
|
23
|
+
animations: [{
|
24
|
+
duration: 0,
|
25
|
+
operations: [{
|
26
|
+
fade: "think",
|
27
|
+
to: 0
|
28
|
+
}]
|
29
|
+
}, {
|
30
|
+
duration: 2,
|
31
|
+
operations: [{
|
32
|
+
move: "google",
|
33
|
+
to: 150,
|
34
|
+
axis: :y
|
35
|
+
}],
|
36
|
+
after: {
|
37
|
+
duration: 0.5,
|
38
|
+
operations: [{
|
39
|
+
rotate: "google",
|
40
|
+
to: -90
|
41
|
+
}],
|
42
|
+
after: {
|
43
|
+
delay: 1.25,
|
44
|
+
duration: 0.5,
|
45
|
+
operations: [{
|
46
|
+
fade: "google",
|
47
|
+
from: 1.0,
|
48
|
+
to: 0.0
|
49
|
+
}]
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}, {
|
53
|
+
duration: 2,
|
54
|
+
operations: [{
|
55
|
+
move: "apple",
|
56
|
+
to: 220,
|
57
|
+
axis: :y
|
58
|
+
}],
|
59
|
+
after: {
|
60
|
+
duration: 0.5,
|
61
|
+
operations: [{
|
62
|
+
rotate: "apple",
|
63
|
+
to: -90
|
64
|
+
}, {
|
65
|
+
scale: "apple",
|
66
|
+
to: 1.2
|
67
|
+
}],
|
68
|
+
after: {
|
69
|
+
delay: 1,
|
70
|
+
duration: 1.5,
|
71
|
+
operations: [{
|
72
|
+
move: "apple",
|
73
|
+
to: 40,
|
74
|
+
axis: :y
|
75
|
+
}],
|
76
|
+
after: {
|
77
|
+
delay: 1,
|
78
|
+
duration: 0.5,
|
79
|
+
operations: [{
|
80
|
+
rotate: "apple",
|
81
|
+
to: 0
|
82
|
+
}],
|
83
|
+
after: {
|
84
|
+
duration: 1,
|
85
|
+
operations: [{
|
86
|
+
fade: "think",
|
87
|
+
to: 1.0
|
88
|
+
}]
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}],
|
94
|
+
in: @window
|
95
|
+
)
|
96
|
+
|
97
|
+
true
|
98
|
+
end
|
99
|
+
end
|