1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-24 08:12:24 +02:00

removed listmode

This commit is contained in:
Laurent Cozic 2017-05-24 20:18:09 +00:00
parent 276ac0e180
commit 40dca4348f
3 changed files with 3 additions and 42 deletions

View File

@ -20,7 +20,6 @@ const FolderList = connect(
(state) => {
return {
items: state.folders,
listMode: state.listMode,
};
}
)(FolderListComponent)

View File

@ -9,7 +9,6 @@ class ItemListComponent extends Component {
constructor() {
super();
this.previousListMode = 'view';
const ds = new ListView.DataSource({
rowHasChanged: (r1, r2) => { return r1 !== r2; }
});
@ -26,39 +25,14 @@ class ItemListComponent extends Component {
}
componentWillReceiveProps(newProps) {
// When the items have changed, we just pass this to the data source. However,
// when the list mode change, we need to clone the items to make sure the whole
// list is updated (so that the checkbox can be added or removed).
let items = newProps.items;
if (newProps.listMode != this.previousListMode) {
items = newProps.items.slice();
for (let i = 0; i < items.length; i++) {
items[i] = Object.assign({}, items[i]);
}
this.previousListMode = newProps.listMode;
}
// https://stackoverflow.com/questions/38186114/react-native-redux-and-listview
this.setState({
dataSource: this.state.dataSource.cloneWithRows(items),
});
}
setListMode = (mode) => {
this.props.dispatch({
type: 'SET_LIST_MODE',
listMode: mode,
dataSource: this.state.dataSource.cloneWithRows(newProps.items),
});
}
listView_itemPress = (itemId) => {}
listView_itemLongPress = (itemId) => {
this.setListMode('edit');
}
render() {
let renderRow = (item) => {
let onPress = () => {
@ -67,12 +41,10 @@ class ItemListComponent extends Component {
let onLongPress = () => {
this.listView_itemLongPress(item.id);
}
let isEditable = this.props.listMode == 'edit';
return (
<TouchableHighlight onPress={onPress} onLongPress={onLongPress}>
<View>
{ isEditable && <Checkbox label={item.title} ></Checkbox> }
{ !isEditable && <Text>{item.title} [{item.id}]</Text> }
<Text>{item.title} [{item.id}]</Text>
</View>
</TouchableHighlight>
);

View File

@ -31,7 +31,6 @@ let defaultState = {
folders: [],
selectedNoteId: null,
selectedFolderId: null,
listMode: 'view',
user: { email: 'laurent@cozic.net', session: null },
showSideMenu: false,
};
@ -66,8 +65,6 @@ const reducer = (state = defaultState, action) => {
if (currentRouteName == action.routeName) {
// If the current screen is already the requested screen, don't do anything
} else {
action.params = { listMode: 'view' };
const nextStateNav = AppNavigator.router.getStateForAction(action, currentRouteName != 'Loading' ? state.nav : null);
if (nextStateNav) {
newState.nav = nextStateNav;
@ -148,13 +145,6 @@ const reducer = (state = defaultState, action) => {
newState.user = action.user;
break;
case 'SET_LIST_MODE':
newState = Object.assign({}, state);
newState.listMode = action.listMode;
newState.nav = Object.assign({}, state.nav);
break;
case 'SIDE_MENU_TOGGLE':
newState = Object.assign({}, state);
@ -279,7 +269,7 @@ class AppComponent extends React.Component {
defaultState.nav = AppNavigator.router.getStateForAction({
type: 'Navigation/NAVIGATE',
routeName: 'Loading',
params: {listMode: 'view'}
params: {}
});
const mapStateToProps = (state) => {