motion-ios-simplesplash 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0212c1e187061817d7bfde5cefe746e9dd2cfc01e0217561e1189f279c0188c8
4
+ data.tar.gz: d3c070943fba0c9514175925b6399f4e86bf067c2457b2cd62952649adbfe412
5
+ SHA512:
6
+ metadata.gz: abd4a71a18852c60cc8bce6b3c578f1344e16bf00934a1cad5480f6e930c005e63d4cfa447fd56b1ca3b92debcad6a77c0909a72353cf8c79422e2e76028c30b
7
+ data.tar.gz: efa168da3249ca4effde48273a88f04df3d6b501ce0c823bb2fbb46b828e503f2d051e88de8c876b1ae69880f0efb24e612073ddbf9f73d1e73c61e9c6bf7440
@@ -0,0 +1,59 @@
1
+ # RubyMotion SimpleSplash
2
+
3
+ Generate a simple splash page to be used in iOS projects, that uses autolayout to fit all devices.
4
+
5
+ Currently the library will use a default colour definition or you can specify a colour by definition (RGB).
6
+
7
+ ### Background
8
+
9
+ I needed a quick, brain-dead simple way of adding a splash screen for my iOS projects. I was adding the `ib` gem, generating the storybaord, opening Xcode and then editing it. All to create a fairly simple XML file that really didn't need all of those extra steps.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'motion-ios-simplesplash'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install motion-ios-simplesplash
24
+
25
+ ## Usage
26
+
27
+ ```bash
28
+ $ bundle exec rake generate:simple_splash
29
+ ```
30
+
31
+ This will generate the file `SimpleSplash.storyboard` in the resources directory of your project. RubyMotion will automatically compile this files and copy it to your application resources. You will need to specify that the storyboard file should be used as the splash screen. This is done by adding the following to your `Rakefile`:
32
+
33
+ ```ruby
34
+ app.info_plist['UILaunchStoryboardName'] = 'SimpleSplash'
35
+ ```
36
+
37
+ You can edit the storyboard file once it has been produced if it is not exactly to your liking. You may or may not need to include the `ib` gem and then open using Xcode. Those of you wanting to get your *XML on* can simply open the storyboard file (it is just and XML text file) and hack. YMMV
38
+
39
+ The `rake` command above will generate a splash screen with the default background (light gray- Red: 224, Green: 226, Blue: 220). However you can run the command and specify the RGB values to allow you to create a splash screen that matches your application's colour scheme. The values for red, green and blue are in the range 0-255. For example, to create a splash screen with a vibrant yellow background (Red: 255, Green: 255, Blue: 0), execute the following:
40
+
41
+ ```bash
42
+ $ bundle exec rake generate:simple_splash[255,255,0]
43
+ ```
44
+
45
+ If there is an existing splash screen file, it will be overwritten with the new values. This is helpful, as you can update the splash screen any time you wish.
46
+
47
+ ### Caution
48
+ Rerunning the `rake generate:simple_splash` will replace the current `SimpleSplash.storyboard` file with a freshly generated version. Good if you are recovering from a mistaken edit, not so good if you had changes that you wanted to keep. Make a backup if you have changes you wish to save before re-executing the command.
49
+
50
+ ### Additional Considerations
51
+ For most projects, the motion-ios-simplesplash will be single use. Once you have generated your splash screen you are done. If you wish, you can remove the gem from your `Gemfile` once your splash storyboard has been generated, there are no build or runtime dependencies.
52
+
53
+ ## Contributing
54
+
55
+ 1. Fork it
56
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
57
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
58
+ 4. Push to the branch (`git push origin my-new-feature`)
59
+ 5. Create new Pull Request
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ unless defined?(Motion::Project::Config)
4
+ raise "This file must be required within a RubyMotion project Rakefile."
5
+ end
6
+
7
+ lib_dir_path = File.dirname(File.expand_path(__FILE__))
8
+
9
+ require File.join(lib_dir_path, "tasks/motion-ios-simplesplash.rb")
@@ -0,0 +1,154 @@
1
+ require 'builder'
2
+
3
+ module SimpleSplash
4
+
5
+ module Storyboard
6
+ StoryboardItem = Struct.new(:name, :attributes, :entries) do
7
+ def to_xml(xml)
8
+ if attributes && attributes.size > 0
9
+ if entries && entries.size > 0
10
+ xml.tag!(name, attributes) do |xml|
11
+ entries.each do |entry|
12
+ entry.to_xml(xml)
13
+ end
14
+ end
15
+ else
16
+ xml.tag!(name, attributes)
17
+ end
18
+ else
19
+ if entries && entries.size > 0
20
+ xml.tag!(name) do |xml|
21
+ entries.each do |entry|
22
+ entry.to_xml(xml)
23
+ end
24
+ end
25
+ else
26
+ xml.tag!(name)
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ BASE_COLOUR = {name: "backgroundColor", red: 224, green: 226, blue: 220}
33
+
34
+ def self.build(vc_id, colours=[])
35
+ unless colours && colours.size > 0
36
+ colours = [BASE_COLOUR]
37
+ end
38
+ # bg_colour_name = colours[0][:name]
39
+
40
+ StoryboardItem.new('document', { type: "com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB",
41
+ version: "3.0", toolsVersion: "14460.31",
42
+ targetRuntime: "iOS.CocoaTouch",
43
+ propertyAccessControl: "none", useAutolayout: "YES",
44
+ useTraitCollections: "YES", useSafeAreas: "YES",
45
+ colorMatched: "YES", initialViewController: vc_id },
46
+ [ StoryboardItem.new('device', {id: "retina4_7", orientation: "portrait"},
47
+ [StoryboardItem.new("adaptation", {id: "fullscreen" })]),
48
+ StoryboardItem.new('dependencies', nil,
49
+ [StoryboardItem.new("plugIn",
50
+ {identifier: "com.apple.InterfaceBuilder.IBCocoaTouchPlugin",
51
+ version: "14460.20"
52
+ }),
53
+ StoryboardItem.new("capability",
54
+ {name: "Safe area layout guides",
55
+ minToolsVersion: "9.0"}),
56
+ StoryboardItem.new("capability",
57
+ {name: "documents saved in the Xcode 8 format",
58
+ minToolsVersion: "8.0"})
59
+ ]),
60
+ StoryboardItem.new('scenes', nil,
61
+ [StoryboardItem.new('scene', {sceneID: "S9a-Lo-nRK"},
62
+ storyboard_objects(vc_id, colours[0]))]),
63
+ # add_color_resources(colours)
64
+ ]
65
+ )
66
+ end
67
+
68
+ def self.storyboard_objects(vc_id, colour)
69
+ [StoryboardItem.new("objects", nil,
70
+ [storyboard_vc(vc_id, colour),
71
+ StoryboardItem.new("placeholder",
72
+ {placeholderIdentifier: "IBFirstResponder",
73
+ id: "nbj-SD-Ib0", userLabel: "First Responder",
74
+ sceneMemberID: "firstResponder"})
75
+ ]),
76
+ StoryboardItem.new("point", {key:"canvasLocation", x:"-340", y: "-71"})]
77
+ end
78
+
79
+ def self.storyboard_vc(vc_id, colour)
80
+ # cap_name = bg_colour_name.clone
81
+ # cap_name[0] = cap_name.slice(0).upcase
82
+ StoryboardItem.new("viewController", { id: vc_id, sceneMemberID: "viewController" },
83
+ [StoryboardItem.new("view", {key: "view", contentMode: "scaleToFill",
84
+ id: "Ff1-8D-V8f"},
85
+ [StoryboardItem.new("rect",
86
+ {key: "frame", x: "0.0", y:"0.0",
87
+ width: "375", height: "667"}),
88
+ StoryboardItem.new("autoresizingMask",
89
+ {key: "autoresizingMask",
90
+ widthSizable: "YES",
91
+ heightSizable: "YES"}),
92
+ StoryboardItem.new("color",
93
+ {key: colour[:name]}.
94
+ merge(colour_set(colour))),
95
+ StoryboardItem.new("viewLayoutGuide", {key: "safeArea",
96
+ id: "7Wg-de-foW"})
97
+ ])])
98
+ end
99
+
100
+ def self.add_color_resources(colours=[])
101
+ StoryboardItem.new("resources", nil,
102
+ colours.map { |col| generate_colour_item(col) })
103
+ end
104
+
105
+ def self.generate_colour_item(colour)
106
+ cap_name = colour[:name].clone
107
+ cap_name[0] = cap_name.slice(0).upcase
108
+ StoryboardItem.new("namedColor", {name: cap_name},
109
+ [StoryboardItem.new("color",
110
+ {key: colour[:name]}.merge(colour_set(colour)))
111
+ ])
112
+ end
113
+
114
+ def self.colour_set(colour)
115
+ {
116
+ red: "%.10f" % (colour[:red].to_f / 255.0),
117
+ green: "%.10f" % (colour[:green].to_f / 255.0),
118
+ blue: "%.10f" % (colour[:blue].to_f / 255.0),
119
+ alpha: "%.3f" % colour.fetch(:alpha, 1.0),
120
+ colorSpace: "custom",
121
+ customColorSpace: "sRGB"
122
+ }
123
+ end
124
+ end
125
+ end
126
+
127
+ namespace :generate do |ns|
128
+ desc 'Generate a splash screen with a single colour for iOS applications (in a storyboard file)'
129
+ task :simple_splash, :red, :green, :blue do |t, args|
130
+ vc_id = "Ohr-fl-fP5" # Assign a fixed value, may need to change this in the future
131
+
132
+ splash_colour = {name: "backgroundColor",
133
+ red: args.fetch(:red, 224),
134
+ green: args.fetch(:green, 226),
135
+ blue: args.fetch(:blue, 220)}
136
+ puts "\n\n"
137
+ if args[:red].nil? && args[:green].nil? && args[:blue].nil?
138
+ puts "Using the default splash background colour"
139
+ puts "\n"
140
+ puts "You can specify your own values by re-executing the command like:"
141
+ puts " '$rake generate:simple_splash[<red>,<green>,<blue>]'"
142
+ else
143
+ puts "Using an rgb of #{splash_colour[:red]}:#{splash_colour[:green]}:#{splash_colour[:blue]} for the splash background"
144
+ end
145
+ output = File.open("resources/SimpleSplash.storyboard", 'w')
146
+ xml_builder = Builder::XmlMarkup.new(:target=>output, :indent=>2)
147
+ xml_builder.instruct!
148
+ SimpleSplash::Storyboard.build(vc_id, [splash_colour]).to_xml(xml_builder)
149
+ puts "\n\n*************"
150
+ puts "*Be sure to add: \n\n"
151
+ puts " app.info_plist['UILaunchStoryboardName'] = 'SimpleSplash'"
152
+ puts "\n to your Rakefile\n\n"
153
+ end
154
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-ios-simplesplash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Andy Stechishin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-06-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
+ - !ruby/object:Gem::Dependency
28
+ name: builder
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 3.2.2
41
+ description: Generate a simple splash page in a storyboard file for RubyMotion projects
42
+ email:
43
+ - andy@canasoftware.ca
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - README.md
49
+ - lib/motion-ios-simplesplash.rb
50
+ - lib/tasks/motion-ios-simplesplash.rb
51
+ homepage: ''
52
+ licenses:
53
+ - MIT
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubygems_version: 3.0.3
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: Generate a simple splash page in a storyboard file for RubyMotion projects
74
+ test_files: []