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.

EquipmentConfirmScreen.js 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // @flow
  2. import * as React from 'react';
  3. import {Button, Caption, Card, Headline, Paragraph, withTheme} from 'react-native-paper';
  4. import {Collapsible} from "react-navigation-collapsible";
  5. import {withCollapsible} from "../../../utils/withCollapsible";
  6. import {StackNavigationProp} from "@react-navigation/stack";
  7. import type {CustomTheme} from "../../../managers/ThemeManager";
  8. import type {Device} from "./EquipmentListScreen";
  9. import {Animated, View} from "react-native";
  10. import i18n from "i18n-js";
  11. import {getRelativeDateString} from "../../../utils/EquipmentBooking";
  12. type Props = {
  13. navigation: StackNavigationProp,
  14. route: {
  15. params?: {
  16. item?: Device,
  17. dates: [string, string]
  18. },
  19. },
  20. theme: CustomTheme,
  21. collapsibleStack: Collapsible,
  22. }
  23. class EquipmentConfirmScreen extends React.Component<Props> {
  24. item: Device | null;
  25. dates: [string, string] | null;
  26. constructor(props: Props) {
  27. super(props);
  28. if (this.props.route.params != null) {
  29. if (this.props.route.params.item != null)
  30. this.item = this.props.route.params.item;
  31. else
  32. this.item = null;
  33. if (this.props.route.params.dates != null)
  34. this.dates = this.props.route.params.dates;
  35. else
  36. this.dates = null;
  37. }
  38. }
  39. render() {
  40. const {containerPaddingTop, scrollIndicatorInsetTop, onScroll} = this.props.collapsibleStack;
  41. const item = this.item;
  42. const dates = this.dates;
  43. if (item != null && dates != null) {
  44. const start = new Date(dates[0]);
  45. const end = new Date(dates[1]);
  46. return (
  47. <Animated.ScrollView
  48. // Animations
  49. onScroll={onScroll}
  50. contentContainerStyle={{
  51. paddingTop: containerPaddingTop,
  52. minHeight: '100%'
  53. }}
  54. scrollIndicatorInsets={{top: scrollIndicatorInsetTop}}>
  55. <Card style={{margin: 5}}>
  56. <Card.Content>
  57. <View style={{flex: 1}}>
  58. <View style={{
  59. marginLeft: "auto",
  60. marginRight: "auto",
  61. flexDirection: "row",
  62. flexWrap: "wrap",
  63. }}>
  64. <Headline style={{textAlign: "center"}}>
  65. {item.name}
  66. </Headline>
  67. <Caption style={{
  68. textAlign: "center",
  69. lineHeight: 35,
  70. marginLeft: 10,
  71. }}>
  72. ({i18n.t('screens.equipment.bail', {cost: item.caution})})
  73. </Caption>
  74. </View>
  75. </View>
  76. <Button
  77. icon={"check-circle-outline"}
  78. color={this.props.theme.colors.success}
  79. mode="text"
  80. >
  81. {
  82. start == null
  83. ? i18n.t('screens.equipment.booking')
  84. : end != null && start.getTime() !== end.getTime()
  85. ? i18n.t('screens.equipment.bookingPeriod', {
  86. begin: getRelativeDateString(start),
  87. end: getRelativeDateString(end)
  88. })
  89. : i18n.t('screens.equipment.bookingDay', {
  90. date: getRelativeDateString(start)
  91. })
  92. }
  93. </Button>
  94. <Paragraph style={{textAlign: "center"}}>
  95. {i18n.t("screens.equipment.bookingConfirmedMessage")}
  96. </Paragraph>
  97. </Card.Content>
  98. </Card>
  99. </Animated.ScrollView>
  100. );
  101. } else
  102. return null;
  103. }
  104. }
  105. export default withCollapsible(withTheme(EquipmentConfirmScreen));