UNPKG

smartech-base-expo-plugin

Version:

Smartech Base Expo SDK's React Native Plugin For React Native Projects.

39 lines (28 loc) 1.24 kB
import { deepLinkHandlerSnippet } from "./iosConstants"; import { SmartechBaseProps } from "./smartechBaseProps"; export class Helper { static Ios = class { static addDeepLinkHandler(content: string, props: SmartechBaseProps): string { const smartechContentLines = content.split("\n"); const lastLine = this.getLastLine(smartechContentLines); const deepLinkHandlerLines = deepLinkHandlerSnippet(props.deepLinkDelay); const smartechDelegateContents = [ ...smartechContentLines.slice(0, lastLine + 1), deepLinkHandlerLines, ...smartechContentLines.slice(lastLine + 1), ].join("\n"); return smartechDelegateContents; }; static getLastLine = (lineArray: string[]): number => { return lineArray.lastIndexOf("@end") - 1; }; } static Android = class { static addDependency(appContents: string, dependency: string, version: string): string { const dependencyTemplate = `api "${dependency}:${version}"`; return appContents.replace('dependencies {', `dependencies {\n ${dependencyTemplate}`); } } }