index.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import React, { FC, ReactNode } from 'react';
  2. import { Text, TouchableOpacity, View } from 'react-native';
  3. import { NavigationProp, useNavigation } from '@react-navigation/native';
  4. import { styles } from './styles';
  5. import { Header, PageWrapper } from '../../../../components';
  6. import { NAVIGATION_PAGES } from '../../../../types';
  7. import { Colors } from '../../../../theme';
  8. import UserPenIcon from '../../../../../assets/icons/user-pen.svg';
  9. import UserPlusIcon from '../../../../../assets/icons/user-plus.svg';
  10. import BellIcon from '../../../../../assets/icons/bell.svg';
  11. import MailIcon from '../../../../../assets/icons/mail.svg';
  12. import FAQIcon from '../../../../../assets/icons/faq.svg';
  13. import DocumentIcon from '../../../../../assets/icons/document.svg';
  14. import ShieldIcon from '../../../../../assets/icons/shield.svg';
  15. import ExitIcon from '../../../../../assets/icons/exit.svg';
  16. import UserXMark from '../../../../../assets/icons/user-xmark.svg';
  17. import ArrowRightIcon from '../../../../../assets/icons/right-arrow.svg';
  18. type ButtonType = {
  19. label: string;
  20. icon: ReactNode;
  21. red?: boolean;
  22. buttonFn?: (navigationHook: NavigationProp<ReactNavigation.RootParamList>) => void;
  23. };
  24. const buttons: ButtonType[] = [
  25. {
  26. label: 'Edit Profile',
  27. icon: <UserPenIcon fill={Colors.DARK_BLUE} width={20} height={20} />,
  28. buttonFn: (navigation) => {
  29. navigation.navigate(NAVIGATION_PAGES.EDIT_PERSONAL_INFO);
  30. }
  31. },
  32. {
  33. label: 'Invite a Friend',
  34. icon: <UserPlusIcon fill={Colors.DARK_BLUE} width={20} height={20} />
  35. },
  36. {
  37. label: 'Notification',
  38. icon: <BellIcon fill={Colors.DARK_BLUE} width={20} height={20} />
  39. },
  40. {
  41. label: 'Contact Us',
  42. icon: <MailIcon fill={Colors.DARK_BLUE} width={20} height={20} />
  43. },
  44. {
  45. label: 'FAQs',
  46. icon: <FAQIcon fill={Colors.DARK_BLUE} width={20} height={20} />
  47. },
  48. {
  49. label: 'Terms & Conditions',
  50. icon: <DocumentIcon fill={Colors.DARK_BLUE} width={20} height={20} />
  51. },
  52. {
  53. label: 'Privacy Notice',
  54. icon: <ShieldIcon fill={Colors.DARK_BLUE} width={20} height={20} />
  55. },
  56. {
  57. label: 'Logout',
  58. icon: <ExitIcon fill={Colors.RED} width={20} height={20} />,
  59. red: true
  60. },
  61. {
  62. label: 'Delete account',
  63. icon: <UserXMark fill={Colors.RED} width={20} height={20} />,
  64. red: true
  65. }
  66. ];
  67. const Settings = () => {
  68. return (
  69. <PageWrapper>
  70. <Header label={'Settings'} />
  71. {buttons.map((button) => (
  72. <SettingsButton
  73. label={button.label}
  74. icon={button.icon}
  75. red={button.red}
  76. buttonFn={button.buttonFn}
  77. />
  78. ))}
  79. </PageWrapper>
  80. );
  81. };
  82. type ButtonProps = {
  83. label: string;
  84. icon: ReactNode;
  85. buttonFn?: (navigate: NavigationProp<ReactNavigation.RootParamList>) => void;
  86. red?: boolean;
  87. };
  88. const SettingsButton: FC<ButtonProps> = ({ label, icon, buttonFn, red }) => {
  89. const navigation = useNavigation();
  90. return (
  91. <TouchableOpacity
  92. style={[styles.alignStyle, styles.buttonWrapper, { justifyContent: 'space-between' }]}
  93. onPress={() => (buttonFn ? buttonFn(navigation) : null)}
  94. >
  95. <View style={styles.alignStyle}>
  96. {icon}
  97. <Text style={[styles.buttonLabel, red ? { color: Colors.RED } : null]}>{label}</Text>
  98. </View>
  99. <View>
  100. <ArrowRightIcon fill={red ? Colors.RED : Colors.LIGHT_GRAY} width={20} height={20} />
  101. </View>
  102. </TouchableOpacity>
  103. );
  104. };
  105. export default Settings;