diff --git a/package-lock.json b/package-lock.json index 5f47c3f..57ee70f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10842,6 +10842,11 @@ "resolved": "http://registry.npm.taobao.org/react-native-iphone-x-helper/download/react-native-iphone-x-helper-1.0.2.tgz", "integrity": "sha1-fbylMJMPfBzoYzzI/RO6lBApkuE=" }, + "react-native-keyboard-spacer": { + "version": "0.4.1", + "resolved": "http://registry.npm.taobao.org/react-native-keyboard-spacer/download/react-native-keyboard-spacer-0.4.1.tgz", + "integrity": "sha1-RvGKMgQyCYol6p+on1FD3SVNMy0=" + }, "react-native-navigation": { "version": "2.18.5", "resolved": "https://registry.npm.taobao.org/react-native-navigation/download/react-native-navigation-2.18.5.tgz", diff --git a/package.json b/package.json index 4ba2b5a..4b07cec 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "react-native-device-info": "^1.6.1", "react-native-elements": "^0.19.0", "react-native-iphone-x-helper": "^1.0.2", + "react-native-keyboard-spacer": "^0.4.1", "react-native-navigation": "^2.18.5", "react-native-root-toast": "^3.0.0", "react-native-tab-view": "^1.3.0", diff --git a/src/component/comment/commentInput.js b/src/component/comment/commentInput.js new file mode 100644 index 0000000..ca7de12 --- /dev/null +++ b/src/component/comment/commentInput.js @@ -0,0 +1,119 @@ +import React, {Component} from 'react'; +import {StyleSheet, Text, View, ActivityIndicator, TextInput, TouchableOpacity} from 'react-native'; +import Icon from 'react-native-vector-icons/Ionicons'; +import KeyboardSpacer from "react-native-keyboard-spacer"; + +import Touchable from '../touchable'; +import Color from '../../style/color'; +import Api from '../../util/api'; + + +export default class CommentInput extends Component { + + constructor(props) { + super(props); + + this.state = { + sending: false + }; + } + + sendComment() { + this.setState({sending: true}); + } + + render() { + return ( + + {}} + /> + + + + + + + + {this.state.sending + ? ( + + + + ) : null} + + { + !Api.IS_ANDROID + ? + : null + } + + + ); + } +} + +const localStyle = StyleSheet.create({ + container: { + height: 56, + backgroundColor: '#eee', + elevation: 3, + borderColor: '#bbb', + borderTopWidth: StyleSheet.hairlineWidth + }, + input: { + flexGrow: 1, + borderColor: '#bbb', + backgroundColor: '#fff', + borderWidth: StyleSheet.hairlineWidth, + borderRadius: 19, + paddingRight: 40, + paddingLeft: 15, + paddingTop: 12, + paddingBottom: 12, + fontSize: 12, + lineHeight: 24, + margin: 8 + }, + buttonWrap: { + position: 'absolute', + bottom: 0, + right: 0, + paddingBottom: 12, + paddingRight:12, + paddingTop: 12 + }, + button: { + width: 32, + height: 32, + backgroundColor: Color.light, + alignItems: 'center', + justifyContent: 'center', + borderRadius: 16 + }, + sending: { + flexGrow: 1, + opacity: 0.8, + backgroundColor: "#fff", + top: 0, + left: 0, + bottom:0, + right:0, + alignItems: 'center', + justifyContent: 'center', + position: 'absolute' + } +}); \ No newline at end of file diff --git a/src/component/comment/commentList.js b/src/component/comment/commentList.js index 7891b7f..9dabc39 100644 --- a/src/component/comment/commentList.js +++ b/src/component/comment/commentList.js @@ -63,8 +63,21 @@ export default class CommentList extends Component { ) }} + + ListHeaderComponent={() => { + let count = this.state.comments.length; + return ( + + + + {count > 0 ? `共 ${count} 条回复` : '还没有人回复'} + + + ); + }} > + ); } @@ -73,8 +86,19 @@ export default class CommentList extends Component { const localStyle = StyleSheet.create({ container: { flex: 1, - backgroundColor: Color.navBackground, + backgroundColor: 'white', justifyContent: 'space-between', paddingBottom: Api.IS_IPHONEX ? 30 : 0 + }, + line: { + borderBottomWidth: StyleSheet.hairlineWidth, + borderColor: Color.line, + marginHorizontal: 15 + }, + header: { + marginHorizontal: 16, + marginTop: 20, + marginBottom: 20, + color: Color.inactiveText } }); \ No newline at end of file diff --git a/src/component/diary/diaryFull.js b/src/component/diary/diaryFull.js index 966c0d3..fe477d2 100644 --- a/src/component/diary/diaryFull.js +++ b/src/component/diary/diaryFull.js @@ -11,20 +11,33 @@ import CommentList from '../comment/commentList'; export default class DiaryFull extends Component { + constructor(props) { + super(props); + this.diary = props.diary; + } + render() { - let diary = this.props.diary; + let diary = this.diary; + if(!diary) { + return null; + } + let user = diary.user; - let editable = this.props.editable; return ( - + {user && user.iconUrl + ? : null} + - - {user.name} - + {user && user.name + ? ( + {user.name} + + ) : null} + 《{diary.notebook_subject}》 diff --git a/src/page/DiaryDetailPage.js b/src/page/DiaryDetailPage.js index 5d21149..2d3881a 100644 --- a/src/page/DiaryDetailPage.js +++ b/src/page/DiaryDetailPage.js @@ -3,19 +3,28 @@ import {Platform, StyleSheet, Text, View, ScrollView} from 'react-native'; import Color from '../style/color'; import DiaryFull from '../component/diary/diaryFull'; +import CommentInput from '../component/comment/commentInput' export default class DiaryDetailPage extends Component { render() { return ( - - - - ); + + + + + + + + + ); } } const localStyle = StyleSheet.create({ - + wrap: { + flex: 1, + flexDirection: 'column' + } }); diff --git a/src/page/HomePage.js b/src/page/HomePage.js index 5e547f5..039f295 100644 --- a/src/page/HomePage.js +++ b/src/page/HomePage.js @@ -20,12 +20,20 @@ export default class HomePage extends Component { Navigation.push(this.props.componentId, { component: { name: 'DiaryDetail', + options: { + bottomTabs: { + visible: false, + + // hide bottom tab for android + drawBehind: true, + animate: true + } + }, passProps: { diary: diary } } }); - } render() {