Authored by 于良

Merge branch 'local' into develop

... ... @@ -296,6 +296,7 @@ export default function community(platform) {
key="SubjectPost"
title="主题帖"
hideNavBar={false}
clone={true}
component={SubjectPostContainer}
initial={false}
rightButtonImage={require('./images/posting/share.png')}
... ... @@ -317,9 +318,9 @@ export default function community(platform) {
<Scene
key='LikeList'
hideNavBar={false}
clone={true}
component={LikeListContainer}
initial={false}
clone={true}
getSceneStyle={(props) => {
return this.navPushStyle(props);
}}
... ...
... ... @@ -166,7 +166,7 @@ export default class NavBarTitle extends React.Component {
render() {
let index = this.props.index;
console.log(width);
return (
<Animated.View
style={[
... ...
... ... @@ -171,7 +171,6 @@ export default class User extends React.Component {
this._renderRow = this._renderRow.bind(this);
this._renderSeparator = this._renderSeparator.bind(this);
this._updateHorizontalScrollValue = this._updateHorizontalScrollValue.bind(this);
this._updateVerticalScrollValue = this._updateVerticalScrollValue.bind(this);
this._getCurrentPageHeight = this._getCurrentPageHeight.bind(this);
this.getPageList = this.getPageList.bind(this);
... ... @@ -314,10 +313,6 @@ export default class User extends React.Component {
this.state.scrollValueH.setValue(value);
}
_updateVerticalScrollValue(value) {
this.state.scrollValueV.setValue(value);
}
_getCurrentPageHeight(page) {
let ref = null;
if (page == 0) {
... ... @@ -398,10 +393,13 @@ export default class User extends React.Component {
/>
}
}}
onScroll={(e) => {
const offsetY = e.nativeEvent.contentOffset.y;
this._updateVerticalScrollValue(offsetY/150);
}}
onScroll={Animated.event([{
nativeEvent: {
contentOffset: {
y: this.state.scrollValueV
}
}
}])}
/>
<UserNavBar
... ...
... ... @@ -98,50 +98,14 @@ class UserNavBar extends React.Component {
this.renderBackButton = this.renderBackButton.bind(this);
this.renderRightButton = this.renderRightButton.bind(this);
this.setAnimationValue = this.setAnimationValue.bind(this);
this.headerColor = this.headerColor.bind(this);
}
componentDidMount() {
this._listener = this.props.scrollValue.addListener(this.setAnimationValue);
}
componentWillUnmount() {
this.props.scrollValue.removeListener(this._listener);
}
setAnimationValue({ value, }) {
if (value >= 0 && value <= 2) {
if (value > 0.5 && value < 1) {
value = value + 0.1;
}
this.headerView.setNativeProps({
style: {
backgroundColor: this.headerColor(value),
},
});
// value = value > 1 ? 1 : value;
// this.image.setNativeProps({
// style: {
// opacity: value,
// },
// });
}
}
componentWillUnmount() {
//color between rgb(255,255,255) and rgb(0,0,0)
headerColor(progress) {
const red = 255 + (0 - 255) * progress;
const green = 255 + (0 - 255) * progress;
const blue = 255 + (0 - 255) * progress;
if (progress > 1) {
return `rgb(0, 0, 0)`; //`darkgray`
} else {
return `rgba(${red}, ${green}, ${blue}, ${progress})`;
}
}
renderBackButton() {
... ... @@ -192,6 +156,16 @@ class UserNavBar extends React.Component {
}
render() {
let interpolatedColor = this.props.scrollValue.interpolate({
inputRange: [0, 64],
outputRange: ['rgba(255, 255, 255, 0)', 'rgba(255, 255, 255, 1)'],
extrapolate: 'clamp'
});
let interpolatedOpacity = this.props.scrollValue.interpolate({
inputRange: [0, 64],
outputRange: [0, 1],
extrapolate: 'clamp'
});
return (
<Animated.View
ref={(c) => {
... ... @@ -199,17 +173,18 @@ class UserNavBar extends React.Component {
}}
style={[
styles.header,
{backgroundColor: interpolatedColor}
]}
>
<Image
<Animated.Image
ref={(c) => {
this.image = c;
}}
source={this.getNavBarBackgroundImage(this.props.channel)}
style={[styles.image, {opacity: 0,}]}
style={[styles.image, {opacity: interpolatedOpacity}]}
>
</Image>
</Animated.Image>
{this.renderBackButton()}
{this.renderRightButton()}
</Animated.View>
... ...
... ... @@ -79,7 +79,6 @@ export default class UserThatNotMe extends React.Component {
this._renderRow = this._renderRow.bind(this);
this._renderSectionHeader = this._renderSectionHeader.bind(this);
this._renderSeparator = this._renderSeparator.bind(this);
this._updateScrollValue = this._updateScrollValue.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2),
... ... @@ -149,10 +148,6 @@ export default class UserThatNotMe extends React.Component {
}
}
_updateScrollValue(value) {
this.state.scrollValue.setValue(value);
}
render() {
let {posts, endReached, isRefreshing, isLoadingMore, isFetching} = this.props;
let dataSource = {
... ... @@ -165,10 +160,13 @@ export default class UserThatNotMe extends React.Component {
ref={(c) => {
this.listView = c;
}}
onScroll={(e) => {
const offsetY = e.nativeEvent.contentOffset.y;
this._updateScrollValue(offsetY / 150);
}}
onScroll={Animated.event([{
nativeEvent: {
contentOffset: {
y: this.state.scrollValue
}
}
}])}
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
renderHeader={this._renderHeader}
renderRow={this._renderRow}
... ...

1.39 KB | W: | H:

5.81 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

4.5 KB | W: | H:

6.84 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

13.6 KB | W: | H:

16.6 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
... ... @@ -36,27 +36,39 @@ const {
} = require('../../constants/actionTypes').default;
export function goToSection(section) {
Actions.Section();
return {
type: GO_TO_SECTION,
payload: section,
};
return (dispatch, getState) => {
let {route} = getState();
let tryToClean = route.lastPopScene == 'Section';
Actions.Section();
dispatch({
type: GO_TO_SECTION,
payload: {...section, tryToClean},
});
}
}
export function goToPost(id) {
Actions.SubjectPost({postId:id});
return {
type: GO_TO_POST,
payload: id,
};
return (dispatch, getState) => {
let {route} = getState();
let tryToClean = route.lastPopScene == 'SubjectPost';
Actions.SubjectPost({postId:id});
dispatch({
type: GO_TO_POST,
payload: {id, tryToClean},
});
}
}
export function goToLikeList(postId, likeCount) {
Actions.LikeList({title: `共${likeCount}个赞`});
return {
type: GO_TO_LIKE_LIST,
payload: postId,
};
return (dispatch, getState) => {
let {route} = getState();
let tryToClean = route.lastPopScene == 'LikeList';
Actions.LikeList({title: `共${likeCount}个赞`});
dispatch({
type: GO_TO_LIKE_LIST,
payload: {postId, tryToClean},
});
}
}
export function goToUserOrMe(uid) {
... ... @@ -68,11 +80,7 @@ export function goToUserOrMe(uid) {
type: GO_TO_USER,
});
} else {
Actions.UserThatNotMe();
dispatch({
type: GO_TO_USER_THAT_NOT_ME,
payload: uid,
});
dispatch(goToUserThatNotMe(uid));
}
};
}
... ... @@ -97,14 +105,15 @@ export function goToUser() {
export function goToUserThatNotMe(uid) {
return (dispatch, getState) => {
let {user} = getState();
let {user, route} = getState();
if (user.profile.uid == uid) {
} else {
Actions.UserThatNotMe();
let tryToClean = route.lastPopScene == 'UserThatNotMe';
Actions.UserThatNotMe();
dispatch({
type: GO_TO_USER_THAT_NOT_ME,
payload: uid,
payload: {uid, tryToClean},
});
}
};
... ...
... ... @@ -17,6 +17,7 @@ let InitialState = Record({
sid: -1,
items: List(),
item: item,
cleaned: false,
});
export default InitialState;
... ...
... ... @@ -24,15 +24,26 @@ export default function likeList(state = initialState, action) {
switch (action.type) {
case GO_TO_LIKE_LIST: {
let sid = state.sid + 1;
let currentSid = state.sid;
let newItems = state.items;
let newSid = currentSid;
// componentWillUnmount未调用,导致clean操作未进行
if (action.payload.tryToClean && currentSid > -1 && !state.cleaned) {
newItems = newItems.pop();
newSid = newSid - 1;
}
let sid = newSid + 1;
// 获取新的初始状态item
let item = initialState.item;
// 设置item的value
item = item.set('postId', action.payload);
item = item.set('postId', action.payload.postId);
// items新增item
let newItems = state.items.push(item);
newItems = newItems.push(item);
let nextState = state.set('sid', sid)
.set('items', newItems);
.set('items', newItems)
.set('cleaned', false);
return nextState;
}
... ... @@ -69,7 +80,8 @@ export default function likeList(state = initialState, action) {
if (state.items.size > sid) {
let items = state.items.pop();
let nextState = state.set('sid', sid - 1)
.set('items', items);
.set('items', items)
.set('cleaned', true);
return nextState;
}
}
... ...
... ... @@ -2,6 +2,7 @@ import { ActionConst } from 'react-native-router-flux';
const initialState = {
scene: {},
lastPopScene: '',
};
export default function reducer(state = initialState, action = {}) {
... ... @@ -13,6 +14,12 @@ export default function reducer(state = initialState, action = {}) {
scene: action.scene,
};
case ActionConst.BACK_ACTION:
return {
...state,
lastPopScene: state.scene.sceneKey,
};
// ...other actions
default:
... ...
... ... @@ -54,6 +54,7 @@ let InitialState = Record({
sid: -1,
items: List(),
item: item,
cleaned: false,
});
export default InitialState;
... ...
... ... @@ -10,7 +10,7 @@
* InitialState
*/
import InitialState from './sectionInitialState';
import Immutable, {Map} from 'immutable';
import Immutable, {Map, List} from 'immutable';
const {
SECTION_HEADER_REQUEST,
... ... @@ -46,16 +46,27 @@ export default function sectionReducer(state = initialState, action) {
switch (action.type) {
case GO_TO_SECTION: {
let sid = state.sid + 1;
let currentSid = state.sid;
let newItems = state.items;
let newSid = currentSid;
// componentWillUnmount未调用,导致clean操作未进行
if (action.payload.tryToClean && currentSid > -1 && !state.cleaned) {
newItems = newItems.pop();
newSid = newSid - 1;
}
let sid = newSid + 1;
// 获取新的初始状态item
let item = initialState.item;
// 设置item的value
item = item.set('id', action.payload.id)
.set('name', action.payload.name);
// items新增item
let newItems = state.items.push(item);
let items = newItems.push(item);
let nextState = state.set('sid', sid)
.set('items', newItems);
.set('items', items)
.set('cleaned', false);
return nextState;
}
... ... @@ -172,7 +183,8 @@ export default function sectionReducer(state = initialState, action) {
if (state.items.size > sid) {
let items = state.items.pop();
let nextState = state.set('sid', sid - 1)
.set('items', items);
.set('items', items)
.set('cleaned', true);
return nextState;
}
}
... ...
... ... @@ -68,6 +68,7 @@ let InitialState = Record({
sid: -1,
items: List(),
item: item,
cleaned: false,
});
export default InitialState;
... ...
... ... @@ -56,17 +56,27 @@ export default function postingReducer(state = initialState, action) {
switch (action.type) {
case GO_TO_POST: {
let sid = state.sid + 1;
let currentSid = state.sid;
let newItems = state.items;
let newSid = currentSid;
// componentWillUnmount未调用,导致clean操作未进行
if (action.payload.tryToClean && currentSid > -1 && !state.cleaned) {
newItems = newItems.pop();
newSid = newSid - 1;
}
let sid = newSid + 1;
// 获取新的初始状态item
let item = initialState.item;
// 设置item的value
item = item.set('id', action.payload);
item = item.set('id', action.payload.id);
// items新增item
let newItems = state.items.push(item);
newItems = newItems.push(item);
let nextState = state.set('sid', sid)
.set('items', newItems);
.set('items', newItems)
.set('cleaned', false);
return nextState;
// return state.set('id', action.payload);
}
case SUBJECT_CONTENT_REQUEST: {
... ... @@ -287,7 +297,8 @@ export default function postingReducer(state = initialState, action) {
if (state.items.size > sid) {
let items = state.items.pop();
let nextState = state.set('sid', sid - 1)
.set('items', items);
.set('items', items)
.set('cleaned', true);
return nextState;
}
}
... ...
... ... @@ -32,6 +32,7 @@ let InitialState = Record({
sid: -1,
items: List(),
item: item,
cleaned: false,
});
export default InitialState;
... ...
... ... @@ -28,15 +28,26 @@ export default function userThatNotMe(state = initialState, action) {
switch (action.type) {
case GO_TO_USER_THAT_NOT_ME: {
let sid = state.sid + 1;
let currentSid = state.sid;
let newItems = state.items;
let newSid = currentSid;
// componentWillUnmount未调用,导致clean操作未进行
if (action.payload.tryToClean && currentSid > -1 && !state.cleaned) {
newItems = newItems.pop();
newSid = newSid - 1;
}
let sid = newSid + 1;
// 获取新的初始状态item
let item = initialState.item;
// 设置item的value
item = item.setIn(['profile', 'uid'], action.payload);
item = item.setIn(['profile', 'uid'], action.payload.uid);
// items新增item
let newItems = state.items.push(item);
newItems = newItems.push(item);
let nextState = state.set('sid', sid)
.set('items', newItems);
.set('items', newItems)
.set('cleaned', false);
return nextState;
}
... ... @@ -106,7 +117,8 @@ export default function userThatNotMe(state = initialState, action) {
if (state.items.size > sid) {
let items = state.items.pop();
let nextState = state.set('sid', sid - 1)
.set('items', items);
.set('items', items)
.set('cleaned', true);
return nextState;
}
}
... ...