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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

- Fixed background image widget not visible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also add here that the widget was not visible under specific scenario.


## [2.2.0] - 2024-12-3

### Changed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "background-image-native",
"widgetName": "BackgroundImage",
"version": "2.2.0",
"version": "2.2.1",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ export function BackgroundImage(props: BackgroundImageProps<BackgroundImageStyle
{ opacity, resizeMode }
] as StyleProp<SvgImageStyle>;

// When there's no content, allow container to grow to fill available space
// When there's content, size container to content
const containerStyle = props.content
? styles.container
: [styles.container, { flexGrow: 1, flexShrink: 1, flexBasis: "auto" as const }];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's consider switching the order of the styles in the array here, because now, if the user passes the same style props, they will be overwritten by our hard-coded ones.

And for extra points, we can create a const for the hard-coded style for better readability e.g.
const DEFAULT_CONT_STYLE = { flexGrow: 1 ....}


return (
<View style={styles.container} testID={name}>
<View style={containerStyle} testID={name}>
<Image source={image.value} style={imageStyle} color={styles.image.svgColor} testID={`${name}$image`} />
{props.content}
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,16 @@ exports[`BackgroundImage renders with default styles 1`] = `

exports[`BackgroundImage renders without content 1`] = `

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can also add a snapshot test to address this scenario e.g. it("renders with visible dimensions without content", or it("fills available space when content is empty"...

<View
style={{}}
style={
[
{},
{
"flexBasis": "auto",
"flexGrow": 1,
"flexShrink": 1,
},
]
}
testID="backgroundImageTest"
>
<Image
Expand Down
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="BackgroundImage" version="2.2.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="BackgroundImage" version="2.2.1" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="BackgroundImage.xml" />
</widgetFiles>
Expand Down
Loading