Merge remote-tracking branch 'origin/master'

This commit is contained in:
mx1700 2019-07-15 22:11:27 +08:00
commit da7ff8050a
16 changed files with 120 additions and 34 deletions

View file

@ -114,7 +114,7 @@ const localStyle = StyleSheet.create({
moreIcon: {
position: 'absolute',
bottom: 0,
right: 10,
right: 15,
paddingHorizontal: 12,
paddingVertical: 5
}

View file

@ -89,6 +89,8 @@ export default class DiaryBrief extends Component {
<Photo uri={diary.photoThumbUrl} onPress={this.props.onPhotoPress}></Photo>
<View style={localStyle.actionBar}>
<View style={{flex: 1}} />
<View style={localStyle.icons}>
<DiaryIconComment count={diary.comment_count}></DiaryIconComment>
<DiaryIconOkB diaryId={diary.id}
@ -98,7 +100,7 @@ export default class DiaryBrief extends Component {
refreshBack={this.refreshDiary.bind(this)}
></DiaryIconOkB>
</View>
<View style={{flex: 1}} />
{
isMine && !expired
? <TouchableOpacity onPress={this.onDiaryAction.bind(this)}>
@ -134,7 +136,8 @@ const localStyle = StyleSheet.create({
title: {
flexDirection: "row",
alignItems: "flex-end",
paddingBottom: 5
paddingBottom: 5,
paddingRight: 9
},
titleName: {
fontWeight: 'bold',
@ -164,7 +167,7 @@ const localStyle = StyleSheet.create({
flexDirection: 'row'
},
moreIcon: {
paddingVertical: 5,
paddingHorizontal: 5
marginLeft: 7,
marginRight: 13
}
});

View file

@ -157,7 +157,7 @@ const localStyle = StyleSheet.create({
title: {
flexDirection: "row",
alignItems: "flex-end",
paddingRight: 10,
paddingRight: 9,
paddingBottom: 5
},
titleName: {

View file

@ -29,9 +29,11 @@ export default class DiaryIconComment extends Component {
const localStyle = StyleSheet.create({
wrap: {
flexDirection: 'row',
marginRight: 6
marginRight: 6,
marginTop: -1
},
icon: {
color: Color.inactiveText,
marginLeft: 2,
marginRight: 4
},

View file

@ -101,8 +101,8 @@ const localStyle = StyleSheet.create({
icon: {
width: 18,
height: 18,
marginLeft: 2,
marginRight: 4
marginLeft: 4,
marginRight: 1
},
text: {
fontSize: 15

View file

@ -53,6 +53,15 @@ export default class DiaryList extends Component {
}
scrollToTop() {
if(!this.scrollY) {
this.scrollY = 0;
}
if(this.scrollY <= 10) {
this.refresh();
return;
}
this.list.scrollToOffset({
offset: 0
});
@ -263,6 +272,10 @@ export default class DiaryList extends Component {
onEndReachedThreshold={2}
onEndReached={this.state.hasMore ? this.loadMore.bind(this) : null}
onScroll={(event) => {
this.scrollY = event.nativeEvent.contentOffset.y;
}}
>
</FlatList>

View file

@ -86,10 +86,10 @@ export default class NotebookDiaryList extends Component {
}
refreshOne(index, diary) {
console.log('index, diary:', index, diary);
if(diary) {
let list = this.state.rawlist;
diary.user = list[index].user;
list[index] = diary;
this.setState({
@ -188,8 +188,18 @@ export default class NotebookDiaryList extends Component {
diary: diary,
showField: ['createdTime'],
expired: this.notebook.isExpired,
refreshBack: this.refreshOne.bind(this, index)
expired: this.notebook.isExpired
}
}
});
}
_onPhotoPress(photoUrl) {
Navigation.push(this.props.componentId, {
component: {
name: 'Photo',
passProps: {
url: photoUrl
}
}
});
@ -215,13 +225,14 @@ export default class NotebookDiaryList extends Component {
renderItem={(rowData) => {
return (
<DiaryBrief
<DiaryBrief {...this.props}
diary={rowData.item}
showField={['createdTime']}
expired={expired}
isMine={isMine}
onDiaryPress={this._onDiaryPress.bind(this, rowData.index)}
onPhotoPress={() => this._onPhotoPress(rowData.item.photoUrl)}
refreshBack={this.refreshOne.bind(this, rowData.index)}
>

View file

@ -12,6 +12,12 @@ export default class UserIcon extends Component {
};
}
static getDerivedStateFromProps(nextProps, prevState) {
return {
iconUrl: nextProps.iconUrl
};
}
_defaultOnPress() {
// empty
}

View file

@ -30,7 +30,7 @@ function getTodayStr() {
let month = now.getMonth() + 1;
let date = now.getDate();
return year + '-' + (month > 9 ? month : '0' + month) + '-' + date;
return year + '-' + (month > 9 ? month : '0' + month) + '-' + (date > 9 ? date : '0' + date);
}
export default class DiaryDetailPage extends Component {

View file

@ -52,10 +52,20 @@ export default class FollowPage extends Component {
});
}
componentDidMount() {
this.bottomTabEventListener = Navigation.events().registerBottomTabSelectedListener(
({ selectedTabIndex, unselectedTabIndex }) => {
if(selectedTabIndex == unselectedTabIndex && selectedTabIndex == 1) {
this.diaryList.scrollToTop();
}
}
);
}
render() {
return (
<View style={localStyle.wrap}>
<DiaryList ref={(r) => this.list = r}
<DiaryList ref={(r) => this.diaryList = r}
dataSource={this.dataSource}
{...this.props}

View file

@ -119,7 +119,10 @@ export default class HomePage extends Component {
}
},
bottomTabs: {
visible: true
visible: true,
drawBehind: false,
animate: false
}
});

View file

@ -147,8 +147,10 @@ export default class NotificationPage extends Component {
}
refresh() {
if(this.list) {
this.list.refresh(false);
}
}
_onDeletePress(msg) {
this._setRead(msg).done();

View file

@ -114,6 +114,14 @@ export default class SettingPage extends Component {
Alert.alert('提示','确认退出登录?',[
{text: '退出', style: 'destructive', onPress: () => {
Api.logout();
/*
* clear ActionSheet instance
*/
if(global.__action_sheet) {
global.__action_sheet = null;
}
Navigation.setRoot({
root: {
stack: {

View file

@ -30,7 +30,7 @@ export default class UserPage extends Component {
this.dataSource = new UserDiaryData(this.userId);
this.state = {
index: 1,
index: this.user ? 0 : 1,
routes: [
{ key: 'userIntro', title: '简介' },
{ key: 'diary', title: '日记' },

View file

@ -100,6 +100,7 @@ export default class WritePage extends Component {
componentDidMount() {
this.loadNotebook();
this.contentInput.focus();
this.notebookListener = DeviceEventEmitter.addListener(Event.updateNotebooks, (param) => {
this.loadNotebook(true);
@ -111,6 +112,7 @@ export default class WritePage extends Component {
}
openModal() {
this.contentInput.blur();
this.setState({modalVisible: true});
if(this.state.notebooks.length == 0) {
@ -120,15 +122,14 @@ export default class WritePage extends Component {
}
}
closeModal(showKeyboard = true) {
this.contentInput.blur();
closeModal(showKeyboard = true, callback) {
Animated.parallel([
Animated.timing(
this.state.fadeAnimOpacity,
{
toValue: 0,
duration: 350,
easing: Easing.out(Easing.cubic)
easing: Easing.out(Easing.linear)
}
),
Animated.timing(
@ -136,27 +137,36 @@ export default class WritePage extends Component {
{
toValue: 0,
duration: 350,
easing: Easing.out(Easing.cubic)
easing: Easing.out(Easing.linear)
}
)
]).start(({finished}) => {
this.setState({modalVisible: false});
if(!finished) {
return;
}
this.setState({modalVisible: false}, () => {
setTimeout(() => {
if(showKeyboard) {
setTimeout(() => this.contentInput.focus(), 100);
this.contentInput.focus()
} else {
if(typeof callback == 'function') {
callback();
}
}
}, 100);
});
});
}
_onCreateNotebook() {
this.closeModal(false);
this.closeModal(false, () => {
Navigation.push(this.props.componentId, {
component: {
name: 'NotebookEdit'
}
});
});
}
_onNotebookSelected(notebook) {
@ -241,13 +251,25 @@ export default class WritePage extends Component {
}
saveDiary() {
if(!this.state.content) {
return;
}
let photoUri = this.state.photoUri;
let topic = this.props.topic ? 1 : 0;
let waitingToast = Msg.showMsg('正在保存中', {
duration: 10000,
position: -75,
shadow: false,
hideOnPress: false
});
(this.diary
? Api.updateDiary(this.diary.id, this.state.targetbookId, this.state.content)
: Api.addDiary(this.state.targetbookId, this.state.content, photoUri, topic)
).then(result => {
Msg.hideMsg(waitingToast);
Msg.showMsg('日记保存完成');
DeviceEventEmitter.emit(Event.updateDiarys);
@ -271,6 +293,7 @@ export default class WritePage extends Component {
}
})
.catch(e => {
Msg.hideMsg(waitingToast);
Msg.showMsg('保存失败');
})
.done();

View file

@ -14,9 +14,14 @@ function showMsg(msg, option) {
}
}
Toast.show(msg, option);
return Toast.show(msg, option);
}
function hideMsg(toast) {
Toast.hide(toast);
}
export default {
showMsg
showMsg,
hideMsg
}