Authored by 于良

Merge branch 'local' into develop

... ... @@ -28,7 +28,7 @@ const {
let {width, height} = Dimensions.get('window');
let bannerHeight = Math.ceil((363 / 750) * width);
let sectionHeight = Math.ceil((435 / 750) * width);
let sectionHeight = Math.ceil((419 / 750) * width);
export default class Home extends React.Component {
... ... @@ -220,11 +220,15 @@ export default class Home extends React.Component {
} else if (type == 1) {
// hot
let postId = item.get('hot').get('postId')
this.props.onPressPost && this.props.onPressPost(postId);
if (postId) {
this.props.onPressPost && this.props.onPressPost(postId);
}
} else if (type == 2) {
// new
let postId = item.get('new').get('postId')
this.props.onPressPost && this.props.onPressPost(postId);
if (postId) {
this.props.onPressPost && this.props.onPressPost(postId);
}
}
}}
/>
... ... @@ -249,6 +253,14 @@ export default class Home extends React.Component {
_renderSectionHeader(sectionData, sectionID) {
switch (sectionID) {
case 'recommendation':
if (this.props.recommendation.size == 0) {
if (this.props.isLoadingMore && this.props.isFetching) {
} else {
return null;
}
}
return (
<View style={styles.sectionHeader}>
<Image style={styles.sectionHeaderImg} source={require('../../images/home/hot.png')}/>
... ... @@ -337,7 +349,7 @@ let styles = StyleSheet.create({
},
sectionHeader: {
flexDirection: 'row',
height: 32,
height: 33,
alignItems: 'center',
backgroundColor: 'white',
// borderTopWidth: 0.5, // borderTopWidth 在iPhone 6P上显示有bug
... ...
... ... @@ -7,6 +7,7 @@ import UserBrief from './UserBrief';
import Thumbs from './Thumbs';
import SectionItem from './SectionItem';
import NumberButton from './NumberButton';
import emojiDecter from '../../utils/emojiDecter';
const {
View,
... ... @@ -62,8 +63,25 @@ export default class ListCell extends React.Component {
let data = this.props.data.toJS();
let {author, timeago, isOwner, isTop, isLike, id, title, desc, thumbs, section, commentCount, likeCount} = data;
let likeImage = isLike ? require('../../images/home/like.png') : require('../../images/home/unlike.png');
let titleStyle = emojiDecter(title) ? null : {paddingTop: -(28 - 18) / 2};
let descStyle = emojiDecter(desc) ? null : {paddingTop: -(23 - 14) / 2};
let hideSection = this.props.hideSection;
let bottomStyle = hideSection ? {alignSelf: 'flex-end'} : null;
let thumbMarginTop = 10;
let bottomMarginTop = 15;
if (title && !desc && thumbs.length == 0) {
bottomMarginTop = 8;
}
if (title && desc && thumbs.length == 0) {
bottomMarginTop = 10;
}
if (title && desc && thumbs.length > 0) {
thumbMarginTop = 14;
bottomMarginTop = 15;
}
if (title && !desc && thumbs.length > 0) {
thumbMarginTop = 9;
}
return (
<TouchableOpacity
style={styles.row}
... ... @@ -84,10 +102,10 @@ export default class ListCell extends React.Component {
/>
{isTop ? <Text style={styles.topTag}>置顶</Text> : null}
</View>
{title ? <Text style={styles.title} numberOfLines={2}>{title}</Text> : null}
{desc ? <Text style={styles.desc} numberOfLines={2}>{desc}</Text> : null}
{thumbs.length > 0 ? <Thumbs style={styles.thumbs} data={thumbs}/> : null}
<View style={[styles.bottom, bottomStyle]}>
{title ? <Text style={[styles.title, titleStyle]} numberOfLines={2}>{title}</Text> : null}
{desc ? <Text style={[styles.desc, descStyle]} numberOfLines={2}>{desc}</Text> : null}
{thumbs.length > 0 ? <Thumbs style={[styles.thumbs, {marginTop: thumbMarginTop}]} data={thumbs}/> : null}
<View style={[styles.bottom, bottomStyle, {marginTop: bottomMarginTop}]}>
{hideSection ? null : <SectionItem
name={section.name}
onPressSection={() => {
... ... @@ -141,23 +159,23 @@ let styles = StyleSheet.create({
paddingTop: 4.5,
},
title: {
marginTop: -6,
fontSize: 18,
lineHeight: 28,
paddingTop: -(28 - 18) / 2 - 2,
},
desc: {
marginTop: 3,
fontSize: 14,
lineHeight: 23,
color: '#888888',
paddingTop: -(23 - 14) / 2,
},
thumbs: {
marginTop: 15,
marginTop: 10,
},
bottom: {
flexDirection: 'row',
justifyContent: 'space-between',
marginTop: 15,
marginTop: 12,
marginBottom: 15,
},
buttonContainer: {
... ...
... ... @@ -86,11 +86,13 @@ let styles = StyleSheet.create({
notice: {
marginLeft: 15,
marginRight: 5,
paddingVertical: 5,
paddingHorizontal: 10,
paddingTop: 4,
backgroundColor: 'black',
fontSize: 12,
color: 'white',
width: 42,
height: 20,
textAlign: 'center',
},
banner: {
... ...
... ... @@ -14,7 +14,7 @@ const {
} = ReactNative;
let {width, height} = Dimensions.get('window');
let thumbHeight = Math.ceil((214 / (750 - 34)) * (width - 34));
let thumbHeight = Math.ceil(214 / 750 * width);
let marginLeft = Math.ceil(width - 34 - thumbHeight * 3) / 2;
export default class Thumbs extends React.Component {
... ...
... ... @@ -15,7 +15,6 @@ const {
let {width, height} = Dimensions.get('window');
let thumbHeight = Math.ceil(276 / 750 * width);
let marginLeft = Math.ceil(width - 34 - thumbHeight * 3) / 2;
export default class SectionHeader extends React.Component {
... ... @@ -58,12 +57,14 @@ let styles = StyleSheet.create({
flexDirection: 'column',
// alignItems: 'center',
backgroundColor: '#b0b0b0',
width: width,
height: thumbHeight,
},
desc: {
color: 'white',
// fontFamily: 'SourceHanSansCN Normal',
fontSize: 24,
marginTop: 44,
marginTop: 42,
textAlign: 'center',
backgroundColor: 'transparent',
},
... ... @@ -72,7 +73,7 @@ let styles = StyleSheet.create({
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginTop: 15,
marginTop: 18,
marginBottom: 44,
},
content: {
... ...
... ... @@ -106,7 +106,7 @@ export default class UserThatNotMe extends React.Component {
_renderSectionHeader(sectionData, sectionID) {
switch (sectionID) {
case 'posts':
if (this.props.endReached && this.props.posts.size == 0) {
if (this.props.posts.size == 0) {
return null;
}
... ...
... ... @@ -179,5 +179,6 @@ export default keyMirror({
MESSAGE_INFO_REQUEST: null,
MESSAGE_INFO_SUCCESS: null,
MESSAGE_INFO_FAILURE: null,
MESSAGE_CLEAN: null,
});
... ...
... ... @@ -104,7 +104,6 @@ class HomeContainer extends React.Component {
(reminder) => {
let uid = reminder.uid;
this.props.actions.setUid(uid);
this.props.actions.syncUserWithSSOUid(uid);
this.triggerPullToRefresh();
}
);
... ... @@ -120,9 +119,7 @@ class HomeContainer extends React.Component {
}
componentDidMount() {
InteractionManager.runAfterInteractions(() => {
this.props.actions.syncUserInfo(false);
});
}
componentWillUnmount() {
... ... @@ -172,6 +169,10 @@ class HomeContainer extends React.Component {
_onRefresh() {
InteractionManager.runAfterInteractions(() => {
let uid = this.props.user.profile.uid;
if (uid) {
this.props.actions.syncUserWithSSOUid(uid);
}
this.props.actions.bannerNoticeSection();
this.props.actions.recommendation(true);
});
... ...
... ... @@ -60,6 +60,9 @@ class MessageCenterContainer extends React.Component {
this._onPressSystemCell = this._onPressSystemCell.bind(this);
}
componentWillUnmount() {
this.props.actions.messageClean();
}
_onPressAvatar(uid) {
this.props.actions.goToUserThatNotMe(uid);
... ...
... ... @@ -204,19 +204,6 @@ export function recommendation(ptr = false) {
};
}
export function increaseErrorCount(number) {
return {
type: INCREASE_ERROR_COUNT,
payload: number,
};
}
export function resetErrorCount() {
return {
type: RESET_ERROR_COUNT,
};
}
function parseBNS(json) {
let {resourceList, forumInfo} = json;
let {advertList, textNoticeList} = resourceList;
... ...
... ... @@ -21,12 +21,19 @@ const {
MESSAGE_SYST_REQUEST,
MESSAGE_SYST_SUCCESS,
MESSAGE_SYST_FAILURE,
MESSAGE_CLEAN,
} = require('../../constants/actionTypes').default;
const LIMIT = 10;
export function messageClean() {
return {
type: MESSAGE_CLEAN,
};
}
export function likeMessageRequest(ptr) {
return {
... ...
... ... @@ -19,7 +19,7 @@ const {
MESSAGE_SYST_SUCCESS,
MESSAGE_SYST_FAILURE,
USER_DID_LOGOUT,
MESSAGE_CLEAN,
} = require('../../constants/actionTypes').default;
... ... @@ -31,6 +31,7 @@ export default function message(state = initialState, action) {
switch (action.type) {
case USER_DID_LOGOUT:
case MESSAGE_CLEAN:
return initialState;
break;
case GO_TO_SYS_MESSAGE: {
... ...
'use strict';
export default function hasEmoji(string) {
if (!string.length) {
return false;
}
let emojiRegex = /(?:0\u20E3|1\u20E3|2\u20E3|3\u20E3|4\u20E3|5\u20E3|6\u20E3|7\u20E3|8\u20E3|9\u20E3|#\u20E3|\*\u20E3|\uD83C(?:\uDDE6\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\uDDFC\uD83C(?:\uDDEB|\uDDF8)|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C(?:\uDDEA|\uDDF9)|\uDDFF\uD83C(?:\uDDE6|\uDDF2|\uDDFC)))|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267B\u267F\u2692-\u2694\u2696\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD79\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED0\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3]|\uD83E[\uDD10-\uDD18\uDD80-\uDD84\uDDC0]/g;
if (string.match(emojiRegex)) {
return true;
} else {
return false;
}
}
... ...