Skip to content

Commit 40d5f21

Browse files
[MOO-1847] Upgrade react-native-fast-image (#317)
2 parents ee8ef90 + 63d56b6 commit 40d5f21

File tree

7 files changed

+122
-64
lines changed

7 files changed

+122
-64
lines changed

packages/pluggableWidgets/image-native/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Changed
10+
11+
- We have migrated from react-native-fast-image to @d11/react-native-fast-image for new architecture compatibility.
12+
913
## [3.0.0] - 2024-12-3
1014

1115
### Changed

packages/pluggableWidgets/image-native/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "image-native",
33
"widgetName": "Image",
4-
"version": "3.0.0",
4+
"version": "3.0.1",
55
"description": "Display an image and enlarge it on click",
66
"copyright": "© Mendix Technology BV 2022. All rights reserved.",
77
"license": "Apache-2.0",
@@ -22,9 +22,9 @@
2222
"test": "pluggable-widgets-tools test:unit:native"
2323
},
2424
"dependencies": {
25+
"@d11/react-native-fast-image": "8.11.1",
2526
"@mendix/piw-native-utils-internal": "*",
2627
"@mendix/piw-utils-internal": "*",
27-
"react-native-fast-image": "8.3.2",
2828
"react-native-svg": "15.7.1",
2929
"react-native-vector-icons": "10.2.0"
3030
},

packages/pluggableWidgets/image-native/src/components/ImageIconSVG.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createElement, FunctionComponent, Fragment, useCallback } from "react";
22
import { View } from "react-native";
33
import { SvgUri, SvgXml } from "react-native-svg";
4-
import FastImageComponent, { Source } from "react-native-fast-image";
4+
import FastImageComponent, { Source } from "@d11/react-native-fast-image";
55
import { extractStyles } from "@mendix/pluggable-widgets-tools";
66
import { CustomImageProps, GlyphIcon } from "../utils/imageUtils";
77
import { GlyphIcon as GlyphIconComponent } from "./fonts/font";

packages/pluggableWidgets/image-native/src/components/__tests__/Image.spec.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,47 @@ jest.mock("react-native/Libraries/Image/Image", () => {
3535
};
3636
});
3737

38+
jest.mock("@d11/react-native-fast-image", () => {
39+
const React = jest.requireActual("react") as typeof import("react");
40+
// eslint-disable-next-line @typescript-eslint/no-var-requires
41+
const { resolveAssetSource } = require("react-native/Libraries/Image/Image");
42+
const FastImage = ({
43+
testID,
44+
style,
45+
source: originalSource,
46+
resizeMode
47+
}: {
48+
testID: string;
49+
style: any;
50+
source: any;
51+
resizeMode: string;
52+
}): any => {
53+
let source = originalSource;
54+
try {
55+
if (typeof originalSource === "number") {
56+
const asset = resolveAssetSource(originalSource);
57+
source = asset ? { height: asset.height, width: asset.width } : { height: 0, width: 0 };
58+
} else if (originalSource?.uri) {
59+
// Dynamic image: use fixed dimensions to match stored snapshots
60+
source = { height: 1111, width: 2222 };
61+
}
62+
} catch (_) {
63+
source = { height: 0, width: 0 };
64+
}
65+
return React.createElement(
66+
"View",
67+
{ style: [{ overflow: "hidden" }, Array.isArray(style) ? style : [style]] },
68+
React.createElement("FastImageView", {
69+
testID,
70+
style: { position: "absolute", top: 0, left: 0, right: 0, bottom: 0 },
71+
source,
72+
resizeMode
73+
})
74+
);
75+
};
76+
return { __esModule: true, default: FastImage };
77+
});
78+
3879
const onLayoutEventData = {
3980
nativeEvent: {
4081
layout: {

packages/pluggableWidgets/image-native/src/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="Image" version="3.0.0" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="Image" version="3.0.1" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="Image.xml" />
66
</widgetFiles>

patches/@mendix+pluggable-widgets-tools+10.21.1.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@ index 2d0b5bfac7f1a1482bc1a222cba3e52b0339cc79..a3f0e368d76d294a5f7cd85886fe5ce0
7777
}
7878

7979
function getModuleName(modulePath) {
80+
diff --git a/configs/rollup.config.native.mjs b/configs/rollup.config.native.mjs
81+
index 682cf9fc4259a1f431e7cc3b17a319fdb072929e..5be03c770f8247637223f78738c3cdecae4d3d92 100644
82+
--- a/configs/rollup.config.native.mjs
83+
+++ b/configs/rollup.config.native.mjs
84+
@@ -62,7 +62,7 @@ const nativeExternal = [
85+
/^react($|\/)/,
86+
/^react-native-gesture-handler($|\/)/,
87+
/^react-native-reanimated($|\/)/,
88+
- /^react-native-fast-image($|\/)/,
89+
+ /^@d11\/react-native-fast-image($|\/)/,
90+
/^react-native-svg($|\/)/,
91+
/^react-native-vector-icons($|\/)/,
92+
/^@?react-navigation($|\/)/,
8093
diff --git a/test-config/jest.native.config.js b/test-config/jest.native.config.js
8194
index 72e3c51473b7566ca9d8b224b35334099ce615db..7e0949aa5d50d288d848117a804fd691422aefde 100644
8295
--- a/test-config/jest.native.config.js

0 commit comments

Comments
 (0)