This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
mobile-app/src/common/Menu/Menu.tsx

54 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-04-10 13:28:57 +00:00
import React from 'react';
import { EMAIL, WEBSITE } from 'config/app';
import { ActionSheet, Icon, NativeBase } from 'native-base';
import { Linking, StyleSheet } from 'react-native';
export interface MenuProps
extends Omit<NativeBase.Icon, 'onPress' | 'type' | 'name'> {}
const OPTIONS = ['Strona internetowa', 'Kontakt', 'Anuluj'];
const WEBSITE_OPT_INDEX = 0;
const CONTACT_OPT_INDEX = 1;
const CANCEL_OPT_INDEX = OPTIONS.length - 1;
const Menu = ({ style, ...rest }: MenuProps) => {
const showMenu = () => {
ActionSheet.show(
{
options: OPTIONS,
cancelButtonIndex: CANCEL_OPT_INDEX,
},
index => {
switch (index) {
case WEBSITE_OPT_INDEX:
Linking.openURL(WEBSITE);
break;
case CONTACT_OPT_INDEX:
Linking.openURL(`mailto:${EMAIL}`);
break;
}
},
);
};
return (
<Icon
type="Feather"
name="more-vertical"
fontSize={30}
style={[styles.icon, style]}
onPress={showMenu}
{...rest}
/>
);
};
const styles = StyleSheet.create({
icon: {
color: 'white',
},
});
export default Menu;