Skip to content

Commit 1462c60

Browse files
fhammerschmidtcknitt
authored andcommitted
bs-react-native-next: Add image methods (#356)
1 parent 789cfa4 commit 1462c60

1 file changed

Lines changed: 55 additions & 24 deletions

File tree

  • bs-react-native-next/src/components

‎bs-react-native-next/src/components/Image.re‎

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
1+
type uriSource;
2+
3+
[@bs.obj]
4+
external uriSource:
5+
(
6+
~uri: string,
7+
~bundle: string=?,
8+
~method: string=?,
9+
~headers: Js.t('a)=?,
10+
~body: string=?,
11+
~cache: [@bs.string] [
12+
| `default
13+
| `reload
14+
| [@bs.as "force-cache"] `forceCache
15+
| [@bs.as "only-if-cached"] `onlyIfCached
16+
]
17+
=?,
18+
~scale: float=?,
19+
~width: float=?,
20+
~height: float=?,
21+
unit
22+
) =>
23+
uriSource =
24+
"";
25+
126
module Source = {
227
type t;
328

4-
[@bs.obj]
5-
external fromUri:
6-
(
7-
~uri: string,
8-
~bundle: string=?,
9-
~method: string=?,
10-
~headers: Js.t('a)=?,
11-
~body: string=?,
12-
~cache: [@bs.string] [
13-
| `default
14-
| `reload
15-
| `forceCache
16-
| `onlyIfCached
17-
]
18-
=?,
19-
~scale: float=?,
20-
~width: float=?,
21-
~height: float=?,
22-
unit
23-
) =>
24-
t =
25-
"";
26-
2729
external fromRequired: Packager.required => t = "%identity";
28-
external fromArray: array(t) => t = "%identity";
30+
external fromUriSource: uriSource => t = "%identity";
31+
external fromUriSources: array(uriSource) => t = "%identity";
2932
};
3033

3134
module DefaultSource = {
@@ -75,3 +78,31 @@ external make:
7578
) =>
7679
React.element =
7780
"Image";
81+
82+
type error;
83+
84+
[@bs.module "react-native"] [@bs.scope "Image"]
85+
external getSize:
86+
(
87+
~uri: string,
88+
~success: (~width: float, ~height: float) => unit,
89+
~failure: error => unit=?,
90+
unit
91+
) =>
92+
unit =
93+
"getSize";
94+
95+
type requestId;
96+
97+
[@bs.module "react-native"] [@bs.scope "Image"]
98+
external prefetch: (~uri: string) => requestId = "prefetch";
99+
100+
[@bs.module "react-native"] [@bs.scope "Image"]
101+
external abortPrefetch: requestId => unit = "abortPrefetch";
102+
103+
[@bs.module "react-native"] [@bs.scope "Image"]
104+
external queryCache: (~uris: array(string)) => unit = "queryCache";
105+
106+
[@bs.module "react-native"] [@bs.scope "Image"]
107+
external resolveAssetSource: Packager.required => uriSource =
108+
"resolveAssetSource";

0 commit comments

Comments
 (0)