Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/pluggableWidgets/image-native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Changed

- We fixed image enlargement issue on Android.

## [3.0.2] - 2025-12-15

- Updated react-native-svg to v15.12.1. This addresses compatibility issues with React Native 0.78 and later versions.
Expand Down
2 changes: 1 addition & 1 deletion packages/pluggableWidgets/image-native/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "image-native",
"widgetName": "Image",
"version": "3.0.2",
"version": "3.0.3",
"description": "Display an image and enlarge it on click",
"copyright": "© Mendix Technology BV 2022. All rights reserved.",
"license": "Apache-2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Dispatch, SetStateAction, FunctionComponent, useState, Fragment, useCallback } from "react";
import { Modal, Pressable, LayoutChangeEvent, View, ImageStyle } from "react-native";
import { Dispatch, SetStateAction, FunctionComponent, useState, Fragment, useCallback, useMemo } from "react";
import { Modal, Pressable, LayoutChangeEvent, View, ImageStyle, useWindowDimensions } from "react-native";
import { SvgUri } from "react-native-svg";
import { extractStyles } from "@mendix/pluggable-widgets-tools";
import { OnClickTypeEnum } from "../../typings/ImageProps";
import { CustomImageObjectProps, onLayoutSetDimensions } from "../utils/imageUtils";
import { CustomImageObjectProps, onLayoutSetDimensions, getScaledDimensions } from "../utils/imageUtils";
import { DimensionsType, ImageIconSVG } from "./ImageIconSVG";
import { DefaultImageStyle } from "../ui/Styles.js";
import { DynamicValue } from "mendix";
Expand Down Expand Up @@ -209,7 +209,6 @@ export const ImageSmall: FunctionComponent<ImageSmallProps> = props => {
};

