@livelike/react-native
Version:
LiveLike React Native package
65 lines • 1.91 kB
JavaScript
import React from 'react';
import { ActivityIndicator, ScrollView, StyleSheet, View } from 'react-native';
import { useStyles, useTheme } from '../../hooks';
import { LLPickerEmptyComponent } from './LLPickerEmptyComponent';
export function LLBasePicker(_ref) {
let {
visible,
loading,
packItems,
styles: stylesProp,
EmptyPickerComponent = LLPickerEmptyComponent,
PickerItemComponent,
PickerHeaderComponent
} = _ref;
const {
theme
} = useTheme();
const pickerStyles = useStyles({
componentStylesFn: getPickerStyles,
stylesProp
});
if (!visible) {
return null;
}
return /*#__PURE__*/React.createElement(View, {
style: pickerStyles.pickerContainer
}, PickerHeaderComponent && PickerHeaderComponent(), loading ? /*#__PURE__*/React.createElement(ActivityIndicator, {
size: 'large',
color: theme.text,
style: pickerStyles.pickerLoadingIndicator
}) : /*#__PURE__*/React.createElement(ScrollView, {
style: pickerStyles.pickerItemsScrollview,
keyboardShouldPersistTaps: 'always'
}, /*#__PURE__*/React.createElement(View, {
style: pickerStyles.pickerItemContainer
}, !packItems || packItems.length === 0 ? /*#__PURE__*/React.createElement(EmptyPickerComponent, null) : packItems.map(item => /*#__PURE__*/React.createElement(PickerItemComponent, {
key: item.id,
item: item
})))));
}
const getPickerStyles = _ref2 => {
let {
theme
} = _ref2;
return StyleSheet.create({
pickerContainer: {
minHeight: 300,
maxHeight: 300,
backgroundColor: theme.secondaryBackground
},
pickerItemsScrollview: {
paddingTop: 10
},
pickerItemContainer: {
position: 'relative',
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-evenly'
},
pickerLoadingIndicator: {
flex: 1
}
});
};
//# sourceMappingURL=LLBasePicker.js.map