motion-stylez 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +72 -0
- data/Rakefile +15 -0
- data/app/app_delegate.rb +9 -0
- data/app/controllers/my_controller.rb +14 -0
- data/app/stylesheets/my_stylesheet.rb +13 -0
- data/lib/motion-stylez.rb +7 -0
- data/lib/motion-stylez/base.rb +28 -0
- data/lib/motion-stylez/ext.rb +6 -0
- data/lib/motion-stylez/version.rb +3 -0
- data/motion-stylez.gemspec +23 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3bd7292a67cd3bb09b4967b2d51141a61509aee9
|
4
|
+
data.tar.gz: 0af50715e670038c0253b1986d880c0584dfe51f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 363537296a5174d8a9c11a3c0c097cea1572f95784ab48c3548233ecbafa6b94e623dd9d3b3db6be3b20f40bf2eb6c81e2b604679228cd64548ffe7d5e1a9a42
|
7
|
+
data.tar.gz: b560967aa9b4f2e209a3a81fbd31626bd9473888f65576c87a346c566a3430853865e51932ea3420e7023caf3a7548d9b22862d060f3f67b202bc9fa6e74cc57
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jack Dean Watson-Hamblin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Motion::Stylez
|
2
|
+
|
3
|
+
A super basic RubyMotion stylesheet library based off Todd Werth's [RMQ library](https://github.com/infinitered/rmq) that lets you centralize your view styles.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'motion-stylez'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install motion-stylez
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
You can use the `z` method from anywhere in your application.
|
22
|
+
|
23
|
+
First you will need to set your stylesheet.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
z.stylesheet = MyStylesheet.new
|
27
|
+
```
|
28
|
+
|
29
|
+
Then create your stylesheet and it's styles.
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
class MyStylesheet
|
33
|
+
def bw_big(v)
|
34
|
+
v.backgroundColor = UIColor.blackColor
|
35
|
+
v.textColor = UIColor.whiteColor
|
36
|
+
v.font = UIFont.systemFontOfSize(36)
|
37
|
+
v.frame = [[20, 40], [280, 50]]
|
38
|
+
v.textAlignment = UITextAlignmentCenter
|
39
|
+
end
|
40
|
+
|
41
|
+
def white_bg(v)
|
42
|
+
v.backgroundColor = UIColor.whiteColor
|
43
|
+
end
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
Then you can use the `z` method to create your styled view, which you can also pass a block to. For example, use in a controller.
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
class MyViewController < UIViewController
|
51
|
+
def viewDidLoad
|
52
|
+
super
|
53
|
+
|
54
|
+
z.stylesheet = MyStylesheet.new # works absolutely anywhere
|
55
|
+
|
56
|
+
z(self.view).style(:white_bg)
|
57
|
+
|
58
|
+
self.view.addSubview(z(UILabel).style(:bw_big) do |v|
|
59
|
+
v.text = "Testing"
|
60
|
+
end)
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
## Contributing
|
67
|
+
|
68
|
+
1. Fork it ( http://github.com/FluffyJack/motion-stylez/fork )
|
69
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
70
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
71
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
72
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$:.unshift("/Library/RubyMotion/lib")
|
2
|
+
require 'motion/project/template/ios'
|
3
|
+
|
4
|
+
require 'bundler'
|
5
|
+
Bundler.require(:development)
|
6
|
+
|
7
|
+
require 'motion-stylez'
|
8
|
+
|
9
|
+
Motion::Project::App.setup do |app|
|
10
|
+
app.name = 'MotionStylezTest'
|
11
|
+
app.version = MotionStylez::VERSION
|
12
|
+
app.redgreen_style = :full
|
13
|
+
app.deployment_target = "7.0"
|
14
|
+
app.detect_dependencies = true
|
15
|
+
end
|
data/app/app_delegate.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
class MyViewController < UIViewController
|
2
|
+
def viewDidLoad
|
3
|
+
super
|
4
|
+
|
5
|
+
z.stylesheet = MyStylesheet.new # works absolutely anywhere
|
6
|
+
|
7
|
+
z(self.view).style(:white_bg)
|
8
|
+
|
9
|
+
self.view.addSubview(z(UILabel).style(:bw_big) do |v|
|
10
|
+
v.text = "Testing"
|
11
|
+
end)
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class MyStylesheet
|
2
|
+
def bw_big(v)
|
3
|
+
v.backgroundColor = UIColor.blackColor
|
4
|
+
v.textColor = UIColor.whiteColor
|
5
|
+
v.font = UIFont.systemFontOfSize(36)
|
6
|
+
v.frame = [[20, 40], [280, 50]]
|
7
|
+
v.textAlignment = UITextAlignmentCenter
|
8
|
+
end
|
9
|
+
|
10
|
+
def white_bg(v)
|
11
|
+
v.backgroundColor = UIColor.whiteColor
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module MotionStylez
|
2
|
+
class Base
|
3
|
+
attr_accessor :stylesheet, :selector
|
4
|
+
|
5
|
+
def self.shared
|
6
|
+
Dispatch.once { @shared ||= new }
|
7
|
+
@shared
|
8
|
+
end
|
9
|
+
|
10
|
+
def style(style_name)
|
11
|
+
begin
|
12
|
+
puts "\[STYLEZ ERROR] no stylesheet selected" unless self.stylesheet
|
13
|
+
|
14
|
+
view = self.selector
|
15
|
+
view = view.new if view.class == Class
|
16
|
+
self.stylesheet.public_send(style_name, view)
|
17
|
+
yield view if block_given?
|
18
|
+
view
|
19
|
+
rescue NoMethodError => e
|
20
|
+
if e.message =~ /.*#{style_name.to_s}.*/
|
21
|
+
puts "\n[STYLEZ ERROR] style_name :#{style_name} doesn't exist for a #{view.class.name}. Add 'def #{style_name}(v)' to #{stylesheet.class.name} class\n\n"
|
22
|
+
else
|
23
|
+
raise e
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'motion-stylez/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "motion-stylez"
|
8
|
+
spec.version = MotionStylez::VERSION
|
9
|
+
spec.authors = ["Jack Dean Watson-Hamblin"]
|
10
|
+
spec.email = ["info@fluffyjack.com"]
|
11
|
+
spec.summary = %q{RubyMotion stylesheet library based off RMQ (https://github.com/infinitered/rmq)}
|
12
|
+
spec.description = %q{A super basic RubyMotion stylesheet library based off Todd Werth's RMQ library (https://github.com/infinitered/rmq) that lets you centralize your view styles}
|
13
|
+
spec.homepage = "https://github.com/FluffyJack/motion-stylez"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.test_files = spec.files.grep(%r{^(spec)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", ">= 1.3.5"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "motion-redgreen"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion-stylez
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jack Dean Watson-Hamblin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.5
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.3.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: motion-redgreen
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A super basic RubyMotion stylesheet library based off Todd Werth's RMQ
|
56
|
+
library (https://github.com/infinitered/rmq) that lets you centralize your view
|
57
|
+
styles
|
58
|
+
email:
|
59
|
+
- info@fluffyjack.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- app/app_delegate.rb
|
70
|
+
- app/controllers/my_controller.rb
|
71
|
+
- app/stylesheets/my_stylesheet.rb
|
72
|
+
- lib/motion-stylez.rb
|
73
|
+
- lib/motion-stylez/base.rb
|
74
|
+
- lib/motion-stylez/ext.rb
|
75
|
+
- lib/motion-stylez/version.rb
|
76
|
+
- motion-stylez.gemspec
|
77
|
+
homepage: https://github.com/FluffyJack/motion-stylez
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.1.11
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: RubyMotion stylesheet library based off RMQ (https://github.com/infinitered/rmq)
|
101
|
+
test_files: []
|