Application Android et IOS pour l'amicale des élèves
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VoteWait.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // @flow
  2. import * as React from 'react';
  3. import {
  4. ActivityIndicator,
  5. Card,
  6. Paragraph,
  7. withTheme,
  8. } from 'react-native-paper';
  9. import {StyleSheet} from 'react-native';
  10. import i18n from 'i18n-js';
  11. import type {CustomThemeType} from '../../../managers/ThemeManager';
  12. type PropsType = {
  13. startDate: string | null,
  14. justVoted: boolean,
  15. hasVoted: boolean,
  16. isVoteRunning: boolean,
  17. theme: CustomThemeType,
  18. };
  19. const styles = StyleSheet.create({
  20. card: {
  21. margin: 10,
  22. },
  23. icon: {
  24. backgroundColor: 'transparent',
  25. },
  26. });
  27. class VoteWait extends React.Component<PropsType> {
  28. shouldComponentUpdate(): boolean {
  29. return false;
  30. }
  31. render(): React.Node {
  32. const {props} = this;
  33. const {startDate} = props;
  34. return (
  35. <Card style={styles.card}>
  36. <Card.Title
  37. title={
  38. props.isVoteRunning
  39. ? i18n.t('screens.vote.wait.titleSubmitted')
  40. : i18n.t('screens.vote.wait.titleEnded')
  41. }
  42. subtitle={i18n.t('screens.vote.wait.subtitle')}
  43. left={({size}: {size: number}): React.Node => (
  44. <ActivityIndicator size={size} />
  45. )}
  46. />
  47. <Card.Content>
  48. {props.justVoted ? (
  49. <Paragraph style={{color: props.theme.colors.success}}>
  50. {i18n.t('screens.vote.wait.messageSubmitted')}
  51. </Paragraph>
  52. ) : null}
  53. {props.hasVoted ? (
  54. <Paragraph style={{color: props.theme.colors.success}}>
  55. {i18n.t('screens.vote.wait.messageVoted')}
  56. </Paragraph>
  57. ) : null}
  58. {startDate != null ? (
  59. <Paragraph>
  60. {`${i18n.t('screens.vote.wait.messageDate')} ${startDate}`}
  61. </Paragraph>
  62. ) : (
  63. <Paragraph>
  64. {i18n.t('screens.vote.wait.messageDateUndefined')}
  65. </Paragraph>
  66. )}
  67. </Card.Content>
  68. </Card>
  69. );
  70. }
  71. }
  72. export default withTheme(VoteWait);