nitc/ios: add LoadingScreen.storyboard
authorAlexis Laferrière <alexis.laf@xymus.net>
Sat, 13 Feb 2016 18:59:22 +0000 (13:59 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 15 Feb 2016 16:08:59 +0000 (11:08 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

src/platform/ios.nit
src/platform/xcode_templates.nit

index 7ba038b..8a6b7c8 100644 (file)
@@ -73,6 +73,9 @@ private class IOSToolchain
        do
                var project_name = app_project.short_name
 
+               # ---
+               # project_folder.xcodeproj (projet meta data)
+
                # Create an XCode project directory
                var dir = ios_project_root/project_name+".xcodeproj"
                if not dir.file_exists then dir.mkdir
@@ -86,9 +89,17 @@ private class IOSToolchain
                        pbx.add_file new PbxFile(file.filename.basename)
                end
 
+               # Basic storyboard, mainly to have the right screen size
+               var launch_screen_storyboard = new LaunchScreenStoryboardTemplate
+               launch_screen_storyboard.title = app_project.name
+               launch_screen_storyboard.subtitle = "app.nit"
+               launch_screen_storyboard.write_to_file ios_project_root / "LaunchScreen.storyboard"
+               pbx.write_to_file dir / "project.pbxproj"
+
                ## TODO Register asset files
 
-               pbx.write_to_file dir/"project.pbxproj"
+               # ---
+               # project_folder (source code)
 
                # Create the plist in the same directory as the generated C code
                if not compile_dir.file_exists then compile_dir.mkdir
index 0f869c3..776d314 100644 (file)
@@ -174,6 +174,7 @@ class PbxprojectTemplate
 """
 
                add """
+               0FDD07A21C6F8E0E006FF70E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0FDD07A11C6F8E0E006FF70E /* LaunchScreen.storyboard */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
@@ -218,6 +219,7 @@ class PbxprojectTemplate
                for file in files do add file.description
 
                add """
+               0FDD07A11C6F8E0E006FF70E /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -236,6 +238,7 @@ class PbxprojectTemplate
                        children = (
                                AF9F83CE1A5F0D21004B62C0 /* {{{name}}} */,
                                AF9F83CD1A5F0D21004B62C0 /* Products */,
+                               0FDD07A11C6F8E0E006FF70E /* LaunchScreen.storyboard */,
                        );
                        sourceTree = "<group>";
                };
@@ -324,6 +327,7 @@ class PbxprojectTemplate
 """
 
                add """
+                               0FDD07A21C6F8E0E006FF70E /* LaunchScreen.storyboard in Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
@@ -513,6 +517,9 @@ class PlistTemplate
                <string>UIInterfaceOrientationLandscapeRight</string>
        </array>
 
+       <key>UILaunchStoryboardName</key>
+       <string>LaunchScreen</string>
+
        <key>NSAppTransportSecurity</key>
        <dict>
                <key>NSAllowsArbitraryLoads</key><true/>
@@ -522,3 +529,72 @@ class PlistTemplate
 """
        end
 end
+
+# Template for the loading screen to generate `LaunchScreen.storyboard`
+class LaunchScreenStoryboardTemplate
+       super Template
+
+       # Large text to show in the center of the loading screen
+       var title = "" is writable
+
+       # Text to show at the bottom of the loading screen
+       var subtitle = "" is writable
+
+       # TODO make this more customizable by moving the subviews block as an attribute
+       # or by allowing to pass a custom file from the ` res/` folder.
+
+       redef fun rendering
+       do
+               add """
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
+        <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
+    </dependencies>
+    <scenes>
+        <!--View Controller-->
+        <scene sceneID="EHf-IW-A2E">
+            <objects>
+                <viewController id="01J-lp-oVM" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
+                        <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
+                        <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="{{{subtitle}}}" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
+                                <rect key="frame" x="20" y="559" width="560" height="21"/>
+                                <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
+                                <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="{{{title}}}" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
+                                <rect key="frame" x="20" y="176" width="560" height="43"/>
+                                <fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
+                                <color key="textColor" red="0.0" green="0.5" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+                        <constraints>
+                            <constraint firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>
+                            <constraint firstAttribute="centerX" secondItem="GJd-Yh-RWb" secondAttribute="centerX" id="Q3B-4B-g5h"/>
+                            <constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" constant="20" symbolic="YES" id="SfN-ll-jLj"/>
+                            <constraint firstAttribute="bottom" secondItem="obG-Y5-kRd" secondAttribute="bottom" constant="20" id="Y44-ml-fuU"/>
+                            <constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="1/3" constant="1" id="moa-c2-u7t"/>
+                            <constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" constant="20" symbolic="YES" id="x7j-FC-K8j"/>
+                        </constraints>
+                    </view>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="53" y="375"/>
+        </scene>
+    </scenes>
+</document>"""
+       end
+end