module SimpleSplash::Storyboard
Constants
- BASE_COLOUR
- StoryboardItem
Public Class Methods
add_color_resources(colours=[])
click to toggle source
# File lib/tasks/motion-ios-simplesplash.rb, line 100 def self.add_color_resources(colours=[]) StoryboardItem.new("resources", nil, colours.map { |col| generate_colour_item(col) }) end
build(vc_id, colours=[])
click to toggle source
# File lib/tasks/motion-ios-simplesplash.rb, line 34 def self.build(vc_id, colours=[]) unless colours && colours.size > 0 colours = [BASE_COLOUR] end # bg_colour_name = colours[0][:name] StoryboardItem.new('document', { type: "com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB", version: "3.0", toolsVersion: "14460.31", targetRuntime: "iOS.CocoaTouch", propertyAccessControl: "none", useAutolayout: "YES", useTraitCollections: "YES", useSafeAreas: "YES", colorMatched: "YES", initialViewController: vc_id }, [ StoryboardItem.new('device', {id: "retina4_7", orientation: "portrait"}, [StoryboardItem.new("adaptation", {id: "fullscreen" })]), StoryboardItem.new('dependencies', nil, [StoryboardItem.new("plugIn", {identifier: "com.apple.InterfaceBuilder.IBCocoaTouchPlugin", version: "14460.20" }), StoryboardItem.new("capability", {name: "Safe area layout guides", minToolsVersion: "9.0"}), StoryboardItem.new("capability", {name: "documents saved in the Xcode 8 format", minToolsVersion: "8.0"}) ]), StoryboardItem.new('scenes', nil, [StoryboardItem.new('scene', {sceneID: "S9a-Lo-nRK"}, storyboard_objects(vc_id, colours[0]))]), # add_color_resources(colours) ] ) end
colour_set(colour)
click to toggle source
# File lib/tasks/motion-ios-simplesplash.rb, line 114 def self.colour_set(colour) { red: "%.10f" % (colour[:red].to_f / 255.0), green: "%.10f" % (colour[:green].to_f / 255.0), blue: "%.10f" % (colour[:blue].to_f / 255.0), alpha: "%.3f" % colour.fetch(:alpha, 1.0), colorSpace: "custom", customColorSpace: "sRGB" } end
generate_colour_item(colour)
click to toggle source
# File lib/tasks/motion-ios-simplesplash.rb, line 105 def self.generate_colour_item(colour) cap_name = colour[:name].clone cap_name[0] = cap_name.slice(0).upcase StoryboardItem.new("namedColor", {name: cap_name}, [StoryboardItem.new("color", {key: colour[:name]}.merge(colour_set(colour))) ]) end
storyboard_objects(vc_id, colour)
click to toggle source
# File lib/tasks/motion-ios-simplesplash.rb, line 68 def self.storyboard_objects(vc_id, colour) [StoryboardItem.new("objects", nil, [storyboard_vc(vc_id, colour), StoryboardItem.new("placeholder", {placeholderIdentifier: "IBFirstResponder", id: "nbj-SD-Ib0", userLabel: "First Responder", sceneMemberID: "firstResponder"}) ]), StoryboardItem.new("point", {key:"canvasLocation", x:"-340", y: "-71"})] end
storyboard_vc(vc_id, colour)
click to toggle source
# File lib/tasks/motion-ios-simplesplash.rb, line 79 def self.storyboard_vc(vc_id, colour) # cap_name = bg_colour_name.clone # cap_name[0] = cap_name.slice(0).upcase StoryboardItem.new("viewController", { id: vc_id, sceneMemberID: "viewController" }, [StoryboardItem.new("view", {key: "view", contentMode: "scaleToFill", id: "Ff1-8D-V8f"}, [StoryboardItem.new("rect", {key: "frame", x: "0.0", y:"0.0", width: "375", height: "667"}), StoryboardItem.new("autoresizingMask", {key: "autoresizingMask", widthSizable: "YES", heightSizable: "YES"}), StoryboardItem.new("color", {key: colour[:name]}. merge(colour_set(colour))), StoryboardItem.new("viewLayoutGuide", {key: "safeArea", id: "7Wg-de-foW"}) ])]) end