Skip to content

Commit

Permalink
Updated internal dependencies to match Mx8.15
Browse files Browse the repository at this point in the history
  • Loading branch information
mgroeneweg committed Nov 22, 2020
1 parent 05ff7a6 commit 1c7042c
Show file tree
Hide file tree
Showing 171 changed files with 13,428 additions and 11,623 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const base = require("./node_modules/@mendix/pluggable-widgets-tools/configs/eslint.ts.base.json");
const base = require("@mendix/pluggable-widgets-tools/configs/eslint.ts.base.json");

module.exports = {
...base
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/
20,075 changes: 10,296 additions & 9,779 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 7 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,27 @@
"copyright": "ITvisors 2020",
"author": "Marcel Groeneweg",
"config": {
"widgetPath": "./test/widgets",
"projectPath": "./test/"
},
"packagePath": "itvisors",
"scripts": {
"start": "npm run dev",
"build": "pluggable-widgets-tools build:ts:native",
"dev": "pluggable-widgets-tools start:ts:native",
"build": "pluggable-widgets-tools build:native",
"dev": "pluggable-widgets-tools start:native",
"lint": "pluggable-widgets-tools lint",
"lint:fix": "pluggable-widgets-tools lint:fix",
"prerelease": "npm run lint",
"release": "pluggable-widgets-tools release:ts:native"
"release": "pluggable-widgets-tools release:native"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/Marcel Groeneweg/nativeresponsivelistview/issues"
},
"devDependencies": {
"@mendix/pluggable-widgets-tools": "^8.7.0",
"@mendix/pluggable-widgets-tools": "^8.14.0",
"@types/big.js": "^4.0.5",
"@types/classnames": "^2.2.6",
"@types/jest": "^24.0.0",
"@types/react": "^16.8.17",
"@types/react-dom": "^16.8.4",
"@types/react-native": "^0.57.56"
"@types/react": "~16.9.0",
"@types/react-native": "~0.61.23"
},
"dependencies": {
"big.js": "^5.2.2"
}
"dependencies": {}
}
2 changes: 1 addition & 1 deletion prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const base = require("./node_modules/@mendix/pluggable-widgets-tools/configs/prettier.base.json");
const base = require("@mendix/pluggable-widgets-tools/configs/prettier.base.json");

