import React from 'react'
import { Text, StyleSheet, TextStyle, StyleProp } from 'react-native'

import { colors } from '../Colors'
import { TextStyles } from '../Styles'
import { formatCountShortSeparate } from '../util'

const styles = StyleSheet.create({
  number: {
    ...TextStyles.body,
    color: colors.midWhite,
    textTransform: 'uppercase',
    paddingStart: 5,
    marginBottom: 2,
  },
})

interface Props {
  number: number
  style?: StyleProp<TextStyle>
}

export function Number({ number, style }: Props): React.ReactElement<Props> {
  const { number: num, postfix } = formatCountShortSeparate(number)

  return (
    <Text style={[styles.number, style]}>
      {num}
      {postfix}
    </Text>
  )
}
