Skip to content

Commit

Permalink
fix: save for diff
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-weber committed Jun 21, 2023
1 parent 5e61135 commit 3e344e3
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 110 deletions.
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"useTabs": true,
"tabWidth": 4,
"semi": false
}
5 changes: 2 additions & 3 deletions app.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

const configPath = `${__dirname}/config/app.config.ts`;

require('ts-node/register');
require("ts-node/register");

module.exports = require(configPath);
module.exports = require(configPath);
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

227 changes: 130 additions & 97 deletions src/components/modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,125 +19,158 @@ export default function MyModal({
visible,
success,
isContactList,
children
children,
}: IMyModalProps) {

const { color, highlight } = useContext(ThemeContext)

const getCorrectStyle = () => {
if (type === 'bottom') { return styles(color, highlight).bottomView }
if (type === 'question' || type === 'success' || type === 'error' || type === 'invoiceAmount') {
if (type === 'bottom') {
return styles(color, highlight).bottomView
}
if (
type === 'question' ||
type === 'success' ||
type === 'error' ||
type === 'invoiceAmount'
) {
return styles(color, highlight).centeredView
}
}

const getViewStyle = () => {
if (type === 'bottom') { return { ...styles(color, highlight).common, ...styles(color, highlight).modalView } }
if (type === 'question') { return { ...styles(color, highlight).common, ...styles(color, highlight).centeredModalView } }
if (type === 'success') { return { ...styles(color, highlight).common, ...styles(color, highlight).successModalView } }
if (type === 'error') { return { ...styles(color, highlight).common, ...styles(color, highlight).promptModalView } }
if (type === 'bottom') {
return {
...styles(color, highlight).common,
...styles(color, highlight).modalView,
}
}
if (type === 'question') {
return {
...styles(color, highlight).common,
...styles(color, highlight).centeredModalView,
}
}
if (type === 'success') {
return {
...styles(color, highlight).common,
...styles(color, highlight).successModalView,
}
}
if (type === 'error') {
return {
...styles(color, highlight).common,
...styles(color, highlight).promptModalView,
}
}
if (type === 'invoiceAmount') {
let styling = {
...styles(color, highlight).common,
...styles(color, highlight).invoiceAmountModalView,
}
if (isContactList) {
styling = { ...styling, ...styles(color, highlight).contactList }
styling = {
...styling,
...styles(color, highlight).contactList,
}
}
return styling
}
}

return (
visible ?
<View style={styles(color, highlight).modalParent}>
<Modal
animationType={animation}
transparent={true}
visible={visible}
return visible ? (
<View style={styles(color, highlight).modalParent}>
<Modal
animationType={animation}
transparent={true}
visible={visible}
>
<KeyboardAvoidingView
style={getCorrectStyle()}
behavior={isIOS ? 'padding' : 'height'}
>
<KeyboardAvoidingView
style={getCorrectStyle()}
behavior={isIOS ? 'padding' : 'height'}
<View
style={[
getViewStyle(),
success ? { backgroundColor: hi[highlight] } : {},
]}
>
<View style={[getViewStyle(), success ? { backgroundColor: hi[highlight] } : {}]}>
{children}
</View>
</KeyboardAvoidingView>
</Modal>
</View>
: null
)
{children}
</View>
</KeyboardAvoidingView>
</Modal>
</View>
) : null
}

const styles = (pref: TPref, h: string) => StyleSheet.create({
modalParent: {
position: 'absolute',
top: 0,
right: 0,
bottom: 0,
left: 0,
backgroundColor: 'rgba(0, 0, 0, .5)',
},
common: {
backgroundColor: pref.BACKGROUND,
alignItems: 'center',
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2,
const styles = (pref: TPref, h: string) =>
StyleSheet.create({
modalParent: {
position: 'absolute',
top: 0,
right: 0,
bottom: 0,
left: 0,
backgroundColor: 'rgba(0, 0, 0, .5)',
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5,
},
// Bottom Modal
bottomView: {
flex: 1,
justifyContent: 'flex-end',
alignItems: 'center',
},
modalView: {
width: '100%',
borderTopLeftRadius: 20,
borderTopRightRadius: 20,
padding: 20,
},
// Centered Modal
centeredView: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
centeredModalView: {
width: '90%',
borderRadius: 20,
borderWidth: 3,
borderColor: hi[h],
paddingTop: 50,
paddingBottom: 50,
paddingRight: 20,
paddingLeft: 20,
},
// Success Modal
successModalView: {
width: '90%',
borderRadius: 20,
},
promptModalView: {
width: '90%',
borderRadius: 20,
borderWidth: 3,
borderColor: hi[h],
padding: 20,
},
invoiceAmountModalView: {
width: '100%',
height: '100%',
padding: 20,
justifyContent: 'space-between',
},
contactList: {
paddingHorizontal: 0,
}
})
common: {
backgroundColor: pref.BACKGROUND,
alignItems: 'center',
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5,
},
// Bottom Modal
bottomView: {
flex: 1,
justifyContent: 'flex-end',
alignItems: 'center',
},
modalView: {
width: '100%',
borderTopLeftRadius: 20,
borderTopRightRadius: 20,
padding: 20,
},
// Centered Modal
centeredView: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
centeredModalView: {
width: '90%',
borderRadius: 20,
borderWidth: 3,
borderColor: hi[h],
paddingTop: 50,
paddingBottom: 50,
paddingRight: 20,
paddingLeft: 20,
},
// Success Modal
successModalView: {
width: '90%',
borderRadius: 20,
},
promptModalView: {
width: '90%',
borderRadius: 20,
borderWidth: 3,
borderColor: hi[h],
padding: 20,
},
invoiceAmountModalView: {
width: '100%',
height: '100%',
padding: 20,
justifyContent: 'space-between',
},
contactList: {
paddingHorizontal: 0,
},
})

0 comments on commit 3e344e3

Please sign in to comment.