diff --git a/App.js b/App.js index 5fee225..8dec87e 100644 --- a/App.js +++ b/App.js @@ -12,7 +12,7 @@ import reducer from './src/reducers'; import HomeScreenContainer from './src/containers/HomeScreenContainer'; import SearchView from './src/components/HomeScreen/SearchView'; -import DetailScreen from './src/components/screens/DetailScreen'; +import DetailScreenContainer from './src/containers/DetailScreenContainer'; import EntryScreen from './src/components/screens/EntryScreen'; import ScanScreen from './src/components/screens/ScanScreen'; import EntryTagsScreen from './src/components/screens/EntryTagsScreen'; @@ -34,7 +34,7 @@ const RootStack = StackNavigator( screen: EntryTagsScreen, }, Detail: { - screen: DetailScreen, + screen: DetailScreenContainer, }, Search: { screen: SearchView, diff --git a/package.json b/package.json index e054f19..610507a 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "test": "jest", "test:watch": "npm test -- --watch", "appr": "appr", + "postinstall": "rndebugger-open", "debugger": "open 'rndebugger://set-debugger-loc?host=localhost&port=19001'" }, "jest": { diff --git a/src/__tests__/components/DetailScreen.test.js b/src/__tests__/components/DetailScreen.test.js new file mode 100644 index 0000000..5ee0728 --- /dev/null +++ b/src/__tests__/components/DetailScreen.test.js @@ -0,0 +1,21 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import DetailScreen from '../../components/DetailScreen'; +import _books from '../../api/books.json'; + +describe('', () => { + it('正しくレンダリングされていること', () => { + const navigation = { + state: { + params: { + item: _books[0], + }, + }, + }; + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); + }); +}); diff --git a/src/__tests__/components/__snapshots__/DetailScreen.test.js.snap b/src/__tests__/components/__snapshots__/DetailScreen.test.js.snap new file mode 100644 index 0000000..c9c733b --- /dev/null +++ b/src/__tests__/components/__snapshots__/DetailScreen.test.js.snap @@ -0,0 +1,688 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` 正しくレンダリングされていること 1`] = ` +ShallowWrapper { + "length": 1, + Symbol(enzyme.__root__): [Circular], + Symbol(enzyme.__unrendered__): , + Symbol(enzyme.__renderer__): Object { + "batchedUpdates": [Function], + "getNode": [Function], + "render": [Function], + "simulateEvent": [Function], + "unmount": [Function], + }, + Symbol(enzyme.__node__): Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "children": Array [ + , + + + + + javascript + + + 出版日: + 2018-02-09T00:00:00Z + + + + + + + , + ], + "style": Object { + "backgroundColor": "#fff", + "flex": 1, + }, + }, + "ref": null, + "rendered": Array [ + Object { + "instance": null, + "key": undefined, + "nodeType": "function", + "props": Object { + "uri": "none", + }, + "ref": null, + "rendered": null, + "type": [Function], + }, + Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "children": Array [ + , + + + javascript + + + 出版日: + 2018-02-09T00:00:00Z + + , + + + + , + ], + "style": Object { + "flex": 1, + }, + }, + "ref": null, + "rendered": Array [ + Object { + "instance": null, + "key": undefined, + "nodeType": "function", + "props": Object { + "tags": Array [], + }, + "ref": null, + "rendered": null, + "type": [Function], + }, + Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "children": Array [ + + javascript + , + + 出版日: + 2018-02-09T00:00:00Z + , + ], + "style": Object { + "flex": 1, + "justifyContent": "center", + "marginLeft": 50, + }, + }, + "ref": null, + "rendered": Array [ + Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "accessible": true, + "allowFontScaling": true, + "children": "javascript ", + "ellipsizeMode": "tail", + "style": Object { + "fontSize": 20, + "marginBottom": 10, + }, + }, + "ref": null, + "rendered": "javascript ", + "type": [Function], + }, + Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "accessible": true, + "allowFontScaling": true, + "children": Array [ + "出版日:", + "2018-02-09T00:00:00Z", + ], + "ellipsizeMode": "tail", + "style": Object { + "color": "#6E6E6E", + "fontSize": 14, + }, + }, + "ref": null, + "rendered": Array [ + "出版日:", + "2018-02-09T00:00:00Z", + ], + "type": [Function], + }, + ], + "type": [Function], + }, + Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "children": Array [ + , + , + ], + "style": Object { + "flex": 1, + "flexDirection": "row", + "marginBottom": 15, + }, + }, + "ref": null, + "rendered": Array [ + Object { + "instance": null, + "key": undefined, + "nodeType": "function", + "props": Object { + "status": true, + }, + "ref": null, + "rendered": null, + "type": [Function], + }, + Object { + "instance": null, + "key": undefined, + "nodeType": "function", + "props": Object { + "navigate": undefined, + "status": true, + }, + "ref": null, + "rendered": null, + "type": [Function], + }, + ], + "type": [Function], + }, + ], + "type": [Function], + }, + ], + "type": [Function], + }, + Symbol(enzyme.__nodes__): Array [ + Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "children": Array [ + , + + + + + javascript + + + 出版日: + 2018-02-09T00:00:00Z + + + + + + + , + ], + "style": Object { + "backgroundColor": "#fff", + "flex": 1, + }, + }, + "ref": null, + "rendered": Array [ + Object { + "instance": null, + "key": undefined, + "nodeType": "function", + "props": Object { + "uri": "none", + }, + "ref": null, + "rendered": null, + "type": [Function], + }, + Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "children": Array [ + , + + + javascript + + + 出版日: + 2018-02-09T00:00:00Z + + , + + + + , + ], + "style": Object { + "flex": 1, + }, + }, + "ref": null, + "rendered": Array [ + Object { + "instance": null, + "key": undefined, + "nodeType": "function", + "props": Object { + "tags": Array [], + }, + "ref": null, + "rendered": null, + "type": [Function], + }, + Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "children": Array [ + + javascript + , + + 出版日: + 2018-02-09T00:00:00Z + , + ], + "style": Object { + "flex": 1, + "justifyContent": "center", + "marginLeft": 50, + }, + }, + "ref": null, + "rendered": Array [ + Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "accessible": true, + "allowFontScaling": true, + "children": "javascript ", + "ellipsizeMode": "tail", + "style": Object { + "fontSize": 20, + "marginBottom": 10, + }, + }, + "ref": null, + "rendered": "javascript ", + "type": [Function], + }, + Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "accessible": true, + "allowFontScaling": true, + "children": Array [ + "出版日:", + "2018-02-09T00:00:00Z", + ], + "ellipsizeMode": "tail", + "style": Object { + "color": "#6E6E6E", + "fontSize": 14, + }, + }, + "ref": null, + "rendered": Array [ + "出版日:", + "2018-02-09T00:00:00Z", + ], + "type": [Function], + }, + ], + "type": [Function], + }, + Object { + "instance": null, + "key": undefined, + "nodeType": "class", + "props": Object { + "children": Array [ + , + , + ], + "style": Object { + "flex": 1, + "flexDirection": "row", + "marginBottom": 15, + }, + }, + "ref": null, + "rendered": Array [ + Object { + "instance": null, + "key": undefined, + "nodeType": "function", + "props": Object { + "status": true, + }, + "ref": null, + "rendered": null, + "type": [Function], + }, + Object { + "instance": null, + "key": undefined, + "nodeType": "function", + "props": Object { + "navigate": undefined, + "status": true, + }, + "ref": null, + "rendered": null, + "type": [Function], + }, + ], + "type": [Function], + }, + ], + "type": [Function], + }, + ], + "type": [Function], + }, + ], + Symbol(enzyme.__options__): Object { + "adapter": ReactSixteenAdapter { + "options": Object { + "enableComponentDidUpdateOnSetState": true, + }, + }, + }, +} +`; diff --git a/src/components/DetailScreen/BookImage.js b/src/components/DetailScreen/BookImage.js new file mode 100644 index 0000000..f0604e1 --- /dev/null +++ b/src/components/DetailScreen/BookImage.js @@ -0,0 +1,27 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { + View, + Image, +} from 'react-native'; + +import { bookImage as styles } from './Styles'; + +const BookImage = ({ uri }) => { + let imageUri = uri; + if (imageUri === 'none') { + imageUri = 'https://facebook.github.io/react/logo-og.png'; + } + + return ( + + + + ); +}; + +BookImage.propTypes = { + uri: PropTypes.string.isRequired, +}; + +export default BookImage; diff --git a/src/components/DetailScreen/LendingButton.js b/src/components/DetailScreen/LendingButton.js new file mode 100644 index 0000000..bdd8990 --- /dev/null +++ b/src/components/DetailScreen/LendingButton.js @@ -0,0 +1,58 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { View } from 'react-native'; +import { Button } from 'react-native-elements'; +import { MaterialCommunityIcons } from '@expo/vector-icons'; + +import { lendingButton as styles } from './Styles'; + +const LendButton = ({ navigate }) => ( + +