-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/multicurrency' into dev
- Loading branch information
Showing
13 changed files
with
532 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,73 @@ | ||
import * as React from 'react'; | ||
import { SafeAreaView, ScrollView } from 'react-native'; | ||
import { SafeAreaView, ScrollView, Dimensions } from 'react-native'; | ||
import { Button, Dialog, Portal, Text } from 'react-native-paper'; | ||
import { connect } from 'react-redux'; | ||
import Colors from '../globals/colors'; | ||
|
||
const AlertModal = (props) => { | ||
const [modalShown, setModalShown] = React.useState(false); | ||
const [modalToBeShown, setModalToBeShown] = React.useState(false) | ||
const [modalToBeShown, setModalToBeShown] = React.useState(false); | ||
const visible = props.activeAlert != null; | ||
|
||
if (visible && !modalToBeShown) { | ||
setModalToBeShown(true) | ||
|
||
setTimeout(() => setModalShown(true), 100) | ||
setModalToBeShown(true); | ||
setTimeout(() => setModalShown(true), 100); | ||
} else if (!visible && modalToBeShown) { | ||
setModalToBeShown(false) | ||
setModalShown(false) | ||
setModalToBeShown(false); | ||
setModalShown(false); | ||
return null; | ||
} else if (!visible) return null; | ||
|
||
return null | ||
} else if (!visible) return null | ||
const { height } = Dimensions.get('window'); | ||
const dialogContentMaxHeight = height * 0.6; // Adjust this value as needed | ||
|
||
const title = props.activeAlert.title; | ||
const description = props.activeAlert.message; | ||
const buttons = props.activeAlert.buttons; | ||
const cancelable = | ||
props.activeAlert.options != null && props.activeAlert.cancelable; | ||
const disabled = | ||
props.activeAlert.options != null && props.activeAlert.disabled; | ||
const cancelable = props.activeAlert.options != null && props.activeAlert.cancelable; | ||
const disabled = props.activeAlert.options != null && props.activeAlert.disabled; | ||
|
||
return ( | ||
<Portal> | ||
<Dialog | ||
dismissable={(!disabled && cancelable) === true} | ||
visible={modalShown} | ||
onDismiss={cancelable ? cancel : () => {}} | ||
style={{maxHeight: "100%", marginBottom: 36}} | ||
> | ||
<Dialog.Title>{title}</Dialog.Title> | ||
<Dialog.Content style={{maxHeight: "80%"}}> | ||
<ScrollView> | ||
<Text>{description}</Text> | ||
</ScrollView> | ||
</Dialog.Content> | ||
<Dialog.Actions> | ||
{buttons != null | ||
? buttons.map((button, index) => { | ||
return ( | ||
<Button | ||
disabled={button.disabled || disabled} | ||
onPress={button.onPress} | ||
color={Colors.primaryColor} | ||
key={index} | ||
> | ||
{button.text} | ||
</Button> | ||
); | ||
}) | ||
: null} | ||
</Dialog.Actions> | ||
</Dialog> | ||
</Portal> | ||
<SafeAreaView> | ||
<Portal> | ||
<Dialog | ||
dismissable={(!disabled && cancelable) === true} | ||
visible={modalShown} | ||
onDismiss={cancelable ? cancel : () => {}} | ||
style={{ maxHeight: '100%', marginBottom: 36 }} | ||
> | ||
<Dialog.Title>{title}</Dialog.Title> | ||
<Dialog.Content style={{ maxHeight: dialogContentMaxHeight }}> | ||
<ScrollView> | ||
<Text>{description}</Text> | ||
</ScrollView> | ||
</Dialog.Content> | ||
<Dialog.Actions> | ||
<ScrollView horizontal> | ||
{buttons != null | ||
? buttons.map((button, index) => ( | ||
<Button | ||
disabled={button.disabled || disabled} | ||
onPress={button.onPress} | ||
color={Colors.primaryColor} | ||
key={index} | ||
> | ||
{button.text} | ||
</Button> | ||
)) | ||
: null} | ||
</ScrollView> | ||
</Dialog.Actions> | ||
</Dialog> | ||
</Portal> | ||
</SafeAreaView> | ||
); | ||
}; | ||
|
||
const mapStateToProps = (state) => { | ||
return { | ||
activeAlert: state.alert.active | ||
} | ||
activeAlert: state.alert.active, | ||
}; | ||
}; | ||
|
||
export default connect(mapStateToProps)(AlertModal); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.