Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | 2x 7x 7x 6x 6x 6x 8x 2x 2x 5x 5x 1x 7x 7x 7x 7x 7x 7x 7x 7x | import { ColorDescriptor } from 'color-string';
import path from 'path';
import { ResizeMode } from '../constants';
import { createDirAndWriteFile } from '../file-helpers';
import { addStoryboardFileToProject } from '../xcode';
import { IosProject } from './pbxproj';
const STORYBOARD_FILE_PATH = './SplashScreen.storyboard';
/**
* Modifies `.pbxproj` by:
* - adding reference for `.storyboard` file
*/
function updatePbxProject({ projectName, pbxProject, applicationNativeTarget }: IosProject): void {
// Check if `${projectName}/SplashScreen.storyboard` already exists
// Path relative to `ios` directory
const storyboardFilePath = path.join(projectName, STORYBOARD_FILE_PATH);
if (!pbxProject.hasFile(storyboardFilePath)) {
const group = pbxProject.findPBXGroupKey({ name: projectName });
Iif (!group) {
throw new Error(`Couldn't locate proper PBXGroup '.xcodeproj' file.`);
}
addStoryboardFileToProject(pbxProject, storyboardFilePath, {
target: applicationNativeTarget.uuid,
group,
});
}
}
/**
* Creates [STORYBOARD] file containing ui description of Splash/Launch Screen.
* > WARNING: modifies `pbxproj`
*/
export default async function configureStoryboard(
iosProject: IosProject,
{
resizeMode,
backgroundColor,
splashScreenImagePresent,
}: {
resizeMode: ResizeMode;
backgroundColor: ColorDescriptor;
splashScreenImagePresent: boolean;
}
) {
let contentMode: string;
switch (resizeMode) {
case ResizeMode.CONTAIN:
contentMode = 'scaleAspectFit';
break;
case ResizeMode.COVER:
contentMode = 'scaleAspectFill';
break;
default:
throw new Error(`resizeMode = ${resizeMode} is not supported for iOS platform.`);
}
const [r, g, b, a] = backgroundColor.value;
const red = r / 255;
const green = g / 255;
const blue = b / 255;
const alpha = a;
const filePath = path.resolve(iosProject.projectPath, STORYBOARD_FILE_PATH);
await createDirAndWriteFile(
filePath,
`<?xml version="1.0" encoding="UTF-8"?>
<document
type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB"
version="3.0"
toolsVersion="15705"
targetRuntime="iOS.CocoaTouch"
propertyAccessControl="none"
useAutolayout="YES"
launchScreen="YES"
useTraitCollections="YES"
useSafeAreas="YES"
colorMatched="YES"
initialViewController="EXPO-VIEWCONTROLLER-1"
>
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EXPO-SCENE-1">
<objects>
<viewController
storyboardIdentifier="SplashScreenViewController"
id="EXPO-VIEWCONTROLLER-1"
sceneMemberID="viewController"
>
<imageView
key="view"
clipsSubviews="YES"
userInteractionEnabled="NO"
contentMode="${contentMode}"
horizontalHuggingPriority="251"
verticalHuggingPriority="251"${
splashScreenImagePresent ? '\n image="SplashScreen"' : ''
}
id="EXPO-IMAGEVIEW-1"
>
<rect key="frame" x="0.0" y="0.0" width="800" height="1600"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="${red}" green="${green}" blue="${blue}" alpha="${alpha}" colorSpace="custom" customColorSpace="sRGB"/>
</imageView>
<size key="freeformSize" width="800" height="1600"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="EXPO-PLACEHOLDER-1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="141" y="130"/>
</scene>
</scenes>
<resources>
<image name="SplashScreen" width="600" height="1200"/>
</resources>
</document>
`
);
await updatePbxProject(iosProject);
}
|