mirror of
https://github.com/timepill/timepill-app.git
synced 2025-04-30 09:59:31 +08:00
1. 提醒历史列表初步成形
This commit is contained in:
parent
e5aae879f3
commit
a593225741
6 changed files with 208 additions and 24 deletions
40
src/component/notification/notification.js
Normal file
40
src/component/notification/notification.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
import React, {Component} from 'react';
|
||||||
|
import {StyleSheet, Text, View} from 'react-native';
|
||||||
|
import Ionicons from 'react-native-vector-icons/Ionicons';
|
||||||
|
|
||||||
|
import Touchable from '../touchable';
|
||||||
|
import Color from '../../style/color'
|
||||||
|
|
||||||
|
|
||||||
|
export default class Notification extends Component {
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Touchable onPress={() => {}}>
|
||||||
|
<View style={localStyle.container}>
|
||||||
|
<Ionicons name="ios-text" size={16}
|
||||||
|
style={localStyle.icon} color={Color.light} />
|
||||||
|
<Text style={localStyle.text}>{'XXX 回复了你|关注了你'}</Text>
|
||||||
|
</View>
|
||||||
|
</Touchable>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const localStyle = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
padding: 20,
|
||||||
|
borderColor: Color.line,
|
||||||
|
borderBottomWidth: StyleSheet.hairlineWidth,
|
||||||
|
flexDirection: 'row'
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
marginRight: 10,
|
||||||
|
marginTop: 1,
|
||||||
|
lineHeight: 20
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
flex: 1,
|
||||||
|
lineHeight: 20
|
||||||
|
}
|
||||||
|
});
|
66
src/component/notification/notificationList.js
Normal file
66
src/component/notification/notificationList.js
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
import React, {Component} from 'react';
|
||||||
|
import {StyleSheet, Text, View, FlatList, InteractionManager} from 'react-native';
|
||||||
|
|
||||||
|
import Api from '../../util/api';
|
||||||
|
import Notification from './notification';
|
||||||
|
|
||||||
|
|
||||||
|
export default class NotificationList extends Component {
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
notifications: [],
|
||||||
|
refreshing: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount(){
|
||||||
|
InteractionManager.runAfterInteractions(() => {
|
||||||
|
this.refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh() {
|
||||||
|
this.setState({refreshing: true});
|
||||||
|
Api.getMessagesHistory()
|
||||||
|
.then(notifications => {
|
||||||
|
console.log('notifications:', notifications);
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
notifications
|
||||||
|
});
|
||||||
|
|
||||||
|
}).done(() => {
|
||||||
|
this.setState({refreshing: false});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
let hasData = this.state.notifications && this.state.notifications.length > 0;
|
||||||
|
return hasData ? (
|
||||||
|
<FlatList
|
||||||
|
data={this.state.notifications}
|
||||||
|
|
||||||
|
keyExtractor={(item, index) => {
|
||||||
|
return item.id ? item.id.toString() : index
|
||||||
|
}}
|
||||||
|
|
||||||
|
renderItem={({item}) => {
|
||||||
|
return (
|
||||||
|
<Notification></Notification>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
|
||||||
|
refreshing={this.state.refreshing}
|
||||||
|
onRefresh={this.refresh.bind(this)}
|
||||||
|
|
||||||
|
/>
|
||||||
|
) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const localStyle = StyleSheet.create({
|
||||||
|
|
||||||
|
});
|
41
src/page/NotificationHistoryPage.js
Normal file
41
src/page/NotificationHistoryPage.js
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
import React, {Component} from 'react';
|
||||||
|
import {Platform, StyleSheet, Text, View} from 'react-native';
|
||||||
|
import {Navigation} from 'react-native-navigation';
|
||||||
|
|
||||||
|
import Color from '../style/color';
|
||||||
|
import {Icon} from '../style/icon';
|
||||||
|
|
||||||
|
import NotificationList from '../component/notification/notificationList';
|
||||||
|
|
||||||
|
|
||||||
|
export default class NotificationHistoryPage extends Component {
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
Navigation.events().bindComponent(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
static options(passProps) {
|
||||||
|
return {
|
||||||
|
topBar: {
|
||||||
|
title: {
|
||||||
|
text: '提醒历史'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<View style={localStyle.container}>
|
||||||
|
<NotificationList></NotificationList>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const localStyle = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1
|
||||||
|
}
|
||||||
|
});
|
|
@ -1,33 +1,62 @@
|
||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import {Platform, StyleSheet, Text, View} from 'react-native';
|
import {Platform, StyleSheet, Text, View} from 'react-native';
|
||||||
|
import {Button} from 'react-native-elements'
|
||||||
|
import {Navigation} from 'react-native-navigation';
|
||||||
|
|
||||||
|
import Color from '../style/color'
|
||||||
|
import {Icon} from '../style/icon'
|
||||||
|
|
||||||
|
|
||||||
export default class NotifyPage extends Component {
|
export default class NotificationPage extends Component {
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
Navigation.events().bindComponent(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
static options(passProps) {
|
||||||
|
return {
|
||||||
|
topBar: {
|
||||||
|
title: {
|
||||||
|
text: '提醒'
|
||||||
|
},
|
||||||
|
rightButtons: [{
|
||||||
|
id: 'history',
|
||||||
|
icon: Icon.navButtonTime,
|
||||||
|
|
||||||
|
color: '#aaa' // android
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
navigationButtonPressed({buttonId}) {
|
||||||
|
Navigation.push(this.props.componentId, {
|
||||||
|
component: {
|
||||||
|
name: 'NotificationHistory'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={localStyle.container}>
|
||||||
<Text style={styles.welcome}>Notify Page !</Text>
|
<Text style={localStyle.text}>没有内容</Text>
|
||||||
</View>
|
<Button fontSize={14} borderRadius={999} backgroundColor={Color.primary}
|
||||||
|
title={'刷新'} onPress={() => {}} />
|
||||||
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const localStyle = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
alignItems:'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
height: '100%'
|
||||||
backgroundColor: '#F5FCFF',
|
},
|
||||||
},
|
text: {
|
||||||
welcome: {
|
paddingBottom: 15,
|
||||||
fontSize: 20,
|
color: Color.text
|
||||||
textAlign: 'center',
|
}
|
||||||
margin: 10,
|
|
||||||
},
|
|
||||||
instructions: {
|
|
||||||
textAlign: 'center',
|
|
||||||
color: '#333333',
|
|
||||||
marginBottom: 5,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ Follow: require("./FollowPage.js").default,
|
||||||
FollowUser: require("./FollowUserPage.js").default,
|
FollowUser: require("./FollowUserPage.js").default,
|
||||||
Home: require("./HomePage.js").default,
|
Home: require("./HomePage.js").default,
|
||||||
NotebookDetail: require("./NotebookDetailPage.js").default,
|
NotebookDetail: require("./NotebookDetailPage.js").default,
|
||||||
|
NotificationHistory: require("./NotificationHistoryPage.js").default,
|
||||||
Notification: require("./NotificationPage.js").default,
|
Notification: require("./NotificationPage.js").default,
|
||||||
User: require("./UserPage.js").default,
|
User: require("./UserPage.js").default,
|
||||||
Write: require("./WritePage.js").default
|
Write: require("./WritePage.js").default
|
||||||
|
|
|
@ -92,13 +92,18 @@ async function getNotebookDiaries(id, page, page_size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getSelfInfoByStore() {
|
async function getSelfInfoByStore() {
|
||||||
return await TokenManager.getUserInfo();
|
return await TokenManager.getUserInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUserTodayDiaries(userId) {
|
async function getUserTodayDiaries(userId) {
|
||||||
return call('GET', '/users/' + userId + '/diaries/')
|
return call('GET', '/users/' + userId + '/diaries/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getMessagesHistory() {
|
||||||
|
return call('GET', '/tip/history');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function call(method, api, body, _timeout = 10000) {
|
async function call(method, api, body, _timeout = 10000) {
|
||||||
let token = await TokenManager.getUserToken();
|
let token = await TokenManager.getUserToken();
|
||||||
|
@ -197,5 +202,7 @@ export default {
|
||||||
getSelfNotebooks,
|
getSelfNotebooks,
|
||||||
|
|
||||||
getRelationUsers,
|
getRelationUsers,
|
||||||
getRelationReverseUsers
|
getRelationReverseUsers,
|
||||||
|
|
||||||
|
getMessagesHistory
|
||||||
}
|
}
|
Loading…
Reference in a new issue