Skip to content

Commit 3aa26f3

Browse files
committed
add a "delete" button to the components folder
1 parent 8de66df commit 3aa26f3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// @flow
2+
3+
import React from 'react'
4+
import {StyleSheet, Alert} from 'react-native'
5+
import {Cell} from 'react-native-tableview-simple'
6+
import * as c from '../colors'
7+
8+
const deleteStyles = StyleSheet.create({
9+
text: {textAlign: 'center', color: c.red},
10+
})
11+
12+
export const DeleteButtonCell = ({
13+
title,
14+
skipConfirm = false,
15+
onPress,
16+
}: {
17+
title: string,
18+
skipConfirm?: boolean,
19+
onPress?: () => any,
20+
}) => {
21+
const onPressCallback = onPress ? onPress : () => {}
22+
23+
const callback = !skipConfirm
24+
? () =>
25+
Alert.alert(title, 'Are you sure you want to delete this?', [
26+
{text: 'Cancel', onPress: () => {}, style: 'cancel'},
27+
{text: 'Delete', onPress: onPressCallback, style: 'destructive'},
28+
])
29+
: onPressCallback
30+
31+
return (
32+
<Cell title={title} titleTextStyle={deleteStyles.text} onPress={callback} />
33+
)
34+
}

0 commit comments

Comments
 (0)