module.exports = {
...base
Expand Down
5 changes: 3 additions & 2 deletions src/components/ResponsiveListview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const defaultVerticalStyle: CustomStyle = {
};

export class ResponsiveListview extends Component<ResponsiveListviewProps> {

render(): ReactNode {
const { ds, content, showVertically } = this.props;
let styles: CustomStyle;
Expand All @@ -40,7 +39,9 @@ export class ResponsiveListview extends Component<ResponsiveListviewProps> {
}
return (
<View style={styles.container}>
{ds.items.map((item) => <View key={item.id}>{content(item)}</View>)}
{ds.items.map(item => (
<View key={item.id}>{content(item)}</View>
))}
</View>
);
}
Expand Down
2 changes: 1 addition & 1 deletion 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="NativeResponsiveListview" version="1.1.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="NativeResponsiveListview" version="1.2.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="NativeResponsiveListview.xml"/>
</widgetFiles>
Expand Down
Binary file modified test/TestNativeResponsiveListview.mpr
Binary file not shown.
64 changes: 64 additions & 0 deletions test/javascriptsource/nanoflowcommons/actions/GenerateUniqueID.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - 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";

// BEGIN EXTRA CODE
const COUNTER_STORE = "idCounter";
let locked = false;
let currentCounter;
function sleep(time) {
return new Promise(resolve => setTimeout(resolve, time));
}
async function initializeCounter() {
currentCounter = JSON.parse((await getItem(COUNTER_STORE)) || "-1");
}
function getItem(key) {
if (navigator && navigator.product === "ReactNative") {
const AsyncStorage = require("@react-native-community/async-storage").default;
return AsyncStorage.getItem(key);
}
if (window) {
const value = window.localStorage.getItem(key);
return Promise.resolve(value);
}
return Promise.reject(new Error("No storage API available"));
}
function setItem(key, value) {
if (navigator && navigator.product === "ReactNative") {
const AsyncStorage = require("@react-native-community/async-storage").default;
return AsyncStorage.setItem(key, value);
}
if (window) {
window.localStorage.setItem(key, value);
return Promise.resolve();
}
return Promise.reject(new Error("No storage API available"));
}
// END EXTRA CODE

/**
* Generates a unique ID based on the current session.
* @returns {Promise.<string>}
*/
export async function GenerateUniqueID() {
// BEGIN USER CODE
const sessionId = mx.session.getConfig("sessionObjectId");
const rnd = Math.round(Math.random() * 10000);
// eslint-disable-next-line no-unmodified-loop-condition
while (locked) {
await sleep(10);
}
locked = true;
if (typeof currentCounter === "undefined") {
await initializeCounter();
}
await setItem(COUNTER_STORE, JSON.stringify(++currentCounter));
locked = false;
return `${sessionId}:${currentCounter}:${rnd}`;
// END USER CODE
}
30 changes: 30 additions & 0 deletions test/javascriptsource/nanoflowcommons/actions/RefreshEntity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - 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";

// BEGIN EXTRA CODE
// END EXTRA CODE

/**
* Updates an entity without needing to refresh the whole page via passing an entity.
* @param {string} entityToRefresh - Entity which will be refreshed.
* @returns {Promise.<void>}
*/
export async function RefreshEntity(entityToRefresh) {
// BEGIN USER CODE
if (!entityToRefresh) {
return Promise.reject(new Error("EntityToRefresh parameter is required"));
}
return new Promise(resolve => {
mx.data.update({
entity: entityToRefresh,
callback: () => resolve(true)
});
});
// END USER CODE
}
30 changes: 30 additions & 0 deletions test/javascriptsource/nanoflowcommons/actions/RefreshObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - 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";

// BEGIN EXTRA CODE
// END EXTRA CODE

/**
* Updates an entity object without needing to refresh the whole page via passing an entity object.
* @param {MxObject} objectToRefresh - Object which will be refreshed.
* @returns {Promise.<void>}
*/
export async function RefreshObject(objectToRefresh) {
// BEGIN USER CODE
if (!objectToRefresh) {
return Promise.reject(new Error("ObjectToRefresh parameter is required"));
}
return new Promise(resolve => {
mx.data.update({
guid: objectToRefresh.getGuid(),
callback: () => resolve(true)
});
});
// END USER CODE
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getLocales, getCountry, getTimeZone, uses24HourClock } from "react-nati
export async function GetDeviceInfo() {
// BEGIN USER CODE
return Promise.all([
createMxObject("NativeMobileActions.DeviceInfo"),
createMxObject("NativeMobileResources.DeviceInfo"),
DeviceInfo.getBatteryLevel(),
DeviceInfo.getFontScale(),
DeviceInfo.getFreeDiskStorage(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ async function createParamObject(entity, url) {
}
function splitUrlToObject(url) {
const urlObject = new UrlParse(url);
const parsedUrlObject = new UrlParse(url, true);
const queryValues = {};
const query = urlObject.query;
const query = parsedUrlObject.query;
for (const [key, value] of Object.entries(query)) {
queryValues[key.toLowerCase()] = value !== undefined ? value : "";
}
console.log("query", queryValues);
const paths = urlObject.pathname
.replace(/^\/*/, "")
.split("/")
Expand Down
43 changes: 36 additions & 7 deletions test/javascriptsource/nativemobileresources/actions/TakePicture.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
// - 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 { Alert, Linking } from "react-native";
import { Alert, Linking, NativeModules } from "react-native";
import ImagePicker from "react-native-image-picker";
import { getLocales } from "react-native-localize";

// BEGIN EXTRA CODE
// END EXTRA CODE
Expand Down Expand Up @@ -73,8 +74,20 @@ export async function TakePicture(picture, pictureSource, pictureQuality, maximu
const guid = imageObject.getGuid();
// eslint-disable-next-line no-useless-escape
const filename = /[^\/]*$/.exec(uri)[0];
const onSuccess = () => resolve(true);
const onError = (error) => reject(error);
const onSuccess = () => {
NativeModules.NativeFsModule.remove(uri).then(() => {
imageObject.set("Name", filename);
mx.data.commit({
mxobj: imageObject,
callback: () => resolve(true),
error: (error) => reject(error)
});
});
};
const onError = (error) => {
NativeModules.NativeFsModule.remove(uri).then(undefined);
reject(error);
};
mx.data.saveDocument(guid, filename, {}, blob, onSuccess, onError);
});
});
Expand All @@ -95,16 +108,32 @@ export async function TakePicture(picture, pictureSource, pictureQuality, maximu
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
function getOptions() {
const { maxWidth, maxHeight } = getPictureQuality();
const [language] = getLocales().map(local => local.languageCode);
const isDutch = language === "nl";

return {
mediaType: "photo",
maxWidth,
maxHeight,
noData: true,
title: isDutch ? "Foto toevoegen" : "Select a photo",
cancelButtonTitle: isDutch ? "Annuleren" : "Cancel",
takePhotoButtonTitle: isDutch ? "Foto maken" : "Take photo",
chooseFromLibraryButtonTitle: isDutch ? "Kies uit bibliotheek" : "Choose from library",
permissionDenied: {
title: "This app does not have access to your camera or photos",
text: "To enable access, tap Settings > Permissions and turn on Camera and Storage.",
reTryTitle: "Settings",
okTitle: "Cancel"
title: isDutch
? "Deze app heeft geen toegang tot uw camera of foto's"
: "This app does not have access to your camera or photos",
text: isDutch
? "Ga naar Instellingen > Privacy om toegang tot uw camera en bestanden te verlenen."
: "To enable access, tap Settings > Privacy and turn on Camera and Photos/Storage.",
reTryTitle: isDutch ? "Instellingen" : "Settings",
okTitle: isDutch ? "Annuleren" : "Cancel"
},
storageOptions: {
skipBackup: true,
cameraRoll: false,
privateDirectory: true
}
};
}
Expand Down
Loading

0 comments on commit 1c7042c

Please sign in to comment.