diff --git a/jest.config.js b/jest.config.js index 7a9eecc..6f46f51 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,4 +1,12 @@ module.exports = { preset: 'react-native', setupFilesAfterEnv: ['@testing-library/jest-native/extend-expect'], + coverageThreshold: { + global: { + statements: 100, + branches: 90, + functions: 90, + lines: 90, + }, + }, }; diff --git a/src/components/App.tsx b/src/components/App.tsx index df7e042..e1b99e8 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -4,7 +4,7 @@ import 'react-native-gesture-handler'; import {Button, View} from 'react-native'; import {Provider as PaperProvider} from 'react-native-paper'; import {Provider} from 'react-redux'; -import {NavigationContainer} from '@react-navigation/native'; +import {NavigationContainer, NavigationProp} from '@react-navigation/native'; import {createStackNavigator, TransitionPresets} from '@react-navigation/stack'; import Stubs from '../stubs/Stubs'; @@ -13,8 +13,11 @@ import CreateListModal from '../stubs/CreateListModal'; import store from '../store/store'; import {RootStackParamList} from './types'; +import DetailMovieModal from '../stubs/DetailMovieModal'; +import CustomHeader from '../stubs/DetailMovieModal/CustomHeader'; const Stack = createStackNavigator(); +export type StackNavigation = NavigationProp; //TODO: interviewee fix warning const RootStack = () => ( @@ -67,6 +70,21 @@ const App = () => { headerShown: true, }} /> + ({ + headerShown: true, + header: () => ( + + ), + })} + /> diff --git a/src/components/types.ts b/src/components/types.ts index c6c0b68..8c756b4 100644 --- a/src/components/types.ts +++ b/src/components/types.ts @@ -4,4 +4,5 @@ export type RootStackParamList = { Stubs: undefined; Lists: undefined; CreateListModal: undefined; + DetailMovieModal: {title: string; description: string; itemsCount: number}; }; diff --git a/src/stubs/DetailMovieModal/CustomHeader/component.tsx b/src/stubs/DetailMovieModal/CustomHeader/component.tsx new file mode 100644 index 0000000..41e7344 --- /dev/null +++ b/src/stubs/DetailMovieModal/CustomHeader/component.tsx @@ -0,0 +1,76 @@ +import React from 'react'; +import {View, Text, TouchableOpacity, Platform, StyleSheet} from 'react-native'; +import {useNavigation} from '@react-navigation/native'; + +const CustomHeader = ({ + title, + description, + itemsCount, +}: { + title: string; + description: string; + itemsCount: number; +}) => { + const navigation = useNavigation(); + + return ( + + navigation.goBack()} + style={styles.backButton}> + Back + + + + {title} + {`(${itemsCount})`} + + {description} + + + ); +}; + +const styles = StyleSheet.create({ + header: { + backgroundColor: '#ffffff', + paddingTop: 24, + flexDirection: 'column', + borderBottomWidth: 1, + borderBottomColor: '#ccc', + paddingHorizontal: 15, + }, + backButton: { + alignSelf: 'flex-start', + }, + backButtonText: { + color: '#007AFF', + fontSize: 16, + }, + titleDescriptionContainer: { + flexDirection: 'column', + justifyContent: 'flex-start', + marginTop: 8, + }, + itemsCount: { + color: '#acacb0', + paddingLeft: 5, + }, + descriptionBlock: { + flexDirection: 'row', + justifyContent: 'flex-start', + alignItems: 'center', + }, + title: { + fontSize: 18, + fontWeight: 'bold', + color: '#333', + }, + description: { + fontSize: 14, + color: '#666', + paddingBottom: 10, + }, +}); + +export default CustomHeader; diff --git a/src/stubs/DetailMovieModal/CustomHeader/index.ts b/src/stubs/DetailMovieModal/CustomHeader/index.ts new file mode 100644 index 0000000..2e331cd --- /dev/null +++ b/src/stubs/DetailMovieModal/CustomHeader/index.ts @@ -0,0 +1 @@ +export {default} from './component'; diff --git a/src/stubs/DetailMovieModal/component.tsx b/src/stubs/DetailMovieModal/component.tsx new file mode 100644 index 0000000..544adad --- /dev/null +++ b/src/stubs/DetailMovieModal/component.tsx @@ -0,0 +1,105 @@ +import React from 'react'; + +import {View, StyleSheet} from 'react-native'; +import {Card, Chip, Text} from 'react-native-paper'; + +const DetailMovieModal = () => ( + + + + + + 23 + + + + + 12.02.22 + + + 6.8 + + + (43 456) + + + + + Description + + + + Genres 1 + Genres 2 + Genres 3 + + + +); + +const styles = StyleSheet.create({ + container: { + padding: 15, + }, + chip: { + width: 100, + backgroundColor: '#ebebeb', + color: '#232323', + borderRadius: 25, + paddingRight: 5, + marginBottom: 5, + }, + title: { + width: '70%', + }, + description: { + paddingTop: 10, + paddingBottom: 10, + width: '100%', + }, + vote: { + color: '#acacb0', + paddingLeft: 5, + }, + rate: { + fontWeight: 'bold', + }, + middleContentContainer: { + display: 'flex', + flexDirection: 'row', + justifyContent: 'flex-start', + alignItems: 'center', + }, + middleContentBlock: { + display: 'flex', + flexDirection: 'row', + justifyContent: 'flex-start', + alignItems: 'center', + paddingLeft: 20, + }, + popularityText: { + width: '30%', + textAlign: 'right', + paddingTop: 15, + paddingRight: 15, + }, + chipContainer: { + width: '100%', + display: 'flex', + flexDirection: 'row', + justifyContent: 'space-between', + flexWrap: 'wrap', + padding: 10, + }, + card: { + backgroundColor: '#ffffff', + }, + titleContainer: { + width: '100%', + display: 'flex', + flexDirection: 'row', + justifyContent: 'space-between', + }, +}); + +export default DetailMovieModal; diff --git a/src/stubs/DetailMovieModal/index.ts b/src/stubs/DetailMovieModal/index.ts new file mode 100644 index 0000000..2e331cd --- /dev/null +++ b/src/stubs/DetailMovieModal/index.ts @@ -0,0 +1 @@ +export {default} from './component'; diff --git a/src/stubs/Lists/component.tsx b/src/stubs/Lists/component.tsx index f57f960..64da3e4 100644 --- a/src/stubs/Lists/component.tsx +++ b/src/stubs/Lists/component.tsx @@ -2,7 +2,6 @@ import React, {useState} from 'react'; import {StyleSheet, FlatList, Text, View} from 'react-native'; import { - IconButton, Card, Title, Paragraph, @@ -12,25 +11,29 @@ import { Snackbar, } from 'react-native-paper'; import {range} from 'lodash'; +import {useNavigation} from '@react-navigation/native'; +import {StackNavigation} from '../../components/App'; const data = range(10).map(index => ({index})); -//TODO: interviewee add type const RemoveDialog = ({visible, hideDialog, onOkPress}) => ( - + Do you want to delete list? - - + + ); -//TODO: interviewee add type const RemoveDialogError = ({visible, onDismissSnackBar}) => ( Oops, something went wrong @@ -40,6 +43,7 @@ const RemoveDialogError = ({visible, onDismissSnackBar}) => ( const Lists = () => { const [modalVisible, setModalVisible] = useState(false); const [snackbarVisible, setSnackbarVisible] = useState(false); + const navigation = useNavigation(); const showModal = () => { setModalVisible(true); @@ -72,7 +76,26 @@ const Lists = () => { Description - + + )} @@ -99,9 +122,13 @@ const styles = StyleSheet.create({ list: { flex: data.length === 0 ? 1 : 0, }, + dialog: { + backgroundColor: '#ffffff', + }, card: { flex: 1, margin: 5, + backgroundColor: '#ffffff', }, row: { flex: 1,