Skip to content

Commit bca8cbc

Browse files
committed
Add platform specific menu
1 parent ce31538 commit bca8cbc

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

components/NoteList.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class NoteList extends Component {
1212
onNavigateNote: PropTypes.func
1313
}
1414

15-
removeNote = noteId => {
15+
onRemoveNote = noteId => {
1616
Alert.alert(
1717
'Remove Note',
1818
'Do you want to remove note ?',
@@ -25,7 +25,7 @@ export class NoteList extends Component {
2525

2626
renderDeleteButton = ({ item }) => (
2727
<View style={{ flex: 1, alignItems: 'flex-end' }}>
28-
<RemoveButton onPress={() => this.removeNote(item.id)} />
28+
<RemoveButton onPress={() => this.onRemoveNote(item.id)} />
2929
</View>
3030
)
3131

components/NoteListItem.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,21 @@ export class NoteListItem extends Component {
6767
}
6868
}
6969

70-
onOpenMenu = () => {
70+
showActionSheet = options => {
71+
ActionSheetIOS.showActionSheetWithOptions(options, this.onPressMenu)
72+
}
73+
74+
showPopupMenu = options => {
7175
const button = findNodeHandle(this._buttonRef)
76+
UIManager.showPopupMenu(button, options, (e) => console.error(e), (e, i) => this.onPressMenu(i))
77+
}
78+
79+
onOpenMenu = () => {
7280
const options = [ 'Edit', 'Delete' ]
7381

7482
Platform.select({
75-
ios: ActionSheetIOS.showActionSheetWithOptions(options, this.onPressMenu),
76-
android: UIManager.showPopupMenu(button, options, (e) => console.error(e), (e, i) => this.onPressMenu(i))
83+
ios: this.showActionSheet(options),
84+
android: this.showPopupMenu(options)
7785
})
7886
}
7987

containers/Projects.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { connect } from 'react-redux'
55
import { bindActionCreators } from 'redux'
66
import { actions } from '../redux/actions'
77

8-
export class Projects extends Component {
8+
export class Projects extends PureComponent {
99
static navigationOptions = ({ navigation }) => ({
1010
headerRight: (
1111
<AddButton onPress={navigation.getParam('onRightButtonPress')} />

0 commit comments

Comments
 (0)