diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml
index 319eb0c..cbf0e22 100644
--- a/android/app/src/main/res/values/styles.xml
+++ b/android/app/src/main/res/values/styles.xml
@@ -5,4 +5,14 @@
+
+
+
+
diff --git a/package-lock.json b/package-lock.json
index 57ee70f..63cbfdf 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10821,6 +10821,14 @@
"resolved": "http://registry.npm.taobao.org/react-native-actionsheet-api/download/react-native-actionsheet-api-1.0.4.tgz",
"integrity": "sha1-AGJeOeRdy8KnERKB/xUDl+5ZUbI="
},
+ "react-native-datepicker": {
+ "version": "1.7.2",
+ "resolved": "https://registry.npm.taobao.org/react-native-datepicker/download/react-native-datepicker-1.7.2.tgz",
+ "integrity": "sha1-WNCCJZGgrJsyq6CCZQIioO4pZp0=",
+ "requires": {
+ "moment": "^2.22.0"
+ }
+ },
"react-native-device-info": {
"version": "1.6.1",
"resolved": "https://registry.npm.taobao.org/react-native-device-info/download/react-native-device-info-1.6.1.tgz",
diff --git a/package.json b/package.json
index 4b07cec..a8cadf7 100644
--- a/package.json
+++ b/package.json
@@ -13,6 +13,7 @@
"react": "16.8.3",
"react-native": "0.59.5",
"react-native-actionsheet-api": "^1.0.4",
+ "react-native-datepicker": "^1.7.2",
"react-native-device-info": "^1.6.1",
"react-native-elements": "^0.19.0",
"react-native-iphone-x-helper": "^1.0.2",
diff --git a/src/component/dateInput.js b/src/component/dateInput.js
new file mode 100644
index 0000000..e556885
--- /dev/null
+++ b/src/component/dateInput.js
@@ -0,0 +1,82 @@
+import React, {Component} from 'react';
+import {StyleSheet, Text, View, InteractionManager} from 'react-native';
+import {Navigation} from 'react-native-navigation';
+import DatePicker from 'react-native-datepicker'
+
+
+function now() {
+ const d = new Date();
+ const localTime = d.getTime();
+ const localOffset = d.getTimezoneOffset() * 60000;
+ const utc = localTime + localOffset;
+ const offset = 8; //东 8 区
+ const beijingTime = utc + (3600000 * offset);
+
+ return new Date(beijingTime);
+}
+
+export default class DateInput extends Component {
+
+ constructor(props) {
+ super(props);
+
+ this.updateDate();
+ this.state = {
+ date: this.formatDate(this.nowDate)
+ };
+ }
+
+ componentDidMount() {
+ InteractionManager.runAfterInteractions(() => {
+ this.updateDate();
+ });
+ }
+
+ updateDate() {
+ this.nowDate = now();
+ let nowMSec = this.nowDate.getTime();
+
+ let minExpiredMSec = 7 * 24 * 3600000; // at least 7 days to expire
+ let minExpiredDate = new Date(nowMSec + minExpiredMSec);
+ this.minDate = this.formatDate(minExpiredDate);
+
+ let maxExpiredMSec = 3650 * 24 * 3600000; // at most 10 years to expire
+ let maxExpireDate = new Date(nowMSec + maxExpiredMSec);
+ this.maxDate = this.formatDate(maxExpireDate);
+ }
+
+ formatDate(date) {
+ let year = date.getFullYear();
+ let month = date.getMonth() + 1;
+ let day = date.getDate();
+
+ return year + '-' + month + '-' + day;
+ }
+
+ getDate() {
+ return this.state.date;
+ }
+
+ render() {
+ return (
+ {
+ this.setState({date: date})
+ }}
+
+ androidMode={'spinner'}
+ />
+ );
+ }
+}
diff --git a/src/component/notebook/notebookAdd.js b/src/component/notebook/notebookAdd.js
new file mode 100644
index 0000000..d7a9fd2
--- /dev/null
+++ b/src/component/notebook/notebookAdd.js
@@ -0,0 +1,44 @@
+import React, {Component} from 'react';
+import {View, StyleSheet, Text, TouchableOpacity} from 'react-native';
+import Ionicons from 'react-native-vector-icons/Ionicons';
+
+import Color from '../../style/color'
+
+
+export default class NotebookAdd extends Component {
+
+ _defaultOnPress() {
+
+ }
+
+ render() {
+ return (
+
+
+
+
+
+ );
+ }
+}
+
+const localStyle = StyleSheet.create({
+ box: {
+ flex: 1,
+ width: 140,
+ shadowColor: '#444',
+ shadowOpacity: 0.1,
+ shadowOffset: {
+ width: 0,
+ height: 0
+ },
+ elevation: 1,
+ backgroundColor: "#eee",
+ alignItems: 'center',
+ justifyContent: 'center',
+ margin: 3,
+ marginBottom: 15
+ }
+});
\ No newline at end of file
diff --git a/src/component/notebook/notebookList.js b/src/component/notebook/notebookList.js
index 3b46860..c538a29 100644
--- a/src/component/notebook/notebookList.js
+++ b/src/component/notebook/notebookList.js
@@ -12,6 +12,7 @@ import {Navigation} from 'react-native-navigation';
import Api from '../../util/api';
import Notebook from './notebook'
+import NotebookAdd from './notebookAdd'
export default class NotebookList extends Component {
@@ -59,6 +60,17 @@ export default class NotebookList extends Component {
return groups;
}
+ _onAddPress() {
+ Navigation.push(this.props.componentId, {
+ component: {
+ name: 'NotebookAdd',
+ passProps: {
+
+ }
+ }
+ });
+ }
+
_onNotebookPress(notebook) {
Navigation.push(this.props.componentId, {
component: {
@@ -85,6 +97,10 @@ export default class NotebookList extends Component {
let user = this.state.user;
(user ? Api.getUserNotebooks(user.id) : Api.getSelfNotebooks())
.then(notebooks => {
+ if(!user) {
+ notebooks.unshift({id: 'new'});
+ }
+
let groups = this.createGroup(notebooks, this.itemsPerRow);
this.setState({
notebooks: groups
@@ -95,6 +111,16 @@ export default class NotebookList extends Component {
});
}
+ _renderAdd() {
+ return ( this._onAddPress()}>
+ );
+ }
+
+ _renderPlaceHolder() {
+ return ;
+ }
+
_renderItem(notebook) {
return notebook ? (
{
- return item[0].id.toString()
+ return item[0].id.toString();
}}
renderItem={({item}) => {
let row = item.map((notebook) => {
+ if(!notebook) {
+ return this._renderPlaceHolder();
+
+ } else if(notebook.id == 'new') {
+ return this._renderAdd();
+ }
+
return this._renderItem(notebook);
});
diff --git a/src/page/NotebookAddPage.js b/src/page/NotebookAddPage.js
new file mode 100644
index 0000000..e3e6473
--- /dev/null
+++ b/src/page/NotebookAddPage.js
@@ -0,0 +1,153 @@
+import React, {Component} from 'react';
+import {StyleSheet, Text, View, ScrollView, Switch, TextInput, TouchableOpacity} from 'react-native';
+import {Navigation} from 'react-native-navigation';
+
+import Color from '../style/color';
+import {Icon} from '../style/icon';
+import Api from '../util/api';
+
+import DateInput from '../component/dateInput'
+
+
+export default class NotebookAddPage extends Component {
+
+ constructor(props) {
+ super(props);
+ Navigation.events().bindComponent(this);
+
+ this.state = {
+ notebook: props.notebook,
+
+ subject: '',
+ isPublic: false,
+ dateString: ''
+ }
+ }
+
+ static options(passProps) {
+ return {
+ topBar: {
+ title: {
+ text: '创建日记本'
+ },
+ rightButtons: [{
+ id: 'save',
+ icon: Icon.navButtonSave
+ }]
+ },
+ bottomTabs: {
+ visible: false,
+
+ // hide bottom tab for android
+ drawBehind: true,
+ animate: true
+ }
+ };
+ }
+
+ navigationButtonPressed({buttonId}) {
+ console.log('date string:', this.dateInput.getDate());
+ }
+
+ render() {
+ return (
+
+
+
+
+ this.setState({subject: text})}
+ />
+
+
+
+
+
+ {this.dateInput = r}}
+ style={localStyle.datePickerStyle}
+ customStyles={customDatePickerStyle}>
+
+
+
+
+
+
+ 公开日记本
+ this.setState({isPublic: v})}
+ trackColor={Api.IS_ANDROID ? Color.textSelect : null}
+ thumbColor={Api.IS_ANDROID && this.state.isPublic ? Color.light : null}
+ />
+
+
+
+
+
+ );
+ }
+}
+
+const localStyle = StyleSheet.create({
+ wrap: {
+ flex: 1,
+ backgroundColor: '#EFEFF4'
+ },
+ group: {
+ marginTop: 30,
+ backgroundColor: 'white',
+ borderTopWidth: StyleSheet.hairlineWidth,
+ borderBottomWidth: StyleSheet.hairlineWidth,
+ borderColor: '#c8c7cc'
+ },
+ item: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ paddingHorizontal: 15,
+ height: 45
+ },
+ subject: {
+ flex: 1,
+ fontSize: 16,
+ height: '100%',
+ padding: 0
+ },
+ title: {
+ fontSize: 16,
+ color: '#222'
+ },
+ line: {
+ marginLeft: 15,
+ borderBottomWidth: StyleSheet.hairlineWidth,
+ borderColor: '#c8c7cc'
+ },
+ datePickerStyle: {
+ flex: 1,
+ padding: 0,
+ height: '100%',
+ justifyContent: 'center'
+ }
+});
+
+const customDatePickerStyle = StyleSheet.create({
+ dateInput: {
+ height: 45,
+ alignItems: 'flex-start',
+ borderWidth: 0
+ },
+ placeholderText: {
+ fontSize: 16
+ },
+ dateText: {
+ fontSize: 16
+ }
+});
+
+
diff --git a/src/page/_list.js b/src/page/_list.js
index 40162b7..c524a54 100644
--- a/src/page/_list.js
+++ b/src/page/_list.js
@@ -3,6 +3,7 @@ DiaryDetail: require("./DiaryDetailPage.js").default,
Follow: require("./FollowPage.js").default,
FollowUser: require("./FollowUserPage.js").default,
Home: require("./HomePage.js").default,
+NotebookAdd: require("./NotebookAddPage.js").default,
NotebookDetail: require("./NotebookDetailPage.js").default,
NotificationHistory: require("./NotificationHistoryPage.js").default,
Notification: require("./NotificationPage.js").default,