export const ImageEnlarged: FunctionComponent<ImageEnlargedProps> = props => {
const [dimensions, setDimensions] = useState<DimensionsType>();
const {
visible,
setEnlarged,
Expand All @@ -222,12 +221,11 @@ export const ImageEnlarged: FunctionComponent<ImageEnlargedProps> = props => {
screenReaderHint
} = props;
const [svgProps] = extractStyles(styles.image as ImageStyle, ["width", "height"]);
const onLayoutSetDimensionsCallback = useCallback(
({ nativeEvent: { layout } }: LayoutChangeEvent) => {
onLayoutSetDimensions(layout.width, layout.height, setDimensions, initialDimensions);
},
[initialDimensions]
);

const { width, height } = useWindowDimensions();
const dimensions = useMemo(() => {
return getScaledDimensions(width, height, initialDimensions);
}, [width, height, initialDimensions]);

return visible && initialDimensions?.width && initialDimensions?.height ? (
<Modal
Expand All @@ -251,19 +249,11 @@ export const ImageEnlarged: FunctionComponent<ImageEnlargedProps> = props => {
<Pressable
testID={`${name}$ImageEnlargedPressable`}
onPress={() => setEnlarged(false)}
onLayout={
source.type !== "icon" &&
((!dimensions?.width && !svgProps?.width) || (!dimensions?.height && !svgProps?.height))
? onLayoutSetDimensionsCallback
: undefined
}
style={styles.backdrop}
>
<Pressable
onPress={null}
<View
pointerEvents="none"
style={{
// The child (FastImage) needs "flexGrow: 1" so images on Android are not blurry.
// Therefore we explicitly have to set width / height here to prevent the image from taking up the whole screen, which in turn prevents the user from closing the modal (bc parent Pressable will not be clickable).
width: (svgProps?.width ?? dimensions?.width) as number,
height: (svgProps?.height ?? dimensions?.height) as number
}}
Expand All @@ -276,7 +266,7 @@ export const ImageEnlarged: FunctionComponent<ImageEnlargedProps> = props => {
initialDimensions={initialDimensions}
styles={styles.image}
/>
</Pressable>
</View>
</Pressable>
</Modal>
) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,49 +391,21 @@ exports[`Widget Dynamic Image SVG renders the structure inside a modal 1`] = `
testID="Image1$ImageEnlargedPressable"
>
<View
accessibilityState={
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"expanded": undefined,
"selected": undefined,
}
}
accessibilityValue={
{
"max": undefined,
"min": undefined,
"now": undefined,
"text": undefined,
}
}
accessible={true}
collapsable={false}
focusable={true}
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
pointerEvents="none"
style={
{
"height": 9999,
"width": 9999,
"height": 750,
"width": 750,
}
}
>
<RNSVGSvgViewAndroid
align="xMidYMid"
bbHeight={9999}
bbWidth={9999}
bbHeight={750}
bbWidth={750}
color="#000"
focusable={false}
height={9999}
height={750}
id="Layer_1"
meetOrSlice={0}
minX={0}
Expand All @@ -458,8 +430,8 @@ exports[`Widget Dynamic Image SVG renders the structure inside a modal 1`] = `
],
{
"flex": 0,
"height": 9999,
"width": 9999,
"height": 750,
"width": 750,
},
]
}
Expand All @@ -468,7 +440,7 @@ exports[`Widget Dynamic Image SVG renders the structure inside a modal 1`] = `
vbHeight={9999}
vbWidth={9999}
version={1.1}
width={9999}
width={750}
x="0px"
xmlSpace="preserve"
xmlns="http://www.w3.org/2000/svg"
Expand Down Expand Up @@ -1211,39 +1183,11 @@ exports[`Widget Dynamic Image renders the structure inside a modal 1`] = `
testID="Image1$ImageEnlargedPressable"
>
<View
accessibilityState={
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"expanded": undefined,
"selected": undefined,
}
}
accessibilityValue={
{
"max": undefined,
"min": undefined,
"now": undefined,
"text": undefined,
}
}
accessible={true}
collapsable={false}
focusable={true}
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
pointerEvents="none"
style={
{
"height": 1111,
"width": 2222,
"height": 375,
"width": 750,
}
}
>
Expand All @@ -1258,8 +1202,8 @@ exports[`Widget Dynamic Image renders the structure inside a modal 1`] = `
"aspectRatio": 2,
},
{
"height": 1111,
"width": 2222,
"height": 375,
"width": 750,
},
{
"flexGrow": 1,
Expand Down Expand Up @@ -1793,39 +1737,11 @@ exports[`Widget Icon type: image/staticImage renders the structure inside a moda
testID="Image1$ImageEnlargedPressable"
>
<View
accessibilityState={
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"expanded": undefined,
"selected": undefined,
}
}
accessibilityValue={
{
"max": undefined,
"min": undefined,
"now": undefined,
"text": undefined,
}
}
accessible={true}
collapsable={false}
focusable={true}
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
pointerEvents="none"
style={
{
"height": 1111,
"width": 2222,
"height": 375,
"width": 750,
}
}
>
Expand All @@ -1840,8 +1756,8 @@ exports[`Widget Icon type: image/staticImage renders the structure inside a moda
"aspectRatio": 2,
},
{
"height": 1111,
"width": 2222,
"height": 375,
"width": 750,
},
{
"flexGrow": 1,
Expand Down Expand Up @@ -2588,35 +2504,7 @@ exports[`Widget Static Image SVG renders the structure inside a modal 1`] = `
testID="Image1$ImageEnlargedPressable"
>
<View
accessibilityState={
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"expanded": undefined,
"selected": undefined,
}
}
accessibilityValue={
{
"max": undefined,
"min": undefined,
"now": undefined,
"text": undefined,
}
}
accessible={true}
collapsable={false}
focusable={true}
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
pointerEvents="none"
style={
{
"height": 15,
Expand Down Expand Up @@ -3420,39 +3308,11 @@ exports[`Widget Static Image renders the structure inside a modal 1`] = `
testID="Image1$ImageEnlargedPressable"
>
<View
accessibilityState={
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"expanded": undefined,
"selected": undefined,
}
}
accessibilityValue={
{
"max": undefined,
"min": undefined,
"now": undefined,
"text": undefined,
}
}
accessible={true}
collapsable={false}
focusable={true}
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
pointerEvents="none"
style={
{
"height": 1111,
"width": 2222,
"height": 375,
"width": 750,
}
}
>
Expand All @@ -3467,8 +3327,8 @@ exports[`Widget Static Image renders the structure inside a modal 1`] = `
"aspectRatio": 2,
},
{
"height": 1111,
"width": 2222,
"height": 375,
"width": 750,
},
{
"flexGrow": 1,
Expand Down
2 changes: 1 addition & 1 deletion packages/pluggableWidgets/image-native/src/package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="Image" version="3.0.2" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="Image" version="3.0.3" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="Image.xml" />
</widgetFiles>
Expand Down
Loading
Loading