react-native-app-update-helper
Version:
This packages provides a customizable update overlay.
163 lines (162 loc) • 4.67 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.AppUpdatedOverlay = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _jsxRuntime = require("react/jsx-runtime");
const {
width,
height
} = _reactNative.Dimensions.get('window');
const AppUpdatedOverlay = ({
content,
version,
primaryColor = '#11B8B2',
backgroundColor = '#EEEEEE',
titleFontFamily,
descriptionFontFamily,
buttonTitleFontFamily,
titleFontSize,
descriptionFontSize,
buttonTitleFontSize
}) => {
const [isModalVisible, setIsModalVisible] = (0, _react.useState)(true);
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Modal, {
visible: isModalVisible,
transparent: true,
animationType: "slide",
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: styles.centeredView,
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: styles.modalView,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: [styles.topComponent, {
backgroundColor: backgroundColor
}]
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styles.mainTitle, {
fontFamily: titleFontFamily ? titleFontFamily : undefined,
fontSize: titleFontSize
}],
children: "What's New"
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
style: [styles.mainTitle, styles.subTitle, {
fontFamily: descriptionFontFamily ? descriptionFontFamily : undefined,
fontSize: descriptionFontSize
}],
children: ["Version: ", version]
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
bounces: false,
alwaysBounceVertical: false,
showsVerticalScrollIndicator: false,
style: styles.scrollviewContainer,
children: content.split(_reactNative.Platform.OS === 'ios' ? '<br />' : '<br>').map((line, index) => {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styles.description, {
fontFamily: descriptionFontFamily ? descriptionFontFamily : undefined,
fontSize: descriptionFontSize,
lineHeight: descriptionFontSize + 2
}],
children: line.trim()
}, index);
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
style: [styles.button, {
backgroundColor: primaryColor
}],
onPress: () => {
setIsModalVisible(false);
},
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styles.buttonTitle, {
fontFamily: buttonTitleFontFamily ? buttonTitleFontFamily : undefined,
fontSize: buttonTitleFontSize
}],
children: "Get Started"
})
})]
})
})
});
};
exports.AppUpdatedOverlay = AppUpdatedOverlay;
const mainStyles = {
color: {
text: '#15202B',
white: '#FFFFFF'
},
fontSize: {
title: 24,
content: 14,
small: 12
},
borderRadius: {
main: 25,
small: 8,
extraSmall: 4
}
};
const styles = _reactNative.StyleSheet.create({
centeredView: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
modalView: {
height: height,
width: width,
margin: 20,
backgroundColor: 'white',
padding: 35,
alignItems: 'center'
},
topComponent: {
height: height / 4,
width: width,
marginTop: -50,
marginBottom: 40
},
icon: {
height: 50,
width: 50,
marginBottom: 20
},
mainTitle: {
color: mainStyles.color.text,
fontSize: mainStyles.fontSize.title,
textAlign: 'center',
marginBottom: 5
},
subTitle: {
fontSize: mainStyles.fontSize.small,
fontWeight: 'normal',
marginBottom: 20
},
description: {
lineHeight: 20,
color: mainStyles.color.text,
fontSize: mainStyles.fontSize.content,
width: width / 1.2,
marginBottom: 30
},
button: {
minWidth: width - 40,
paddingVertical: 15,
paddingHorizontal: 20,
borderRadius: mainStyles.borderRadius.extraSmall,
marginBottom: 20
},
buttonTitle: {
color: mainStyles.color.white,
fontSize: mainStyles.fontSize.small,
textAlign: 'center'
},
scrollviewContainer: {
width: width - 60,
marginVertical: 10
}
});
var _default = exports.default = AppUpdatedOverlay;
//# sourceMappingURL=AppUpdatedOverlay.js.map