motion-font-icon 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +0 -0
- data/lib/motion-font-icon.rb +8 -0
- data/lib/project/motion-font-icon.rb +56 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 100a19dc8615a246e61a7dc0c55c72311b078f4f
|
4
|
+
data.tar.gz: 931ce1a884ac258e1b1811ece0f7ce22d9a1b5a2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a5dcd99f9b813ab64435b05bf0e6cca13854a88e8afc23ee76962564786aa905b23299c9e3f57171534370507a563b6217ff2db3771089bc6074f11f1050be37
|
7
|
+
data.tar.gz: 8ce98f7132f6d3f8d7804fbe889565564a0a8a3d142b195a11bf64583abc1e4ecf8cefbd1188d26447c32467f63f7d1a6eaa3a8b9106c3b30ce419eabe8cbe59
|
data/README.md
ADDED
File without changes
|
@@ -0,0 +1,8 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise 'This file must be required within a RubyMotion project Rakefile.'
|
3
|
+
end
|
4
|
+
|
5
|
+
lib_dir_path = File.dirname(File.expand_path(__FILE__))
|
6
|
+
Motion::Project::App.setup do |app|
|
7
|
+
app.files.unshift(Dir.glob(File.join(lib_dir_path, 'project/**/*.rb')))
|
8
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class Motion
|
2
|
+
class FontIconConfig
|
3
|
+
attr_accessor :icon_mapper, :font
|
4
|
+
end
|
5
|
+
|
6
|
+
class FontIcon < UILabel
|
7
|
+
DEFAULT_ICON_SIZE = 14.0
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def configure
|
11
|
+
yield config if block_given?
|
12
|
+
end
|
13
|
+
|
14
|
+
def config
|
15
|
+
@config ||= FontIconConfig.new
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def initWithFrame(frame)
|
20
|
+
super.tap do |label|
|
21
|
+
label.textAlignment = NSTextAlignmentCenter
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def layoutSubviews
|
26
|
+
raise ArgumentError, '`font` must be set via FontIcon.configure or FontIcon#configure' if config.font.nil?
|
27
|
+
|
28
|
+
self.font = UIFont.fontWithName(config.font, size: DEFAULT_ICON_SIZE)
|
29
|
+
end
|
30
|
+
|
31
|
+
def icon=(icon)
|
32
|
+
self.text = config.icon_mapper ? config.icon_mapper.call(icon) : icon
|
33
|
+
end
|
34
|
+
|
35
|
+
def font_size=(size)
|
36
|
+
@font_size = size
|
37
|
+
|
38
|
+
reset_font
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def configure
|
44
|
+
yield config if block_given?
|
45
|
+
end
|
46
|
+
|
47
|
+
def config
|
48
|
+
@config ||= self.class.config
|
49
|
+
end
|
50
|
+
|
51
|
+
def reset_font
|
52
|
+
self.font = UIFont.fontWithName('dscovr', size: font_size || DEFAULT_ICON_SIZE)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion-font-icon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Devon Blandin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Simple font icon support
|
28
|
+
email:
|
29
|
+
- dblandin@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- README.md
|
35
|
+
- lib/motion-font-icon.rb
|
36
|
+
- lib/project/motion-font-icon.rb
|
37
|
+
homepage: https://github.com/dblandin/motion-font-icon
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.1.1
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Simple font icon support
|
61
|
+
test_files: []
|