Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions packages/jsActions/mobile-resources-native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fixed an issue where the `TakePicture` and `TakePictureAdvanced` actions did not properly clean up temporary files.
- Replaced @notifee/react-native with react-native-notify-kit library.
- We bumped the `brace-expansion` package to v5.0.12 to fix a denial-of-service vulnerability.
- We refactored the GetDeviceInfo action to use the shared device metrics utility instead of directly importing react-native-device-info.
- Updated react-native from version v0.84.1 to v0.88.0.
- Updated react-native-blob-util from version v0.24.7 to v0.24.11.
- The [backgroundColor], [translucent] and [networkActivityIndicatorVisible] parameters of the Change status bar action no longer have any effect, because react-native v0.88 removed support for them.
Expand Down
2 changes: 1 addition & 1 deletion packages/jsActions/mobile-resources-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"release:marketplace": "node ../../../scripts/release/marketplaceRelease.js"
},
"dependencies": {
"@mendix/piw-native-utils-internal": "*",
"@react-native-camera-roll/camera-roll": "7.10.2",
"react-native-notify-kit": "10.4.7",
"@react-native-firebase/messaging": "20.1.0",
Expand All @@ -37,7 +38,6 @@
"mendix-native": "https://github.com/mendix/mendix-native/releases/download/v1.0.0/mendix-native-v1.0.0.tgz",
"mime": "3.0.0",
"react-native-blob-util": "0.24.11",
"react-native-device-info": "15.0.2",
"react-native-file-viewer-turbo": "0.7.4",
"react-native-image-picker": "7.2.3",
"react-native-localize": "3.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { Big } from "big.js";
import DeviceInfo from "react-native-device-info";
import { useDeviceMetrics } from "@mendix/piw-native-utils-internal";
import { getLocales, getCountry, getTimeZone, uses24HourClock } from "react-native-localize";

// BEGIN EXTRA CODE
Expand All @@ -17,20 +17,21 @@ import { getLocales, getCountry, getTimeZone, uses24HourClock } from "react-nati
*/
export async function GetDeviceInfo(): Promise<mendix.lib.MxObject> {
// BEGIN USER CODE
const deviceMetrics = useDeviceMetrics();

return Promise.all([
createMxObject("NativeMobileResources.DeviceInfo"),
DeviceInfo.getBatteryLevel(),
DeviceInfo.getFontScale(),
DeviceInfo.getFreeDiskStorage(),
DeviceInfo.getTotalDiskCapacity(),
DeviceInfo.getTotalMemory(),
DeviceInfo.getCarrier(),
DeviceInfo.getManufacturer(),
DeviceInfo.getUserAgent(),
DeviceInfo.getUniqueId(),
DeviceInfo.isEmulator(),
DeviceInfo.isLandscape()
deviceMetrics.getBatteryLevel(),
deviceMetrics.getFontScale(),
deviceMetrics.getFreeDiskStorage(),
deviceMetrics.getTotalDiskCapacity(),
deviceMetrics.getTotalMemory(),
deviceMetrics.getCarrier(),
deviceMetrics.getManufacturer(),
deviceMetrics.getUserAgent(),
deviceMetrics.getUniqueId(),
deviceMetrics.isEmulator(),
deviceMetrics.isLandscape()
]).then(
async ([
mxObject,
Expand All @@ -47,33 +48,33 @@ export async function GetDeviceInfo(): Promise<mendix.lib.MxObject> {
isLandscape
]) => {
const locales = getLocales();
mxObject.set("ApplicationName", DeviceInfo.getApplicationName());
mxObject.set("ApplicationName", deviceMetrics.getApplicationName());
mxObject.set("BatteryLevel", new Big(batteryLevel.toFixed(2)));
mxObject.set("Brand", DeviceInfo.getBrand());
mxObject.set("BuildNumber", String(DeviceInfo.getBuildNumber()));
mxObject.set("BundleId", DeviceInfo.getBundleId());
mxObject.set("Brand", deviceMetrics.getBrand());
mxObject.set("BuildNumber", String(deviceMetrics.getBuildNumber()));
mxObject.set("BundleId", deviceMetrics.getBundleId());
mxObject.set("Carrier", carrier);
mxObject.set("DeviceCountry", getCountry());
mxObject.set("DeviceId", DeviceInfo.getDeviceId());
mxObject.set("DeviceId", deviceMetrics.getDeviceId());
mxObject.set("DeviceLocale", locales && locales.length > 0 ? locales[0].languageTag : "");
mxObject.set("FontScale", new Big(fontScale.toFixed(2)));
mxObject.set("FreeDiskStorage", new Big(freeDiskStorage));
mxObject.set("Manufacturer", manufacturer);
mxObject.set("Model", DeviceInfo.getModel());
mxObject.set("ReadableVersion", DeviceInfo.getReadableVersion());
mxObject.set("SystemName", DeviceInfo.getSystemName());
mxObject.set("SystemVersion", DeviceInfo.getSystemVersion());
mxObject.set("Model", deviceMetrics.getModel());
mxObject.set("ReadableVersion", deviceMetrics.getReadableVersion());
mxObject.set("SystemName", deviceMetrics.getSystemName());
mxObject.set("SystemVersion", deviceMetrics.getSystemVersion());
mxObject.set("Timezone", getTimeZone());
mxObject.set("TotalDiskCapacity", new Big(totalDiskCapacity));
mxObject.set("TotalMemory", new Big(totalMemory));
mxObject.set("UniqueId", uniqueId);
mxObject.set("UserAgent", userAgent);
mxObject.set("Version", DeviceInfo.getVersion());
mxObject.set("Version", deviceMetrics.getVersion());
mxObject.set("Is24Hour", uses24HourClock());
mxObject.set("IsEmulator", isEmulator);
mxObject.set("IsTablet", DeviceInfo.isTablet());
mxObject.set("IsTablet", deviceMetrics.isTablet);
mxObject.set("IsLandscape", isLandscape);
mxObject.set("HasNotch", DeviceInfo.hasNotch());
mxObject.set("HasNotch", deviceMetrics.hasNotch);

return mxObject;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

### Changed

- Removed unnecessary react-native-device-info dependency.
- Updated react-native from version v0.84.1 to v0.88.0.
- Updated react-native-gesture-handler from version v2.31.2 to v2.33.0.
- Updated react-native-reanimated from version v4.3.1 to v4.7.1.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bottom-sheet-native",
"widgetName": "BottomSheet",
"version": "5.4.0",
"version": "5.4.1",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand All @@ -23,7 +23,6 @@
"@mendix/piw-native-utils-internal": "*",
"@mendix/piw-utils-internal": "*",
"@shopify/flash-list": "2.3.1",
"react-native-device-info": "15.0.2",
"react-native-gesture-handler": "2.33.0",
"react-native-reanimated": "4.7.1",
"react-native-worklets": "0.13.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ jest.mock("react-native-reanimated", () => {
return Reanimated;
});

jest.mock("react-native-device-info", () => ({
getDeviceId: () => "iPhone10,6"
}));

jest.mock("react-native/Libraries/Utilities/Platform", () => {
const Platform = jest.requireActual("react-native/Libraries/Utilities/Platform");
Platform.OS = "ios";
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="BottomSheet" version="5.4.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="BottomSheet" version="5.4.1" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="BottomSheet.xml" />
</widgetFiles>
Expand Down
24 changes: 0 additions & 24 deletions packages/pluggableWidgets/bottom-sheet-native/src/ui/Styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { TextStyle, ViewStyle } from "react-native";
import DeviceInfo from "react-native-device-info";

export interface ModalItemsStyle {
container?: ModalItemContainerStyle;
Expand All @@ -19,26 +18,3 @@ export interface BottomSheetStyle {
modal: ViewStyle;
modalItems: ModalItemsStyle;
}

const isiPhoneModelWithNotch = (): boolean => {
const model = DeviceInfo.getDeviceId();
if (model.indexOf("iPhone") !== -1) {
switch (model) {
case "iPhone10,6": // iPhone X GSM
case "iPhone11,2": // iPhone XS
case "iPhone11,4": // iPhone XS Max
case "iPhone11,6": // iPhone XS Max Global
case "iPhone11,8": // Iphone XR
case "iPhone12,1": // Iphone 11
case "iPhone12,3": // Iphone 11 Pro
case "iPhone12,5": // Iphone 11 Pro Max
return true;
default:
return false;
}
}
return false;
};

export const defaultPaddings = { paddingBottom: isiPhoneModelWithNotch() ? 24 : 0 };
export const defaultMargins = { marginBottom: isiPhoneModelWithNotch() ? 24 : 0 };
1 change: 1 addition & 0 deletions packages/pluggableWidgets/gallery-native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

### Changed

- Migrated device metrics utility to shared package for better code reusability.
- Updated react-native from version v0.84.1 to v0.88.0.

## [2.2.1] - 2026-6-10
Expand Down
6 changes: 3 additions & 3 deletions packages/pluggableWidgets/gallery-native/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gallery-native",
"widgetName": "Gallery",
"version": "2.4.0",
"version": "2.4.1",
"description": "A flexible gallery widget that renders columns, rows and layouts.",
"copyright": "© Mendix Technology BV 2022. All rights reserved.",
"license": "Apache-2.0",
Expand All @@ -22,9 +22,9 @@
"test": "pluggable-widgets-tools test:unit:native"
},
"dependencies": {
"@mendix/piw-native-utils-internal": "*",
"@mendix/piw-utils-internal": "*",
"@shopify/flash-list": "2.3.1",
"react-native-device-info": "15.0.2"
"@shopify/flash-list": "2.3.1"
},
"devDependencies": {
"@mendix/pluggable-widgets-tools": "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
useWindowDimensions
} from "react-native";
import { ObjectItem, DynamicValue } from "mendix";
import DeviceInfo from "react-native-device-info";
import { useDeviceMetrics } from "@mendix/piw-native-utils-internal";
import { GalleryStyle } from "../ui/Styles";
import { HorizontalItemSizingEnum, PaginationEnum, ScrollDirectionEnum } from "../../typings/GalleryProps";
import { isAvailable } from "@mendix/piw-utils-internal";
Expand Down Expand Up @@ -39,8 +39,9 @@ export interface GalleryProps<T extends ObjectItem> {
}

export const Gallery = <T extends ObjectItem>(props: GalleryProps<T>): ReactElement => {
const { isTablet } = useDeviceMetrics();
const isScrollDirectionVertical = props.scrollDirection === "vertical";
const numColumns = DeviceInfo.isTablet() ? props.tabletColumns : props.phoneColumns;
const numColumns = isTablet ? props.tabletColumns : props.phoneColumns;
const firstItemId = props.items?.[0]?.id;
const lastItemId = props.items?.[props.items.length - 1]?.id;
const { name, style, itemRenderer } = props;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { ObjectItem, GUID, DynamicValue, ValueStatus } from "mendix";
import { render, fireEvent, act } from "@testing-library/react-native";
import { Gallery, GalleryProps } from "../Gallery";

jest.mock("react-native-device-info", () => ({ isTablet: jest.fn().mockReturnValue(false) }));
jest.mock("@mendix/piw-native-utils-internal", () => ({
useDeviceMetrics: () => ({ isTablet: false })
}));
jest.mock("@shopify/flash-list"); // Mocking FlashList API because it causes issues with the test renderer

const itemWrapperFunction =
Expand Down
2 changes: 1 addition & 1 deletion packages/pluggableWidgets/gallery-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="Gallery" version="2.4.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="Gallery" version="2.4.1" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="Gallery.xml" />
</widgetFiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Changed

- Updated react-native from version v0.84.1 to v0.88.0.

- We fixed an issue where screen readers (TalkBack and VoiceOver) read out every pagination dot as a separate button. The dots are now announced once as a page indicator (for example "Slide 2 of 4"), which can be adjusted to change slide.
- Migrated device metrics utility to shared package for better code reusability and removed static iPhone list for notch detection.

## [4.4.1] - 2026-6-10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"@mendix/piw-native-utils-internal": "*",
"@mendix/piw-utils-internal": "*",
"@react-native-async-storage/async-storage": "2.2.0",
"@shopify/flash-list": "2.3.1",
"react-native-device-info": "15.0.2"
"@shopify/flash-list": "2.3.1"
},
"devDependencies": {
"@mendix/pluggable-widgets-tools": "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ import { SwipeableContainer } from "./SwipeableContainer";
import AsyncStorage from "@react-native-async-storage/async-storage";
import deepmerge from "deepmerge";
import { executeAction } from "@mendix/piw-utils-internal";
import { MxOverlay } from "@mendix/piw-native-utils-internal";
import { MxOverlay, useDeviceMetrics } from "@mendix/piw-native-utils-internal";

// The popup container draws its own dimmed background, so the overlay backdrop must not add a second one
const transparentBackdrop = { backgroundColor: "transparent" };

export function IntroScreen(props: IntroScreenProps<IntroScreenStyle>): JSX.Element {
const [visible, setVisible] = useState(false);
const { hasNotch } = useDeviceMetrics();
const notchStyle = hasNotch ? { paginationContainer: { bottom: 22 } } : {};
const customStyles = props.style ? props.style.filter(o => o != null) : [];
const styles =
customStyles.length > 0
? deepmerge.all<IntroScreenStyle>([defaultWelcomeScreenStyle, ...customStyles])
: defaultWelcomeScreenStyle;
const styles = deepmerge.all<IntroScreenStyle>([defaultWelcomeScreenStyle, notchStyle, ...customStyles]);

useEffect(() => {
let isMounted = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import { View } from "react-native";
import { EditableValueBuilder } from "@mendix/piw-utils-internal";
import { Big } from "big.js";

jest.mock("react-native-device-info", () => ({
hasNotch: jest.fn().mockReturnValue(true),
getDeviceId: jest.fn().mockReturnValue("iPhone10,6")
}));
jest.mock("@mendix/piw-native-utils-internal", () => {
const actual = jest.requireActual("@mendix/piw-native-utils-internal");
return {
...actual,
useDeviceMetrics: () => ({ hasNotch: true })
};
});

jest.mock("@react-native-async-storage/async-storage", () => ({
getItem: jest.fn().mockResolvedValue(null),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import { EditableValueBuilder } from "@mendix/piw-utils-internal";
import { Big } from "big.js";
import { DynamicValue, ValueStatus } from "mendix";

jest.mock("react-native-device-info", () => ({
hasNotch: jest.fn(),
getDeviceId: jest.fn().mockReturnValue("")
}));
jest.mock("@mendix/piw-native-utils-internal", () => {
const actual = jest.requireActual("@mendix/piw-native-utils-internal");
return {
...actual,
useDeviceMetrics: () => ({ hasNotch: false })
};
});

jest.mock("@react-native-async-storage/async-storage", () => ({
getItem: jest.fn().mockResolvedValue(null),
Expand Down Expand Up @@ -44,11 +47,6 @@ describe("Intro Screen", () => {
hideIndicatorLastSlide: false,
identifier: ""
};

jest.mock("react-native-device-info", () => ({
hasNotch: jest.fn(),
getDeviceId: jest.fn().mockReturnValue("iPhone")
}));
});

it("renders", () => {
Expand Down
24 changes: 1 addition & 23 deletions packages/pluggableWidgets/intro-screen-native/src/ui/Styles.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
import { Style } from "@mendix/piw-native-utils-internal";
import { I18nManager, Platform, StyleSheet, TextStyle, ViewStyle } from "react-native";
import absoluteFill = StyleSheet.absoluteFill;
import DeviceInfo from "react-native-device-info";

const isiPhoneModelWithNotch = (): boolean => {
const model = DeviceInfo.getDeviceId();
if (model.indexOf("iPhone") !== -1) {
switch (model) {
case "iPhone10,6": // iPhone X GSM
case "iPhone11,2": // iPhone XS
case "iPhone11,4": // iPhone XS Max
case "iPhone11,6": // iPhone XS Max Global
case "iPhone11,8": // Iphone XR
case "iPhone12,1": // Iphone 11
case "iPhone12,3": // Iphone 11 Pro
case "iPhone12,5": // Iphone 11 Pro Max
return true;
default:
return false;
}
}
return false;
};

const isAndroidRTL = I18nManager.isRTL && Platform.OS === "android";
const isIphoneWithNotch = DeviceInfo.hasNotch() || (Platform.OS === "ios" && isiPhoneModelWithNotch());

const defaultButtonBetweenContainer: ViewStyle = {
flexDirection: "row",
Expand Down Expand Up @@ -91,7 +69,7 @@ export const defaultWelcomeScreenStyle: IntroScreenStyle = {
},
paginationContainer: {
position: "absolute",
bottom: isIphoneWithNotch ? 22 : 0,
bottom: 0,
left: 0,
right: 0,
justifyContent: "space-between",
Expand Down
3 changes: 3 additions & 0 deletions packages/tools/piw-native-utils-internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"prepare": "pnpm build",
"postinstall": "pnpm build"
},
"dependencies": {
"react-native-device-info": "15.0.2"
},
"devDependencies": {
"@mendix/pluggable-widgets-tools": "*",
"rimraf": "^6.1.2"
Expand Down
Loading
Loading