react-web-native-sketch
Version:
[TODO: We need an overview of how this can be used via npm vs as a local package]
74 lines • 2.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var enums_1 = require("../../utils/enums");
var __1 = require("../..");
function getImageUrl(url) {
if (!url) {
return '';
}
return enums_1.AWS_S3 + url;
}
exports.getImageUrl = getImageUrl;
function checkImageRestrictions(showAlert, t, width, height, minWidth, maxWidth, minHeight, maxHeight, fixedWidth, fixedHeight, ratioWidthHeight) {
if (ratioWidthHeight) {
if (width / height !== ratioWidthHeight) {
showAlert(t(__1.PHOTO_INCORRECT_RATIO, {
expectedRatio: 1 / ratioWidthHeight,
gotRatio: height / width,
}), {}, __1.PHOTO_INCORRECT_RATIO);
return false;
}
}
if (fixedHeight && fixedWidth) {
if (width !== fixedWidth || height !== fixedHeight) {
showAlert(t(__1.PHOTO_INCORRECT_SIZE, {
expectedWidth: fixedWidth,
expectedHeight: fixedHeight,
gotWidth: width,
gotHeight: height
}), {}, __1.PHOTO_INCORRECT_SIZE);
return false;
}
}
else {
if (minWidth && minHeight) {
if (width < minWidth || height < minHeight) {
showAlert(t(__1.PHOTO_INCORRECT_SIZE, {
expectedWidth: minWidth,
expectedHeight: minHeight,
gotWidth: width,
gotHeight: height
}), {}, __1.PHOTO_INCORRECT_SIZE);
return false;
}
}
if (maxWidth && maxHeight) {
if (width > maxWidth || height > maxHeight) {
showAlert(t(__1.PHOTO_INCORRECT_SIZE, {
expectedWidth: maxWidth,
expectedHeight: maxHeight,
gotWidth: width,
gotHeight: height
}), {}, __1.PHOTO_INCORRECT_SIZE);
return false;
}
}
}
return true;
}
exports.checkImageRestrictions = checkImageRestrictions;
function getPhotoDetails(formData) {
return {
file: formData.rawValue,
'Content-Type': formData.rawValue.type,
};
}
exports.getPhotoDetails = getPhotoDetails;
function getImagePreview(formData) {
if (formData && formData.rawValue) {
return formData.rawValue.preview || formData.rawValue.url || formData.rawValue;
}
return "";
}
exports.getImagePreview = getImagePreview;
//# sourceMappingURL=common.js.map