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.tsx 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2019 - 2020 Arnaud Vergnet.
  3. *
  4. * This file is part of Campus INSAT.
  5. *
  6. * Campus INSAT is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Campus INSAT is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Campus INSAT. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. import * as React from 'react';
  20. import {View} from 'react-native';
  21. import {useTheme} from 'react-native-paper';
  22. import {Agenda, AgendaProps} from 'react-native-calendars';
  23. type PropsType = {
  24. onRef: (ref: Agenda<any>) => void;
  25. } & AgendaProps<any>;
  26. /**
  27. * Abstraction layer for Agenda component, using custom configuration
  28. */
  29. function CustomAgenda(props: PropsType) {
  30. const theme = useTheme();
  31. function getAgenda() {
  32. return (
  33. <Agenda
  34. {...props}
  35. ref={props.onRef}
  36. theme={{
  37. backgroundColor: theme.colors.agendaBackgroundColor,
  38. calendarBackground: theme.colors.background,
  39. textSectionTitleColor: theme.colors.agendaDayTextColor,
  40. selectedDayBackgroundColor: theme.colors.primary,
  41. selectedDayTextColor: '#ffffff',
  42. todayTextColor: theme.colors.primary,
  43. dayTextColor: theme.colors.text,
  44. textDisabledColor: theme.colors.agendaDayTextColor,
  45. dotColor: theme.colors.primary,
  46. selectedDotColor: '#ffffff',
  47. arrowColor: 'orange',
  48. monthTextColor: theme.colors.primary,
  49. indicatorColor: theme.colors.primary,
  50. textDayFontWeight: '300',
  51. textMonthFontWeight: 'bold',
  52. textDayHeaderFontWeight: '300',
  53. textDayFontSize: 16,
  54. textMonthFontSize: 16,
  55. textDayHeaderFontSize: 16,
  56. agendaDayTextColor: theme.colors.agendaDayTextColor,
  57. agendaDayNumColor: theme.colors.agendaDayTextColor,
  58. agendaTodayColor: theme.colors.primary,
  59. agendaKnobColor: theme.colors.primary,
  60. }}
  61. />
  62. );
  63. }
  64. // Completely recreate the component on theme change to force theme reload
  65. if (theme.dark) {
  66. return <View style={{flex: 1}}>{getAgenda()}</View>;
  67. }
  68. return getAgenda();
  69. }
  70. export default CustomAgenda;