1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-12 08:54:00 +02:00
joplin/ReactNativeClient/lib/components/action-button.js

85 lines
2.0 KiB
JavaScript
Raw Normal View History

2017-05-16 23:05:53 +02:00
import React, { Component } from 'react';
import { StyleSheet } from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons';
import ReactNativeActionButton from 'react-native-action-button';
import { connect } from 'react-redux'
2017-06-24 20:06:28 +02:00
import { Log } from 'lib/log.js'
2017-05-16 23:05:53 +02:00
const styles = StyleSheet.create({
actionButtonIcon: {
fontSize: 20,
height: 22,
color: 'white',
},
});
class ActionButtonComponent extends React.Component {
2017-05-24 22:51:50 +02:00
newTodo_press() {
this.props.dispatch({
type: 'Navigation/NAVIGATE',
routeName: 'Note',
noteId: null,
folderId: this.props.parentFolderId,
itemType: 'todo',
});
}
2017-05-16 23:05:53 +02:00
newNote_press() {
this.props.dispatch({
type: 'Navigation/NAVIGATE',
routeName: 'Note',
noteId: null,
folderId: this.props.parentFolderId,
2017-05-24 22:51:50 +02:00
itemType: 'note',
2017-05-16 23:05:53 +02:00
});
}
newFolder_press() {
this.props.dispatch({
type: 'Navigation/NAVIGATE',
routeName: 'Folder',
folderId: null,
});
}
render() {
2017-07-09 00:57:09 +02:00
let buttons = [];
2017-05-24 22:51:50 +02:00
2017-07-09 00:57:09 +02:00
if (this.props.folders.length) {
buttons.push(
<ReactNativeActionButton.Item key="ab_todo" buttonColor='#9b59b6' title="New todo" onPress={() => { this.newTodo_press() }}>
2017-05-24 22:51:50 +02:00
<Icon name="md-checkbox-outline" style={styles.actionButtonIcon} />
</ReactNativeActionButton.Item>
2017-07-09 00:57:09 +02:00
);
2017-05-24 22:51:50 +02:00
2017-07-09 00:57:09 +02:00
buttons.push(
<ReactNativeActionButton.Item key="ab_note" buttonColor='#9b59b6' title="New note" onPress={() => { this.newNote_press() }}>
2017-05-16 23:05:53 +02:00
<Icon name="md-document" style={styles.actionButtonIcon} />
</ReactNativeActionButton.Item>
2017-07-09 00:57:09 +02:00
);
}
2017-05-24 22:51:50 +02:00
2017-07-09 00:57:09 +02:00
buttons.push(
<ReactNativeActionButton.Item key="ab_folder" buttonColor='#3498db' title="New folder" onPress={() => { this.newFolder_press() }}>
<Icon name="md-folder" style={styles.actionButtonIcon} />
</ReactNativeActionButton.Item>
);
2017-05-24 22:51:50 +02:00
2017-07-09 00:57:09 +02:00
return (
<ReactNativeActionButton buttonColor="rgba(231,76,60,1)">
{ buttons }
2017-05-16 23:05:53 +02:00
</ReactNativeActionButton>
);
}
}
const ActionButton = connect(
(state) => {
2017-07-09 00:57:09 +02:00
return {
folders: state.folders,
};
2017-05-16 23:05:53 +02:00
}
)(ActionButtonComponent)
export { ActionButton };