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

56 lines
1.2 KiB
TypeScript
Raw Normal View History

2021-04-10 13:28:57 +00:00
import React from 'react';
2021-11-07 10:11:51 +00:00
import Config from 'react-native-config';
import buildURL from 'utils/buildURL';
2021-04-10 13:28:57 +00:00
import { Linking, StyleSheet } from 'react-native';
import { ActionSheet, Icon, NativeBase } from 'native-base';
2021-04-10 13:28:57 +00:00
const OPTIONS = ['Strona internetowa', 'Kontakt', 'Anuluj'];
enum OptionIndex {
WEBSITE,
CONTACT,
CANCEL,
}
export type MenuProps = Omit<NativeBase.Icon, 'onPress' | 'type' | 'name'>;
2021-04-10 13:28:57 +00:00
const Menu = ({ style, ...rest }: MenuProps) => {
const showMenu = () => {
ActionSheet.show(
{
options: OPTIONS,
cancelButtonIndex: OptionIndex.CANCEL,
2021-04-10 13:28:57 +00:00
},
index => {
switch (index) {
case OptionIndex.WEBSITE:
2021-11-07 10:11:51 +00:00
Linking.openURL(Config.WEBSITE);
2021-04-10 13:28:57 +00:00
break;
case OptionIndex.CONTACT:
2021-11-07 10:11:51 +00:00
Linking.openURL(buildURL('email', Config.CONTACT_EMAIL));
2021-04-10 13:28:57 +00:00
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;