"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = __importDefault(require("path")); const constants_1 = require("../constants"); const file_utils_1 = require("../utils/file-utils"); const xcode_1 = require("../xcode"); const STORYBOARD_FILE_PATH = './SplashScreen.storyboard'; /** * Modifies `.pbxproj` by: * - adding reference for `.storyboard` file */ function updatePbxProject({ projectName, pbxProject, applicationNativeTarget }) { // Check if `${projectName}/SplashScreen.storyboard` already exists // Path relative to `ios` directory const storyboardFilePath = path_1.default.join(projectName, STORYBOARD_FILE_PATH); if (!pbxProject.hasFile(storyboardFilePath)) { const group = pbxProject.findPBXGroupKey({ name: projectName }); if (!group) { throw new Error(`Couldn't locate proper PBXGroup '.xcodeproj' file.`); } xcode_1.addStoryboardFileToProject(pbxProject, storyboardFilePath, { target: applicationNativeTarget.uuid, group, }); } } /** * Creates [STORYBOARD] file containing ui description of Splash/Launch Screen. * > WARNING: modifies `pbxproj` */ async function configureStoryboard(iosProject, config = {}) { var _a; const resizeMode = (_a = config.imageResizeMode) !== null && _a !== void 0 ? _a : constants_1.SplashScreenImageResizeMode.CONTAIN; const splashScreenImagePresent = Boolean(config.image); let contentMode; switch (resizeMode) { case constants_1.SplashScreenImageResizeMode.CONTAIN: contentMode = 'scaleAspectFit'; break; case constants_1.SplashScreenImageResizeMode.COVER: contentMode = 'scaleAspectFill'; break; default: throw new Error(`resizeMode = ${resizeMode} is not supported for iOS platform.`); } const filePath = path_1.default.resolve(iosProject.projectPath, STORYBOARD_FILE_PATH); await file_utils_1.createDirAndWriteFile(filePath, ` ${!splashScreenImagePresent ? '' : ` `} ${!splashScreenImagePresent ? '' : ` `} ${!splashScreenImagePresent ? '' : ` `} `); await updatePbxProject(iosProject); } exports.default = configureStoryboard; //# sourceMappingURL=Storyboard.js.map