react-native-modalbox icon indicating copy to clipboard operation
react-native-modalbox copied to clipboard

Modalbox doesn't centered on phone that setting with right to left language.

Open Zwerd opened this issue 9 years ago • 4 comments

I have an issue with modalbox that doesn't centered. My virtual android set on right to left language such as Hebrew ,Arabic or Tamashek, and when I setup a modalbox (modal centered) with on react native app the modal windows stick to the right side of the screen, did anyone knows how to fix this issue? I need the modal in the middle of the screen like "position centered + backdrop".

Thanks

Zwerd avatar Oct 27 '17 14:10 Zwerd

I fixed this problem by change index.js file in \node_modules\react-native-modalbox. in renderContent() function, just add a minus at the start of defining offsetX. actually you have to change this: var offsetX = (this.state.containerWidth - this.state.width) / 2; to this: var offsetX = -(this.state.containerWidth - this.state.width) / 2; I hope it works for you too...

alisn72 avatar Nov 25 '17 11:11 alisn72

@alisn72 this just shifts the bug to non-rtl layouts ;))

igsm avatar May 02 '19 09:05 igsm

@igsm The question is about an RTL application! for LTR apps the original library works well... also, it is just a trick i was used before and it is not a general solution

alisn72 avatar May 02 '19 16:05 alisn72

How I fix mine was I imported I18nManager from react native then worked on the Modal style by giving it a margin to fix the offset

import { I18nManager, StyleSheet } from 'react-native'

const styles = StyleSheet.create({
    modal: {
        justifyContent: 'center',
        alignItems: 'center',
        alignSelf: 'center',
        marginRight: I18nManager.isRTL ? -40 : 0
    },
});

Idimma avatar Jun 15 '19 00:06 Idimma