Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Delete file
Browse files Browse the repository at this point in the history
  • Loading branch information
whs committed May 5, 2016
1 parent 5426ba5 commit 61f7ae4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This project is from mobile software development class.
- [x] Find background image

### Final presentation
- [ ] Files CRUD
- [x] Files CRUD
- [ ] Slide layout
- [ ] Corners
- [x] Add slide
Expand Down
22 changes: 20 additions & 2 deletions components/FileList/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import React, {
TouchableNativeFeedback,
RecyclerViewBackedScrollView,
Image,
Platform
Platform,
Alert
} from 'react-native';
import NavBar, { NavButton, NavTitle, NavGroup } from 'react-native-nav'
import { ListView } from 'realm/react-native';
Expand Down Expand Up @@ -88,7 +89,7 @@ export default class FileList extends Component {

_renderRow = (rowData, sectionID, rowID) => {
return (
<TouchableFeedback onPress={this._onRowPress(rowData)}>
<TouchableFeedback onPress={this._onRowPress(rowData)} onLongPress={this._onLongPress(rowData)}>
<View style={styles.row}>
<Text style={styles.text}>{rowData.name}</Text>
</View>
Expand All @@ -102,6 +103,23 @@ export default class FileList extends Component {
};
};

_onLongPress = (data) => {
return () => {
Alert.alert(
'Delete',
`Delete ${data.name}?\nThis action cannot be undone.`,
[
{text: 'Cancel', style: 'cancel'},
{text: 'OK', onPress: () => {
Realm.write(() => {
Realm.delete(data);
});
}},
]
);
};
};

addSlide(name){
if(!name){
return;
Expand Down

0 comments on commit 61f7ae4

Please sign in to comment.