Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

TimeElapsed.tsx 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import React, { PureComponent } from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. import { Text } from 'react-native';
  4. import { translate } from '../../../base/i18n/functions';
  5. import { createLocalizedTime } from '../timeFunctions';
  6. /**
  7. * The type of the React {@code Component} props of {@link TimeElapsed}.
  8. */
  9. interface IProps extends WithTranslation {
  10. /**
  11. * Style for text.
  12. */
  13. style: Object;
  14. /**
  15. * The milliseconds to be converted into a human-readable format.
  16. */
  17. time: number;
  18. }
  19. /**
  20. * React component for displaying total time elapsed. Converts a total count of
  21. * milliseconds into a more humanized form: "# hours, # minutes, # seconds".
  22. * With a time of 0, "0s" will be displayed.
  23. *
  24. * @augments Component
  25. */
  26. class TimeElapsed extends PureComponent<IProps> {
  27. /**
  28. * Implements React's {@link Component#render()}.
  29. *
  30. * @inheritdoc
  31. * @returns {ReactElement}
  32. */
  33. render() {
  34. const { style, time, t } = this.props;
  35. const timeElapsed = createLocalizedTime(time, t);
  36. return (
  37. <Text style = { style }>
  38. { timeElapsed }
  39. </Text>
  40. );
  41. }
  42. }
  43. export default translate(TimeElapsed);