2019-09-03 19:27:57 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import {
|
|
|
|
StyleSheet,
|
|
|
|
Text,
|
|
|
|
View
|
|
|
|
} from 'react-native';
|
|
|
|
|
2019-12-11 23:01:12 +00:00
|
|
|
import { themes } from '../../constants/colors';
|
|
|
|
|
2019-09-03 19:27:57 +00:00
|
|
|
const style = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'flex-start'
|
|
|
|
},
|
|
|
|
bullet: {
|
|
|
|
alignItems: 'flex-end',
|
|
|
|
marginRight: 5
|
|
|
|
},
|
|
|
|
contents: {
|
|
|
|
flex: 1
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const ListItem = React.memo(({
|
2019-12-11 23:01:12 +00:00
|
|
|
children, level, bulletWidth, continue: _continue, ordered, index, theme
|
2019-09-03 19:27:57 +00:00
|
|
|
}) => {
|
|
|
|
let bullet;
|
|
|
|
if (_continue) {
|
|
|
|
bullet = '';
|
|
|
|
} else if (ordered) {
|
|
|
|
bullet = `${ index }.`;
|
|
|
|
} else if (level % 2 === 0) {
|
|
|
|
bullet = '◦';
|
|
|
|
} else {
|
|
|
|
bullet = '•';
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View style={style.container}>
|
|
|
|
<View style={[{ width: bulletWidth }, style.bullet]}>
|
2020-01-29 20:20:36 +00:00
|
|
|
<Text style={{ color: themes[theme].bodyText }}>
|
2019-09-03 19:27:57 +00:00
|
|
|
{bullet}
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
<View style={style.contents}>
|
|
|
|
{children}
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
ListItem.propTypes = {
|
|
|
|
children: PropTypes.node,
|
|
|
|
bulletWidth: PropTypes.number,
|
|
|
|
level: PropTypes.number,
|
|
|
|
ordered: PropTypes.bool,
|
|
|
|
continue: PropTypes.bool,
|
2019-12-11 23:01:12 +00:00
|
|
|
theme: PropTypes.string,
|
2019-09-03 19:27:57 +00:00
|
|
|
index: PropTypes.number
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ListItem;
|