diff --git a/src/component/comment/comment.js b/src/component/comment/comment.js
index 8e0a4e8..89ea4a1 100644
--- a/src/component/comment/comment.js
+++ b/src/component/comment/comment.js
@@ -114,7 +114,7 @@ const localStyle = StyleSheet.create({
moreIcon: {
position: 'absolute',
bottom: 0,
- right: 10,
+ right: 15,
paddingHorizontal: 12,
paddingVertical: 5
}
diff --git a/src/component/diary/diaryBrief.js b/src/component/diary/diaryBrief.js
index 8d78cf1..67a1242 100644
--- a/src/component/diary/diaryBrief.js
+++ b/src/component/diary/diaryBrief.js
@@ -89,6 +89,8 @@ export default class DiaryBrief extends Component {
+
+
-
+
{
isMine && !expired
?
@@ -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
}
});
diff --git a/src/component/diary/diaryFull.js b/src/component/diary/diaryFull.js
index 8f963b0..936b379 100644
--- a/src/component/diary/diaryFull.js
+++ b/src/component/diary/diaryFull.js
@@ -157,7 +157,7 @@ const localStyle = StyleSheet.create({
title: {
flexDirection: "row",
alignItems: "flex-end",
- paddingRight: 10,
+ paddingRight: 9,
paddingBottom: 5
},
titleName: {
diff --git a/src/component/diary/diaryIconComment.js b/src/component/diary/diaryIconComment.js
index e6e02ef..eb8ddd1 100644
--- a/src/component/diary/diaryIconComment.js
+++ b/src/component/diary/diaryIconComment.js
@@ -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
},
diff --git a/src/component/diary/diaryIconOkB.js b/src/component/diary/diaryIconOkB.js
index 5856fc1..4fc3c8e 100644
--- a/src/component/diary/diaryIconOkB.js
+++ b/src/component/diary/diaryIconOkB.js
@@ -101,8 +101,8 @@ const localStyle = StyleSheet.create({
icon: {
width: 18,
height: 18,
- marginLeft: 2,
- marginRight: 4
+ marginLeft: 4,
+ marginRight: 1
},
text: {
fontSize: 15
diff --git a/src/component/diary/diaryList.js b/src/component/diary/diaryList.js
index a73facc..5056830 100644
--- a/src/component/diary/diaryList.js
+++ b/src/component/diary/diaryList.js
@@ -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;
+ }}
>
diff --git a/src/component/notebook/notebookDiaryList.js b/src/component/notebook/notebookDiaryList.js
index 8e2b564..11fe531 100644
--- a/src/component/notebook/notebookDiaryList.js
+++ b/src/component/notebook/notebookDiaryList.js
@@ -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 (
- this._onPhotoPress(rowData.item.photoUrl)}
refreshBack={this.refreshOne.bind(this, rowData.index)}
>
diff --git a/src/component/userIcon.js b/src/component/userIcon.js
index 483bd70..feb6a69 100644
--- a/src/component/userIcon.js
+++ b/src/component/userIcon.js
@@ -8,7 +8,13 @@ export default class UserIcon extends Component {
constructor(props) {
super(props);
this.state = {
- iconUrl : props.iconUrl
+ iconUrl: props.iconUrl
+ };
+ }
+
+ static getDerivedStateFromProps(nextProps, prevState) {
+ return {
+ iconUrl: nextProps.iconUrl
};
}
diff --git a/src/page/DiaryDetailPage.js b/src/page/DiaryDetailPage.js
index 1a0996e..edbcc40 100644
--- a/src/page/DiaryDetailPage.js
+++ b/src/page/DiaryDetailPage.js
@@ -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 {
diff --git a/src/page/FollowPage.js b/src/page/FollowPage.js
index 3827505..494a98e 100644
--- a/src/page/FollowPage.js
+++ b/src/page/FollowPage.js
@@ -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 (
- this.list = r}
+ this.diaryList = r}
dataSource={this.dataSource}
{...this.props}
diff --git a/src/page/HomePage.js b/src/page/HomePage.js
index b8491f1..404b684 100644
--- a/src/page/HomePage.js
+++ b/src/page/HomePage.js
@@ -119,7 +119,10 @@ export default class HomePage extends Component {
}
},
bottomTabs: {
- visible: true
+ visible: true,
+
+ drawBehind: false,
+ animate: false
}
});
diff --git a/src/page/NotificationPage.js b/src/page/NotificationPage.js
index cdf6f65..7cf9be6 100644
--- a/src/page/NotificationPage.js
+++ b/src/page/NotificationPage.js
@@ -147,7 +147,9 @@ export default class NotificationPage extends Component {
}
refresh() {
- this.list.refresh(false);
+ if(this.list) {
+ this.list.refresh(false);
+ }
}
_onDeletePress(msg) {
diff --git a/src/page/SettingPage.js b/src/page/SettingPage.js
index 6f6b47b..2a7adf4 100644
--- a/src/page/SettingPage.js
+++ b/src/page/SettingPage.js
@@ -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: {
diff --git a/src/page/UserPage.js b/src/page/UserPage.js
index 5802557..ac227d9 100644
--- a/src/page/UserPage.js
+++ b/src/page/UserPage.js
@@ -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: '日记' },
diff --git a/src/page/WritePage.js b/src/page/WritePage.js
index 2079b87..cc7fa97 100644
--- a/src/page/WritePage.js
+++ b/src/page/WritePage.js
@@ -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,26 +137,35 @@ 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;
}
- if(showKeyboard) {
- setTimeout(() => this.contentInput.focus(), 100);
- }
+
+ this.setState({modalVisible: false}, () => {
+ setTimeout(() => {
+ if(showKeyboard) {
+ this.contentInput.focus()
+ } else {
+ if(typeof callback == 'function') {
+ callback();
+ }
+ }
+ }, 100);
+ });
});
}
_onCreateNotebook() {
- this.closeModal(false);
- Navigation.push(this.props.componentId, {
- component: {
- name: 'NotebookEdit'
- }
+ this.closeModal(false, () => {
+ Navigation.push(this.props.componentId, {
+ component: {
+ name: 'NotebookEdit'
+ }
+ });
});
}
@@ -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();
diff --git a/src/util/msg.js b/src/util/msg.js
index c6c4b49..846ab66 100644
--- a/src/util/msg.js
+++ b/src/util/msg.js
@@ -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
}
\ No newline at end of file