您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

TimeElapsed.js 1.2KB

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