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.

CustomAgenda.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // @flow
  2. import * as React from 'react';
  3. import {View} from 'react-native';
  4. import {withTheme} from 'react-native-paper';
  5. import {Agenda} from 'react-native-calendars';
  6. import type {CustomTheme} from '../../managers/ThemeManager';
  7. type PropsType = {
  8. theme: CustomTheme,
  9. onRef: (ref: Agenda) => void,
  10. };
  11. /**
  12. * Abstraction layer for Agenda component, using custom configuration
  13. */
  14. class CustomAgenda extends React.Component<PropsType> {
  15. getAgenda(): React.Node {
  16. const {props} = this;
  17. return (
  18. <Agenda
  19. // eslint-disable-next-line react/jsx-props-no-spreading
  20. {...props}
  21. ref={props.onRef}
  22. theme={{
  23. backgroundColor: props.theme.colors.agendaBackgroundColor,
  24. calendarBackground: props.theme.colors.background,
  25. textSectionTitleColor: props.theme.colors.agendaDayTextColor,
  26. selectedDayBackgroundColor: props.theme.colors.primary,
  27. selectedDayTextColor: '#ffffff',
  28. todayTextColor: props.theme.colors.primary,
  29. dayTextColor: props.theme.colors.text,
  30. textDisabledColor: props.theme.colors.agendaDayTextColor,
  31. dotColor: props.theme.colors.primary,
  32. selectedDotColor: '#ffffff',
  33. arrowColor: 'orange',
  34. monthTextColor: props.theme.colors.primary,
  35. indicatorColor: props.theme.colors.primary,
  36. textDayFontWeight: '300',
  37. textMonthFontWeight: 'bold',
  38. textDayHeaderFontWeight: '300',
  39. textDayFontSize: 16,
  40. textMonthFontSize: 16,
  41. textDayHeaderFontSize: 16,
  42. agendaDayTextColor: props.theme.colors.agendaDayTextColor,
  43. agendaDayNumColor: props.theme.colors.agendaDayTextColor,
  44. agendaTodayColor: props.theme.colors.primary,
  45. agendaKnobColor: props.theme.colors.primary,
  46. }}
  47. />
  48. );
  49. }
  50. render(): React.Node {
  51. const {props} = this;
  52. // Completely recreate the component on theme change to force theme reload
  53. if (props.theme.dark)
  54. return <View style={{flex: 1}}>{this.getAgenda()}</View>;
  55. return this.getAgenda();
  56. }
  57. }
  58. export default withTheme(CustomAgenda);