MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / fromResource

Method fromResource

packages/core/image-source/index.ios.ts:119–137  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

117 return nativeSource ? new ImageSource(nativeSource) : null;
118 }
119 static fromResource(name: string): Promise<ImageSource> {
120 return new Promise<ImageSource>((resolve, reject) => {
121 try {
122 UIImage.tns_safeDecodeImageNamedCompletion(name, (image) => {
123 if (image) {
124 resolve(new ImageSource(image));
125 } else {
126 UIImage.tns_safeDecodeImageNamedCompletion(`${name}.jpg`, (img) => {
127 if (img) {
128 resolve(new ImageSource(img));
129 }
130 });
131 }
132 });
133 } catch (ex) {
134 reject(ex);
135 }
136 });
137 }
138
139 static fromFileSync(path: string): ImageSource {
140 const uiImage = UIImage.imageWithContentsOfFile(getFileName(path));

Callers 1

Calls 2

resolveFunction · 0.50
logMethod · 0.45

Tested by

no test coverage detected