2021-09-13 20:41:05 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { StyleSheet, Text, View } from 'react-native';
|
|
|
|
|
2022-06-27 21:27:22 +00:00
|
|
|
import { useTheme } from '../../theme';
|
2021-09-13 20:41:05 +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-25 17:20:09 +00:00
|
|
|
children: React.ReactElement | null;
|
2021-09-13 20:41:05 +00:00
|
|
|
bulletWidth: number;
|
|
|
|
level: number;
|
|
|
|
ordered: boolean;
|
|
|
|
continue: boolean;
|
|
|
|
index: number;
|
2022-06-27 21:27:22 +00:00
|
|
|
testID: string;
|
2021-09-13 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
2022-06-27 21:27:22 +00:00
|
|
|
const ListItem = React.memo(({ children, level, bulletWidth, continue: _continue, ordered, index, testID }: IListItem) => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
let bullet;
|
|
|
|
if (_continue) {
|
|
|
|
bullet = '';
|
|
|
|
} else if (ordered) {
|
|
|
|
bullet = `${index}.`;
|
|
|
|
} else if (level % 2 === 0) {
|
|
|
|
bullet = '◦';
|
|
|
|
} else {
|
|
|
|
bullet = '•';
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2022-06-27 21:27:22 +00:00
|
|
|
<View style={style.container} testID={`${testID}-list`}>
|
2021-09-13 20:41:05 +00:00
|
|
|
<View style={[{ width: bulletWidth }, style.bullet]}>
|
2022-06-27 21:27:22 +00:00
|
|
|
<Text style={{ color: colors.bodyText }}>{bullet}</Text>
|
2021-09-13 20:41:05 +00:00
|
|
|
</View>
|
|
|
|
<View style={style.contents}>{children}</View>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
export default ListItem;
|