Skip to content

Commit

Permalink
Use Swipeout library to mark items done
Browse files Browse the repository at this point in the history
  • Loading branch information
mgyucht committed Oct 9, 2016
1 parent f0f1802 commit e2fc6fb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ npm-debug.log

node_modules/**/*
.exponent/**/*

org/org_parser.js
20 changes: 16 additions & 4 deletions OrgView.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { SideMenu, List, ListItem } from 'react-native-elements'
import React, { Component } from 'react';

import Menu, { MenuOptions, MenuOption, MenuTrigger } from 'react-native-menu';
import Swipeout from 'react-native-swipeout';


import {
Expand Down Expand Up @@ -398,7 +399,7 @@ function Children({ node }) {
</View>);
}

function TodoRender({ root, searchStr }) {
function TodoRender({ root, searchStr, swipeDone }) {
filtered = Org.search(root, searchStr);
sorted = Org.sort(filtered, 'pl', (a, b) => {
let as = a ? a.get('SCHEDULED') : null;
Expand Down Expand Up @@ -455,22 +456,33 @@ function TodoRender({ root, searchStr }) {
<ListView
dataSource={cloned}
renderRow={(node) => {
const swipeoutButtons = [
{
text: 'Done',
backgroundColor: 'green',
underlayColor: 'rgba(0, 0, 0, 1, 0.6)',
onPress: () => {swipeDone(node);},
},
];
if (node == null) {
return <Text>No search result</Text>
}
return <View>
return <View>
<Swipeout right={swipeoutButtons} autoClose={true}>
<View style={[styles.row]}>
<Keyword keyword={getKeyword(node)}/>
<Text> {Org.getContent(node)} </Text>
</View>
{dates(node)}
</View>}}
</Swipeout>
</View>}}
renderSeparator={(sectionID, rowID) => (<View key={`${sectionID}-${rowID}`} style={styles.separator} />)}
/>
);
}

TodoRender = connect((state) => ({ root: state.doc }))(TodoRender);
TodoRender = connect((state) => ({ root: state.doc }),
(dispatch) => ({swipeDone: (node) => dispatch(setProperty(node, ['meta', 'keyword'], 'DONE'))}))(TodoRender);

/*** Edit node view ***/

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"@exponent/ex-navigation": "^1.5.29",
"@exponent/samples": "^1.0.2",
"@exponent/vector-icons": "^1.0.4",
"babel-preset-es2015": "^6.16.0",
"babel-preset-es2015-node": "^6.1.1",
"babel-preset-react": "^6.16.0",
"babel-preset-react-native-stage-0": "^1.0.1",
"exponent": "^9.0.2",
"lodash": "^4.13.1",
Expand Down

0 comments on commit e2fc6fb

Please sign in to comment.