Skip to content

Commit

Permalink
Add custom modal components for every basic screens
Browse files Browse the repository at this point in the history
  • Loading branch information
bemog committed Jul 22, 2021
1 parent 2ce3ba2 commit 0a4722a
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 21 deletions.
6 changes: 2 additions & 4 deletions app/components/Button/ButtonComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import {
import {theme} from '../../theme/theme';

interface Props {
title: string;
title?: string;
style?: StyleProp<ViewStyle>;
onClick?: () => void;
}

const ButtonComponent = ({title, style, onClick}: Props) => {
const ButtonComponent = ({title = 'Modal', style, onClick}: Props) => {
return (
<TouchableOpacity onPress={onClick} style={[styles.button, style]}>
<View>
Expand All @@ -29,8 +29,6 @@ const styles = StyleSheet.create({
button: {
width: theme.buttons.standardWidth,
height: theme.buttons.standardHeight,
paddingVertical: 5,
paddingHorizontal: 10,
justifyContent: 'center',
alignItems: 'center',
borderWidth: 1,
Expand Down
4 changes: 2 additions & 2 deletions app/screens/ExtraScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import ButtonComponent from '../components/Button/ButtonComponent';
const ExtraScreen = () => {
return (
<View style={styles.container}>
<ButtonComponent title="Modal" />
<ButtonComponent title="Modal" />
<ButtonComponent />
<ButtonComponent />
</View>
);
};
Expand Down
43 changes: 38 additions & 5 deletions app/screens/FadeScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
import React from 'react';
import React, {useState} from 'react';
import {View, StyleSheet} from 'react-native';

import ButtonComponent from '../components/Button/ButtonComponent';
import ModalComponent from '../components/Modal/ModalComponent';

const FadeScreen = () => {
const [showFirstModal, setShowFirstModal] = useState(false);
const [showSecondModal, setShowSecondModal] = useState(false);
const [showThirdModal, setShowThirdModal] = useState(false);
const [showFourthModal, setShowFourthModal] = useState(false);

return (
<View style={styles.container}>
<ButtonComponent title="Modal" />
<ButtonComponent title="Modal" />
<ButtonComponent title="Modal" />
<ButtonComponent title="Modal" />
<ButtonComponent onClick={() => setShowFirstModal(true)} />
<ModalComponent
isVisible={showFirstModal}
onBackdropPress={() => setShowFirstModal(false)}
onBackButtonPress={() => setShowFirstModal(false)}
hideModal={() => setShowFirstModal(false)}
/>

<ButtonComponent onClick={() => setShowSecondModal(true)} />
<ModalComponent
isVisible={showSecondModal}
onBackdropPress={() => setShowSecondModal(false)}
onBackButtonPress={() => setShowSecondModal(false)}
hideModal={() => setShowSecondModal(false)}
/>

<ButtonComponent onClick={() => setShowThirdModal(true)} />
<ModalComponent
isVisible={showThirdModal}
onBackdropPress={() => setShowThirdModal(false)}
onBackButtonPress={() => setShowThirdModal(false)}
hideModal={() => setShowThirdModal(false)}
/>

<ButtonComponent onClick={() => setShowFourthModal(true)} />
<ModalComponent
isVisible={showFourthModal}
onBackdropPress={() => setShowFourthModal(false)}
onBackButtonPress={() => setShowFourthModal(false)}
hideModal={() => setShowFourthModal(false)}
/>
</View>
);
};
Expand Down
55 changes: 50 additions & 5 deletions app/screens/RotateScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,64 @@
import React from 'react';
import React, {useState} from 'react';
import {View, StyleSheet, Dimensions} from 'react-native';
import {theme} from '../theme/theme';

import ButtonComponent from '../components/Button/ButtonComponent';
import ModalComponent from '../components/Modal/ModalComponent';

const width = Dimensions.get('window').width;
const heigth = Dimensions.get('window').height;

const RotateScreen = () => {
const [showFirstModal, setShowFirstModal] = useState(false);
const [showSecondModal, setShowSecondModal] = useState(false);
const [showThirdModal, setShowThirdModal] = useState(false);
const [showFourthModal, setShowFourthModal] = useState(false);

return (
<View style={styles.container}>
<ButtonComponent title="Modal" style={styles.buttonTopLeft} />
<ButtonComponent title="Modal" style={styles.buttonTopRight} />
<ButtonComponent title="Modal" style={styles.buttonBottomLeft} />
<ButtonComponent title="Modal" style={styles.buttonBottomRight} />
<ButtonComponent
style={styles.buttonTopLeft}
onClick={() => setShowFirstModal(true)}
/>
<ModalComponent
isVisible={showFirstModal}
onBackdropPress={() => setShowFirstModal(false)}
onBackButtonPress={() => setShowFirstModal(false)}
hideModal={() => setShowFirstModal(false)}
/>

<ButtonComponent
style={styles.buttonTopRight}
onClick={() => setShowSecondModal(true)}
/>
<ModalComponent
isVisible={showSecondModal}
onBackdropPress={() => setShowSecondModal(false)}
onBackButtonPress={() => setShowSecondModal(false)}
hideModal={() => setShowSecondModal(false)}
/>

<ButtonComponent
style={styles.buttonBottomLeft}
onClick={() => setShowThirdModal(true)}
/>
<ModalComponent
isVisible={showThirdModal}
onBackdropPress={() => setShowThirdModal(false)}
onBackButtonPress={() => setShowThirdModal(false)}
hideModal={() => setShowThirdModal(false)}
/>

<ButtonComponent
style={styles.buttonBottomRight}
onClick={() => setShowFourthModal(true)}
/>
<ModalComponent
isVisible={showFourthModal}
onBackdropPress={() => setShowFourthModal(false)}
onBackButtonPress={() => setShowFourthModal(false)}
hideModal={() => setShowFourthModal(false)}
/>
</View>
);
};
Expand Down
71 changes: 66 additions & 5 deletions app/screens/SlideScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,80 @@
import React from 'react';
import React, {useState} from 'react';
import {View, StyleSheet, Dimensions} from 'react-native';
import {theme} from '../theme/theme';

import ButtonComponent from '../components/Button/ButtonComponent';
import ModalComponent from '../components/Modal/ModalComponent';

const width = Dimensions.get('window').width;
const heigth = Dimensions.get('window').height;

const SlideScreen = () => {
const [showFirstModal, setShowFirstModal] = useState(false);
const [showSecondModal, setShowSecondModal] = useState(false);
const [showThirdModal, setShowThirdModal] = useState(false);
const [showFourthModal, setShowFourthModal] = useState(false);

return (
<View style={styles.container}>
<ButtonComponent title="Modal" style={styles.buttonTop} />
<ButtonComponent title="Modal" style={styles.buttonLeft} />
<ButtonComponent title="Modal" style={styles.buttonRight} />
<ButtonComponent title="Modal" style={styles.buttonBottom} />
<ButtonComponent
style={styles.buttonTop}
onClick={() => setShowFirstModal(true)}
/>
<ModalComponent
isVisible={showFirstModal}
onBackdropPress={() => setShowFirstModal(false)}
onBackButtonPress={() => setShowFirstModal(false)}
swipeDirection="up"
onSwipeComplete={() => setShowFirstModal(false)}
animationIn="slideInDown"
animationOut="slideOutUp"
hideModal={() => setShowFirstModal(false)}
/>

<ButtonComponent
style={styles.buttonLeft}
onClick={() => setShowSecondModal(!showSecondModal)}
/>
<ModalComponent
isVisible={showSecondModal}
onBackdropPress={() => setShowSecondModal(false)}
onBackButtonPress={() => setShowSecondModal(false)}
swipeDirection="left"
onSwipeComplete={() => setShowSecondModal(false)}
animationIn="slideInLeft"
animationOut="slideOutLeft"
hideModal={() => setShowSecondModal(false)}
/>

<ButtonComponent
style={styles.buttonRight}
onClick={() => setShowThirdModal(!showThirdModal)}
/>
<ModalComponent
isVisible={showThirdModal}
onBackdropPress={() => setShowThirdModal(false)}
onBackButtonPress={() => setShowThirdModal(false)}
swipeDirection="right"
onSwipeComplete={() => setShowThirdModal(false)}
animationIn="slideInRight"
animationOut="slideOutRight"
hideModal={() => setShowThirdModal(false)}
/>

<ButtonComponent
style={styles.buttonBottom}
onClick={() => setShowFourthModal(!showFourthModal)}
/>
<ModalComponent
isVisible={showFourthModal}
onBackdropPress={() => setShowFourthModal(false)}
onBackButtonPress={() => setShowFourthModal(false)}
swipeDirection="down"
onSwipeComplete={() => setShowFourthModal(false)}
animationIn="slideInUp"
animationOut="slideOutDown"
hideModal={() => setShowFourthModal(false)}
/>
</View>
);
};
Expand Down
2 changes: 2 additions & 0 deletions app/theme/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ export const theme = {
black: '#000',
},
buttons: {
smallWidth: 80,
standardWidth: 100,
smallHeight: 30,
standardHeight: 40,
},
iconSizes: {
Expand Down

0 comments on commit 0a4722a

Please sign in to comment.