diff --git a/components/CustomModal.js b/components/CustomModal.js new file mode 100644 index 0000000..99b38d6 --- /dev/null +++ b/components/CustomModal.js @@ -0,0 +1,23 @@ +// @flow + +import * as React from 'react'; +import {withTheme} from 'react-native-paper'; +import {Modalize} from "react-native-modalize"; + +function CustomModal(props) { + const { colors } = props.theme; + return ( + + {props.children} + + ); +} + +export default withTheme(CustomModal); + diff --git a/screens/About/AboutScreen.js b/screens/About/AboutScreen.js index 54e257e..69edff9 100644 --- a/screens/About/AboutScreen.js +++ b/screens/About/AboutScreen.js @@ -5,7 +5,7 @@ import {FlatList, Linking, Platform, View} from 'react-native'; import i18n from "i18n-js"; import appJson from '../../app'; import AsyncStorageManager from "../../utils/AsyncStorageManager"; -import {Modalize} from "react-native-modalize"; +import CustomModal from "../../components/CustomModal"; import ThemeManager from "../../utils/ThemeManager"; import {Avatar, Button, Card, List, Text, Title} from 'react-native-paper'; @@ -62,7 +62,7 @@ function openWebLink(link) { export default class AboutScreen extends React.Component { debugTapCounter = 0; - modalRef: { current: null | Modalize }; + modalRef: Object; state = { isDebugUnlocked: AsyncStorageManager.getInstance().preferences.debugUnlocked.current === '1' @@ -186,12 +186,13 @@ export default class AboutScreen extends React.Component { getCardItem: Function; getMainCard: Function; + onModalRef: Function; constructor(props: any) { super(props); - this.modalRef = React.createRef(); this.getCardItem = this.getCardItem.bind(this); this.getMainCard = this.getMainCard.bind(this); + this.onModalRef = this.onModalRef.bind(this); } getAppCard() { @@ -309,54 +310,47 @@ export default class AboutScreen extends React.Component { const onPressMail = openWebLink.bind(this, links.bugsMail); const onPressGit = openWebLink.bind(this, links.bugsGit); return ( - - - {i18n.t('aboutScreen.bugs')} - - {i18n.t('aboutScreen.bugsDescription')} - - - - - + + {i18n.t('aboutScreen.bugs')} + + {i18n.t('aboutScreen.bugsDescription')} + + + + ); } openBugReportModal() { - if (this.modalRef.current) { - this.modalRef.current.open(); + if (this.modalRef) { + this.modalRef.open(); } } @@ -372,10 +366,16 @@ export default class AboutScreen extends React.Component { return ; } + onModalRef(ref: Object) { + this.modalRef = ref; + } + render() { return ( - {this.getBugReportModal()} + + {this.getBugReportModal()} + { - modalRef: { current: null | Modalize }; + modalRef: Object; modalInputValue = ''; state = { modalCurrentDisplayItem: {}, currentPreferences: JSON.parse(JSON.stringify(AsyncStorageManager.getInstance().preferences)) }; + onModalRef: Function; + constructor(props: any) { super(props); - this.modalRef = React.createRef(); + this.onModalRef = this.onModalRef.bind(this); } static getGeneralItem(onPressCallback: Function, icon: ?string, title: string, subtitle: string) { @@ -76,8 +78,8 @@ export default class DebugScreen extends React.Component { this.setState({ modalCurrentDisplayItem: item }); - if (this.modalRef.current) { - this.modalRef.current.open(); + if (this.modalRef) { + this.modalRef.open(); } } @@ -127,15 +129,16 @@ export default class DebugScreen extends React.Component { AsyncStorageManager.getInstance().savePref(key, value); } + onModalRef(ref: Object) { + this.modalRef = ref; + } + render() { return ( - + {this.getModalContent()} - + { - modalRef: { current: null | Modalize }; + modalRef: Object; originalData: Array; shouldFocusSearchBar: boolean; onSearchStringChange: Function; onSortMenuPress: Function; renderItem: Function; + onModalRef: Function; constructor(props: any) { super(props); - this.modalRef = React.createRef(); this.originalData = this.props.route.params['data']['data']; this.shouldFocusSearchBar = this.props.route.params['shouldFocusSearchBar']; this.state = { @@ -69,6 +69,7 @@ export default class ProximoListScreen extends React.Component { this.onSearchStringChange = this.onSearchStringChange.bind(this); this.onSortMenuPress = this.onSortMenuPress.bind(this); this.renderItem = this.renderItem.bind(this); + this.onModalRef = this.onModalRef.bind(this); } /** @@ -95,8 +96,8 @@ export default class ProximoListScreen extends React.Component { data.sort(sortNameReverse); break; } - if (this.modalRef.current && mode !== this.state.currentSortMode) { - this.modalRef.current.close(); + if (this.modalRef && mode !== this.state.currentSortMode) { + this.modalRef.close(); } } @@ -250,8 +251,8 @@ export default class ProximoListScreen extends React.Component { this.setState({ modalCurrentDisplayItem: this.getModalItemContent(item) }); - if (this.modalRef.current) { - this.modalRef.current.open(); + if (this.modalRef) { + this.modalRef.open(); } } @@ -259,8 +260,8 @@ export default class ProximoListScreen extends React.Component { this.setState({ modalCurrentDisplayItem: this.getModalSortMenu() }); - if (this.modalRef.current) { - this.modalRef.current.open(); + if (this.modalRef) { + this.modalRef.open(); } } @@ -283,9 +284,9 @@ export default class ProximoListScreen extends React.Component { description={item.quantity + ' ' + i18n.t('proximoScreen.inStock')} descriptionStyle={{color: this.getStockColor(parseInt(item.quantity))}} onPress={onPress} - left={props => } - right={props => + right={() => {item.price}€ } @@ -297,20 +298,18 @@ export default class ProximoListScreen extends React.Component { return item.name + item.code; } + onModalRef(ref: Object) { + this.modalRef = ref; + } + render() { return ( - + {this.state.modalCurrentDisplayItem} - + { - modalRef: { current: null | Modalize }; + modalRef: Object; onAboutPress: Function; getRenderItem: Function; getRenderSectionHeader: Function; createDataset: Function; onHideBanner: Function; + onModalRef: Function; fetchedData: Object; @@ -66,7 +67,6 @@ export default class ProxiwashScreen extends React.Component { */ constructor() { super(); - this.modalRef = React.createRef(); stateStrings[ProxiwashConstants.machineStates.TERMINE] = i18n.t('proxiwashScreen.states.finished'); stateStrings[ProxiwashConstants.machineStates.DISPONIBLE] = i18n.t('proxiwashScreen.states.ready'); stateStrings[ProxiwashConstants.machineStates["EN COURS"]] = i18n.t('proxiwashScreen.states.running'); @@ -91,6 +91,7 @@ export default class ProxiwashScreen extends React.Component { this.getRenderSectionHeader = this.getRenderSectionHeader.bind(this); this.createDataset = this.createDataset.bind(this); this.onHideBanner = this.onHideBanner.bind(this); + this.onModalRef = this.onModalRef.bind(this); } onHideBanner() { @@ -249,14 +250,14 @@ export default class ProxiwashScreen extends React.Component { this.setState({ modalCurrentDisplayItem: this.getModalContent(title, item, isDryer) }); - if (this.modalRef.current) { - this.modalRef.current.open(); + if (this.modalRef) { + this.modalRef.open(); } } onSetupNotificationsPress(machineId: string) { - if (this.modalRef.current) { - this.modalRef.current.close(); + if (this.modalRef) { + this.modalRef.close(); } this.setupNotifications(machineId) } @@ -323,7 +324,6 @@ export default class ProxiwashScreen extends React.Component { ); } - onAboutPress() { this.props.navigation.navigate('ProxiwashAboutScreen'); } @@ -334,6 +334,10 @@ export default class ProxiwashScreen extends React.Component { ); } + onModalRef(ref: Object) { + this.modalRef = ref; + } + render() { const nav = this.props.navigation; return ( @@ -353,14 +357,9 @@ export default class ProxiwashScreen extends React.Component { > {i18n.t('proxiwashScreen.enableNotificationsTip')} - + {this.state.modalCurrentDisplayItem} - +