react-native-ethiopian-calendar
Version:
A react native calendar component which is mainly intended for applications which require Ethiopian calendar.
45 lines • 1.9 kB
JavaScript
import React, { useState } from 'react';
import { Image, Text, TouchableOpacity, View } from 'react-native';
import { getLocalLabel, languageNames } from '../../../utils/locals';
import { makeStyle } from './styles';
export const LocalsDropDown = /*#__PURE__*/React.memo(props => {
const {
theme,
locals,
onLanguageChange
} = props;
const [showDropdown, setShowDropdown] = useState(false);
const styles = makeStyle(theme);
const handleLanguageChange = lang => {
if (onLanguageChange) {
onLanguageChange(lang);
setShowDropdown(false);
}
};
return /*#__PURE__*/React.createElement(View, {
style: styles.container
}, /*#__PURE__*/React.createElement(TouchableOpacity, {
style: styles.dropdownButtonStyle,
onPress: () => setShowDropdown(!showDropdown),
activeOpacity: 0.9
}, /*#__PURE__*/React.createElement(Text, {
style: styles.labelText
}, getLocalLabel(locals)), /*#__PURE__*/React.createElement(Image, {
source: showDropdown ? require('./images/dropdown_up.png') : require('./images/dropdown_down.png'),
style: styles.dropdownIconStyle
})), showDropdown && /*#__PURE__*/React.createElement(View, {
style: styles.dropdownContainer
}, languageNames.map((item, index) => /*#__PURE__*/React.createElement(View, {
key: index,
style: styles.languageButtonContainer
}, /*#__PURE__*/React.createElement(TouchableOpacity, {
style: [styles.languageButton, item.code === locals && styles.languageButtonSelected],
activeOpacity: 0.7,
onPress: () => handleLanguageChange(item.code)
}, /*#__PURE__*/React.createElement(Text, {
style: [styles.languageTextStyle, locals === item.code && styles.languageTextSelected]
}, item.name)), index < languageNames.length - 1 && /*#__PURE__*/React.createElement(View, {
style: styles.dividerStyle
})))));
});
//# sourceMappingURL=LocalsDropdown.js.map