diff --git a/app/utils/scaling.js b/app/utils/scaling.js index f154a50a9..a69169ecd 100644 --- a/app/utils/scaling.js +++ b/app/utils/scaling.js @@ -2,13 +2,12 @@ import { Dimensions } from 'react-native'; import { isTablet } from './deviceInfo'; -const { width, height } = Dimensions.get('window'); - const guidelineBaseWidth = isTablet ? 600 : 375; const guidelineBaseHeight = isTablet ? 800 : 667; -const scale = size => (width / guidelineBaseWidth) * size; -const verticalScale = size => (height / guidelineBaseHeight) * size; -const moderateScale = (size, factor = 0.5) => size + (scale(size) - size) * factor; +// TODO: we need to refactor this +const scale = (size, width) => (width / guidelineBaseWidth) * size; +const verticalScale = (size, height) => (height / guidelineBaseHeight) * size; +const moderateScale = (size, factor = 0.5, width) => size + (scale(size, width) - size) * factor; export { scale, verticalScale, moderateScale }; diff --git a/app/views/NewServerView/index.js b/app/views/NewServerView/index.js index 43e4a6fbb..9a1ea8ce1 100644 --- a/app/views/NewServerView/index.js +++ b/app/views/NewServerView/index.js @@ -31,6 +31,7 @@ import SSLPinning from '../../utils/sslPinning'; import RocketChat from '../../lib/rocketchat'; import { isTablet } from '../../utils/deviceInfo'; import { verticalScale, moderateScale } from '../../utils/scaling'; +import { withDimensions } from '../../dimensions'; import ServerInput from './ServerInput'; const styles = StyleSheet.create({ @@ -287,22 +288,26 @@ class NewServerView extends React.Component { renderCertificatePicker = () => { const { certificate } = this.state; - const { theme } = this.props; + const { theme, width, height } = this.props; return ( - + {certificate ? I18n.t('Your_certificate') : I18n.t('Do_you_have_a_certificate')} - + {certificate ?? I18n.t('Apply_Your_Certificate')} @@ -311,7 +316,7 @@ class NewServerView extends React.Component { }; render() { - const { connecting, theme, adding, root } = this.props; + const { connecting, theme, adding, root, width, height } = this.props; const { text, connectingOpen, serversHistory } = this.state; const marginTopHeader = adding && root === ROOT_NEW_SERVER ? 25 : 70; @@ -322,9 +327,9 @@ class NewServerView extends React.Component { style={[ styles.onboardingImage, { - marginTop: isTablet ? 0 : verticalScale(marginTopHeader), - marginBottom: verticalScale(25), - maxHeight: verticalScale(150) + marginTop: isTablet ? 0 : verticalScale(marginTopHeader, height), + marginBottom: verticalScale(25, height), + maxHeight: verticalScale(150, height) } ]} source={require('../../static/images/logo.png')} @@ -334,14 +339,18 @@ class NewServerView extends React.Component { Rocket.Chat {I18n.t('Onboarding_subtitle')} @@ -368,7 +377,11 @@ class NewServerView extends React.Component { {I18n.t('Onboarding_join_open_description')} @@ -402,4 +415,4 @@ const mapDispatchToProps = dispatch => ({ inviteLinksClear: () => dispatch(inviteLinksClearAction()) }); -export default connect(mapStateToProps, mapDispatchToProps)(withTheme(NewServerView)); +export default connect(mapStateToProps, mapDispatchToProps)(withDimensions(withTheme(NewServerView)));