2021-10-01 18:12:19 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { StyleSheet, Text, View } from 'react-native';
|
|
|
|
|
2022-04-28 18:44:40 +00:00
|
|
|
import { TSupportedThemes } from '../../theme';
|
|
|
|
import { themes } from '../../lib/constants';
|
2021-10-01 18:12:19 +00:00
|
|
|
|
|
|
|
const style = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'flex-start'
|
|
|
|
},
|
|
|
|
bullet: {
|
|
|
|
alignItems: 'flex-end',
|
|
|
|
marginRight: 5
|
|
|
|
},
|
|
|
|
contents: {
|
|
|
|
flex: 1
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
interface IListItem {
|
2022-03-29 18:53:27 +00:00
|
|
|
children: React.ReactElement | null;
|
2021-10-01 18:12:19 +00:00
|
|
|
bulletWidth: number;
|
|
|
|
level: number;
|
|
|
|
ordered: boolean;
|
|
|
|
continue: boolean;
|
2022-04-28 18:44:40 +00:00
|
|
|
theme: TSupportedThemes;
|
2021-10-01 18:12:19 +00:00
|
|
|
index: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ListItem = React.memo(({ children, level, bulletWidth, continue: _continue, ordered, index, theme }: IListItem) => {
|
|
|
|
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]}>
|
|
|
|
<Text style={{ color: themes[theme].bodyText }}>{bullet}</Text>
|
|
|
|
</View>
|
|
|
|
<View style={style.contents}>{children}</View>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
export default ListItem;
|