Source

externalCode/socialGroupSingle.ts

  1. import React from "react";
  2. import {TGroupViewModel, TTranslationFunction} from "./types";
  3. export const API_NAME = "socialGroupSingleApi";
  4. /**
  5. * GroupListTab
  6. */
  7. type GroupListTab = {
  8. icon: number,
  9. label: string,
  10. /**
  11. * Indicates badge value
  12. */
  13. count: number,
  14. /**
  15. * Returns `true` if tab is loading
  16. */
  17. loading: boolean,
  18. /**
  19. * Default function of the tab
  20. */
  21. onPress: Function
  22. };
  23. /**
  24. * GroupActionButton
  25. */
  26. type GroupActionButton = {
  27. icon: number,
  28. label: string,
  29. /**
  30. * Default function of action button
  31. */
  32. doFunction: Function,
  33. /**
  34. * Validation details
  35. */
  36. onPressValidation?: Record<any, any>
  37. };
  38. /**
  39. * TransformGroupActionButtonsCallback
  40. */
  41. type TransformGroupActionButtonsCallback = {
  42. action: Record<any, any>[]
  43. };
  44. /**
  45. * GroupHeaderAvatarProps
  46. */
  47. type GroupHeaderAvatarProps = {
  48. /**
  49. * App global style
  50. */
  51. global: Record<any, any>,
  52. /**
  53. * App colors
  54. */
  55. colors: Record<any, any>,
  56. group: TGroupViewModel,
  57. /**
  58. * Returns `true` if group avatar upload is disabled
  59. */
  60. disableGroupAvatarUpload: boolean
  61. };
  62. /**
  63. * BeforeGroupDetailsComponentProps
  64. */
  65. type BeforeGroupDetailsComponentProps = {
  66. /**
  67. * App global style
  68. */
  69. global: Record<any, any>,
  70. /**
  71. * App colors
  72. */
  73. colors: Record<any, any>,
  74. group: TGroupViewModel
  75. };
  76. /**
  77. * AfterGroupDetailsComponentProps
  78. */
  79. type AfterGroupDetailsComponentProps = {
  80. /**
  81. * App global style
  82. */
  83. global: Record<any, any>,
  84. /**
  85. * App colors
  86. */
  87. colors: Record<any, any>,
  88. group: TGroupViewModel
  89. };
  90. /**
  91. * GroupHeaderButtonsProps
  92. */
  93. type GroupHeaderButtonsProps = {
  94. /**
  95. * Default button component displayed for the group. Ex: "Request to Join", "Member", etc.
  96. */
  97. OldButtonComponent: Function,
  98. /**
  99. * App global style
  100. */
  101. global: Record<any, any>,
  102. /**
  103. * App colors
  104. */
  105. colors: Record<any, any>,
  106. group: TGroupViewModel,
  107. /**
  108. * Details about the currently logged-in user
  109. */
  110. currentUser: Record<any, any>,
  111. t: TTranslationFunction,
  112. /**
  113. * Functions used in group details
  114. */
  115. filteredActions: Record<any, any>[],
  116. /**
  117. * Default function when a link is pressed
  118. */
  119. onLinkPress: Function,
  120. buttonTextColor: string,
  121. buttonStyle: Record<any, any>,
  122. /**
  123. * Default styles
  124. */
  125. styles: Record<any, any>,
  126. /**
  127. * true when user can join Group
  128. */
  129. canJoin: boolean,
  130. /**
  131. * true, if user is admin
  132. */
  133. isAdmin: boolean,
  134. /**
  135. * true, when Group join request is processing
  136. */
  137. joinGroupLoading: boolean,
  138. /**
  139. * true, when Group delete join request is processing
  140. */
  141. deleteJoinLoading: boolean,
  142. /**
  143. * Functions to join a Group
  144. */
  145. joinGroup: Function,
  146. /**
  147. * Functions to delete Group join request
  148. */
  149. deleteJoinRequest: Function
  150. };
  151. /**
  152. * GroupDetailsComponentProps
  153. */
  154. type GroupDetailsComponentProps = {
  155. /**
  156. * App global style
  157. */
  158. global: Record<any, any>,
  159. /**
  160. * App colors
  161. */
  162. colors: Record<any, any>,
  163. group: TGroupViewModel,
  164. t: TTranslationFunction,
  165. /**
  166. * Functions used in group details
  167. */
  168. filteredActions: Record<any, any>[],
  169. /**
  170. * Default function when a link is pressed
  171. */
  172. onLinkPress: Function,
  173. /**
  174. * Group description
  175. */
  176. truncated: Record<any, any>,
  177. /**
  178. * used for controlling the alignment of the view
  179. */
  180. headerStyle: Record<any, any>,
  181. /**
  182. * Styles group details component
  183. */
  184. styles: Record<any, any>,
  185. /**
  186. * Boolean value for controlling Group type text display
  187. */
  188. showGroupType: boolean,
  189. /**
  190. * Boolean value for controlling Group status text display
  191. */
  192. showGroupPrivacy: boolean
  193. };
  194. /**
  195. * AfterGroupProfileHeaderProps
  196. */
  197. type AfterGroupProfileHeaderProps = {
  198. /**
  199. * App global style
  200. */
  201. global: Record<any, any>,
  202. /**
  203. * App colors
  204. */
  205. colors: Record<any, any>,
  206. group: TGroupViewModel
  207. };
  208. /**
  209. * HeaderRightComponentProps
  210. */
  211. type HeaderRightComponentProps = {
  212. styles: Record<any, any>,
  213. t: TTranslationFunction,
  214. group: TGroupViewModel,
  215. /**
  216. * App global style
  217. */
  218. global: Record<any, any>,
  219. /**
  220. * App colors
  221. */
  222. colors: Record<any, any>,
  223. /**
  224. * Handles link press for the HTML component
  225. */
  226. onLinkPress: Function,
  227. /**
  228. * Default icon
  229. */
  230. icon: number,
  231. /**
  232. * Default header color
  233. */
  234. headerColor: string,
  235. /**
  236. * Action buttons to render
  237. */
  238. actionButtons: Record<any, any>[],
  239. /**
  240. * Returns `true` if logged-in user can subscribe to the group
  241. */
  242. canSubscribe: boolean,
  243. /**
  244. * Returns `true` if logged-in user is subscribed to the group
  245. */
  246. isSubscribed: boolean,
  247. /**
  248. * Returns `true` if subscription state is loading
  249. */
  250. subscriptionLoading: boolean,
  251. /**
  252. * Function to toggle user's subscription to the group
  253. */
  254. subscribeToGroup: Function,
  255. /**
  256. * Default font icon name of the header action button
  257. */
  258. fontIconName: string,
  259. /**
  260. * Default font icon weight of the header action button
  261. */
  262. fontIconWeight: number,
  263. /**
  264. * Default font icon name of the subscribe button
  265. */
  266. fontIconSubscribeName: string,
  267. /**
  268. * Default font icon weight of the subscribe button
  269. */
  270. fontIconSubscribeWeight: number,
  271. /**
  272. * Returns `true` if user can create post in group
  273. */
  274. canPost: boolean,
  275. /**
  276. * Function to open Group Activity screen.
  277. */
  278. openCreateActivityScreen: Function
  279. };
  280. /**
  281. * ParentGroupBarProps
  282. */
  283. type ParentGroupBarProps = {
  284. /**
  285. * Default styles
  286. */
  287. styles: Record<any, any>,
  288. /**
  289. * Details of group's parent
  290. */
  291. parentGroup: null | Record<any, any>,
  292. group: TGroupViewModel,
  293. /**
  294. * App global style
  295. */
  296. global: Record<any, any>,
  297. /**
  298. * App colors
  299. */
  300. colors: Record<any, any>,
  301. /**
  302. * Navigate to parent group
  303. */
  304. navigateToParent: Function,
  305. t: TTranslationFunction
  306. };
  307. /**
  308. * GroupTabBadgeProps
  309. */
  310. type GroupTabBadgeProps = {
  311. /**
  312. * Badge details
  313. */
  314. item: Record<any, any>,
  315. /**
  316. * App global style
  317. */
  318. global: Record<any, any>,
  319. /**
  320. * Badge text
  321. */
  322. text: number,
  323. /**
  324. * Default styles
  325. */
  326. styles: Record<any, any>
  327. };
  328. /**
  329. * GroupTabIconProps
  330. */
  331. type GroupTabIconProps = {
  332. /**
  333. * Icon details
  334. */
  335. link: Record<any, any>,
  336. /**
  337. * App global style
  338. */
  339. global: Record<any, any>,
  340. /**
  341. * App colors
  342. */
  343. colors: Record<any, any>
  344. };
  345. /**
  346. * GroupTabArrowComponentProps
  347. */
  348. type GroupTabArrowComponentProps = {
  349. /**
  350. * Icon color
  351. */
  352. tintColor: string,
  353. /**
  354. * Icon resource
  355. */
  356. icon: number,
  357. /**
  358. * Default styles
  359. */
  360. styles: Record<any, any>
  361. };
  362. /**
  363. * GroupTabTitleComponentProps
  364. */
  365. type GroupTabTitleComponentProps = {
  366. /**
  367. * Tab index
  368. */
  369. index: number,
  370. /**
  371. * Default styles
  372. */
  373. styles: Record<any, any>,
  374. /**
  375. * Tab title
  376. */
  377. title: string
  378. };
  379. /**
  380. * GroupSendInvitesTab
  381. */
  382. type GroupSendInvitesTab = {
  383. /**
  384. * Default icon
  385. */
  386. icon: number,
  387. /**
  388. * Default label
  389. */
  390. label: string,
  391. /**
  392. * Default function to execute when tab is pressed
  393. */
  394. onPress: Function
  395. };
  396. /**
  397. * GroupManageTab
  398. */
  399. type GroupManageTab = {
  400. /**
  401. * Default icon
  402. */
  403. icon: number,
  404. /**
  405. * Default label
  406. */
  407. label: string,
  408. /**
  409. * Default function to execute when tab is pressed
  410. */
  411. onPress: Function
  412. };
  413. /**
  414. * @class
  415. * Group Single Screen Hooks.
  416. * Instance name: socialGroupSingleApi
  417. You can customize the Social Group options such as replacing group avatars, adding components before/after the group details, modifying the default group action buttons and much more.
  418. * @example
  419. * externalCodeSetup.socialGroupSingleApi.METHOD_NAME
  420. */
  421. export class SocialGroupSingleApi {
  422. filterTabs = (tabs: GroupListTab[]) => tabs;
  423. /**
  424. * You can use it to modify the tab list on the Groups screen.
  425. * @method
  426. * @param {GroupListTab[]} tabFilter
  427. * @example
  428. * externalCodeSetup.socialGroupSingleApi.setTabFilter(props => {
  429. * const customTab = {
  430. * icon: {fontIconName: 'comment', weight: 200},
  431. * label: "About",
  432. * onPress: () => Alert.alert("This group was created by the admin"),
  433. * count: 0,
  434. * loading: false,
  435. * };
  436. *
  437. * return [...props, customTab];
  438. * });
  439. */
  440. setTabFilter = (tabFilter: (tabs: GroupListTab[]) => GroupListTab[]) => {
  441. this.filterTabs = tabFilter;
  442. };
  443. //@ts-ignore
  444. privateGroupTabIgnoreFilter = tabs => tabs;
  445. /**
  446. * @ignore
  447. * Reason for ignore: privateGroupTabIgnoreFilter is not being used in the app
  448. * Filters the list of items that should not show to non-members if group is private
  449. */
  450. //@ts-ignore
  451. setPrivateGroupTabFilter = filterFunction => {
  452. this.privateGroupTabIgnoreFilter = filterFunction;
  453. };
  454. GroupHeaderAvatar: React.ComponentType<GroupHeaderAvatarProps> | null = null;
  455. /**
  456. * You can use it to replace the group header avatar. For example, you change the default group avatar if the group does not have an avatar.
  457. * @method
  458. * @param {React.ComponentType<GroupHeaderAvatarProps>} GroupHeaderAvatar
  459. * @example <caption> Change default group avatar if group has no avatar </caption>
  460. *
  461. * ...
  462. * import Animated from "react-native-reanimated";
  463. * import AppImage from "@src/components/AppImage";
  464. * import {DEVICE_WIDTH} from "@src/styles/global";
  465. * export const applyCustomCode = externalCodeSetup => {
  466. *
  467. * externalCodeSetup.socialGroupSingleApi.setGroupHeaderAvatar(props => {
  468. * const {global, group} = props;
  469. *
  470. * const avatarSize = Math.min(DEVICE_WIDTH * 0.3, 110);
  471. * let customUri = group.avatar;
  472. *
  473. * if (group.avatar.includes("mystery-group")) {
  474. * customUri = "https://link-to-image.png";
  475. * }
  476. *
  477. * return (
  478. * <Animated.View
  479. * style={[
  480. * {
  481. * marginBottom: 18,
  482. * marginTop: "auto"
  483. * },
  484. * !!group.coverImage && {
  485. * borderRadius: 18,
  486. * backgroundColor: "#fff",
  487. * borderWidth: 3,
  488. * borderColor: "#fff",
  489. * ...global.shadowBelow
  490. * }
  491. * ]}
  492. * >
  493. * <AppImage
  494. * source={{uri: customUri}}
  495. * style={[{width: avatarSize, height: avatarSize, borderRadius: 18}]}
  496. * resizeMode={"contain"}
  497. * />
  498. * </Animated.View>
  499. * );
  500. * });
  501. * }
  502. */
  503. setGroupHeaderAvatar = (
  504. GroupHeaderAvatar: React.ComponentType<GroupHeaderAvatarProps> | null
  505. ) => {
  506. this.GroupHeaderAvatar = GroupHeaderAvatar;
  507. };
  508. customHeaderBackground: string | null = null;
  509. /**
  510. * Replaces a group's cover image
  511. * @method
  512. * @param {String} customHeaderBackground
  513. * @example
  514. * externalCodeSetup.socialGroupSingleApi.setCustomHeaderBackground('https://link-to-image.png')
  515. */
  516. setCustomHeaderBackground = (customHeaderBackground: string | null) => {
  517. this.customHeaderBackground = customHeaderBackground;
  518. };
  519. BeforeDetailsComponent: React.ComponentType<
  520. BeforeGroupDetailsComponentProps
  521. > | null = null;
  522. /**
  523. * You can use it to add a component before the group details such as the title and group description.
  524. * @method
  525. * @param {React.ComponentType<BeforeGroupDetailsComponentProps>} BeforeDetailsComponent
  526. * @example
  527. * externalCodeSetup.socialGroupSingleApi.setBeforeDetailsComponent(
  528. * props =>
  529. * !props.group.isMember ? (
  530. * <Text>
  531. * You are not a member of this group. To see all available items, please
  532. * join the group.
  533. * </Text>
  534. * ) : null
  535. * );
  536. */
  537. setBeforeDetailsComponent = (
  538. BeforeDetailsComponent: React.ComponentType<
  539. BeforeGroupDetailsComponentProps
  540. > | null
  541. ) => {
  542. this.BeforeDetailsComponent = BeforeDetailsComponent;
  543. };
  544. AfterDetailsComponent: React.ComponentType<
  545. AfterGroupDetailsComponentProps
  546. > | null = null;
  547. /**
  548. * You can customize the Social Group options such as replacing group avatars, adding components before/after the group details, modifying the default group action buttons and much more.
  549. * @method
  550. * @param {React.ComponentType<AfterGroupDetailsComponentProps>} AfterDetailsComponent
  551. * @example
  552. * externalCodeSetup.socialGroupSingleApi.setAfterDetailsComponent(props => {
  553. * return (
  554. * <Button
  555. * title="Open this group in a web browser"
  556. * onPress={() => props.group.navigateToWeb()}
  557. * />
  558. * );
  559. * });
  560. */
  561. setAfterDetailsComponent = (
  562. AfterDetailsComponent: React.ComponentType<
  563. AfterGroupDetailsComponentProps
  564. > | null
  565. ) => {
  566. this.AfterDetailsComponent = AfterDetailsComponent;
  567. };
  568. GroupDetailsComponent: React.ComponentType<
  569. GroupDetailsComponentProps
  570. > | null = null;
  571. /**
  572. * Replaces the group details component and lets you compose your own component to display the group details.
  573. * @method
  574. * @param {React.ComponentType<GroupDetailsComponentProps>} GroupDetailsComponent
  575. * @example
  576. *
  577. * //In custom_code/GroupDetailsComponent.js...
  578. *
  579. * import React from "react";
  580. * import {View, Text, Animated} from "react-native";
  581. * import HTML from "react-native-render-html";
  582. * import htmlclean from "htmlclean";
  583. * import {groupMembersCountTranslation, groupStatusTranslation} from "@src/utils"; //BuddyBoss translation helper functions
  584. * import GroupActionSheetWrapper from "@src/components/Group/GroupActionSheetWrapper";
  585. *
  586. * const GroupDetailsComponent = ({
  587. * global,
  588. * colors,
  589. * group,
  590. * truncated,
  591. * textStyle,
  592. * t,
  593. * filteredActions,
  594. * onLinkPress,
  595. * styles
  596. * }) => (
  597. * <>
  598. * <Text
  599. * numberOfLines={1}
  600. * style={[global.textHeaderTitle, styles.textHeaderTitle, textStyle]}
  601. * >
  602. * {group.title}
  603. * </Text>
  604. * <Animated.View style={[global.screenMetas, styles.groupStatusContainer]}>
  605. * <Text style={[global.textHeaderMeta, styles.groupStatusText, textStyle]}>
  606. * {groupStatusTranslation(t, group)} •{" "}
  607. * {groupMembersCountTranslation(t, group)}
  608. * </Text>
  609. * </Animated.View>
  610. * {!!group.shortContent && (
  611. * <Animated.View style={{maxWidth: 300}}>
  612. * <GroupActionSheetWrapper
  613. * actionButtons={filteredActions}
  614. * {...{
  615. * global,
  616. * colors,
  617. * t,
  618. * group,
  619. * onLinkPress
  620. * }}
  621. * >
  622. * <View>
  623. * <HTML
  624. * html={htmlclean(truncated.html)}
  625. * tagsStyles={{
  626. * p: {marginTop: 0},
  627. * a: global.textHeaderShortContent
  628. * }}
  629. * baseFontStyle={{
  630. * ...global.textHeaderShortContent,
  631. * ...textStyle
  632. * }}
  633. * onLinkPress={(event, url) => {
  634. * if (onLinkPress) {
  635. * onLinkPress(event, url);
  636. * }
  637. * }}
  638. * />
  639. * </View>
  640. * </GroupActionSheetWrapper>
  641. * </Animated.View>
  642. * )}
  643. * </>
  644. * );
  645. *
  646. * export default GroupDetailsComponent;
  647. *
  648. *
  649. * //In custom_code/index.js...
  650. *
  651. * ...
  652. *
  653. * import GroupDetailsComponent from "./GroupDetailsComponent";
  654. * export const applyCustomCode = externalCodeSetup => {
  655. * externalCodeSetup.socialGroupSingleApi.setGroupDetailsComponent(props => <GroupDetailsComponent {...props} />);
  656. * }
  657. */
  658. setGroupDetailsComponent = (
  659. GroupDetailsComponent: React.ComponentType<
  660. GroupDetailsComponentProps
  661. > | null
  662. ) => {
  663. this.GroupDetailsComponent = GroupDetailsComponent;
  664. };
  665. GroupHeaderButtons: React.ComponentType<
  666. GroupHeaderButtonsProps
  667. > | null = null;
  668. /**
  669. * You can add new components near the default group button section.
  670. * @method
  671. * @param {React.ComponentType<GroupHeaderButtonsProps>} GroupHeaderButtons
  672. * @example <caption> Add buttons that can open the group in a web browser </caption>
  673. * externalCodeSetup.socialGroupSingleApi.setGroupHeaderButtons(props => {
  674. *
  675. * const {OldButtonComponent, group} = props;
  676. *
  677. * const goToForum = () => {
  678. * if (typeof group.navigateToForum === 'function'){
  679. * group.navigateToForum()
  680. * }
  681. * }
  682. *
  683. * const NavigateToForum = () => (
  684. * <TouchableOpacity onPress={() => goToForum()}>
  685. * <Text> Go to forum </Text>
  686. * </TouchableOpacity>
  687. * );
  688. *
  689. * const OpenInWeb = () => (
  690. * <TouchableOpacity onPress={() => group.navigateToWeb()}>
  691. * <Text> Open in browser </Text>
  692. * </TouchableOpacity>
  693. * );
  694. *
  695. * return (
  696. * <View style={{flexDirection: "column"}}>
  697. * <NavigateToForum />
  698. * <OpenInWeb />
  699. * <OldButtonComponent />
  700. * </View>
  701. * );
  702. *
  703. * });
  704. *
  705. * @example <caption> Default component structure </caption>
  706. *
  707. * //In custom_code/GroupHeaderButton.js...
  708. *
  709. * import React from "react";
  710. * import GroupActionSheetWrapper from "@src/components/Group/GroupActionSheetWrapper";
  711. * import AvatarActionButton from "@src/components/ActionButtons/AvatarActionButton";
  712. * import AuthWrapper from "@src/components/AuthWrapper";
  713. * import ActionButtonList from "@src/components/ActionButtons/ActionButtonList";
  714. *
  715. * const GroupHeaderButton = ({group, currentUser, global, colors, t, onLinkPress, filteredActions, buttonTextColor, buttonStyle}) => {
  716. *
  717. * return group.isMember ? (
  718. * <GroupActionSheetWrapper
  719. * actionButtons={filteredActions}
  720. * {...{
  721. * global,
  722. * colors,
  723. * t,
  724. * group,
  725. * onLinkPress
  726. * }}
  727. * >
  728. * <AvatarActionButton
  729. * user={currentUser}
  730. * style={{
  731. * ...buttonStyle,
  732. * paddingLeft: 3,
  733. * paddingRight: 13
  734. * }}
  735. * {...{
  736. * global,
  737. * colors,
  738. * t,
  739. * title: group.role,
  740. * titleStyle: {
  741. * ...global.textHeaderActionButton,
  742. * color: colors.primaryColor
  743. * },
  744. * color: buttonTextColor
  745. * }}
  746. * />
  747. * </GroupActionSheetWrapper>
  748. * ) : (
  749. * <AuthWrapper>
  750. * <ActionButtonList
  751. * hideIcons={true}
  752. * actionButtons={filteredActions}
  753. * object={group}
  754. * color={buttonTextColor}
  755. * t={t}
  756. * buttonStyle={{
  757. * ...buttonStyle,
  758. * marginHorizontal: 5,
  759. * paddingVertical: 0
  760. * }}
  761. * textStyle={global.textHeaderActionButton}
  762. * />
  763. * </AuthWrapper>
  764. * );
  765. *
  766. * }
  767. *
  768. * export default GroupHeaderButton;
  769. *
  770. * //In custom_code/index.js...
  771. *
  772. * import GroupHeaderButton from "./components/GroupHeaderButton";
  773. * export const applyCustomCode = externalCodeSetup => {
  774. * externalCodeSetup.socialGroupSingleApi.setGroupHeaderButtons(GroupHeaderButton)
  775. * }
  776. */
  777. setGroupHeaderButtons = (
  778. GroupHeaderButtons: React.ComponentType<GroupHeaderButtonsProps> | null
  779. ) => {
  780. this.GroupHeaderButtons = GroupHeaderButtons;
  781. };
  782. AfterProfileHeader: React.ComponentType<
  783. AfterGroupProfileHeaderProps
  784. > | null = null;
  785. /**
  786. * It adds a component after the group header but places it before the group items list.
  787. * @method
  788. * @param {React.ComponentType<AfterGroupProfileHeaderProps>} AfterProfileHeader
  789. * @example
  790. * externalCodeSetup.socialGroupSingleApi.setAfterProfileHeader(({group}) => {
  791. *
  792. * const toggleSubscription = () => {
  793. * if (typeof group.subscribeClick === "function") {
  794. * group.subscribeClick();
  795. * }
  796. * };
  797. *
  798. * return group.hasForum ? (
  799. * <View style={{margin: 10}}>
  800. * <Button
  801. * onPress={toggleSubscription}
  802. * title="Subscribe/Unsubscribe to group forum"
  803. * />
  804. * </View>
  805. * ) : null;
  806. * });
  807. */
  808. setAfterProfileHeader = (
  809. AfterProfileHeader: React.ComponentType<AfterGroupProfileHeaderProps> | null
  810. ) => {
  811. this.AfterProfileHeader = AfterProfileHeader;
  812. };
  813. filteredGroupActionButtons = (actions: GroupActionButton[]) => actions;
  814. /**
  815. * Append or prepend action buttons.
  816. * You can use this to modify the group's default action buttons.
  817. * `doFunction` can be used to dispatch a redux action.
  818. * @method
  819. * @param {GroupActionButton[]} filteredGroupActionButtons
  820. * @example
  821. *
  822. * externalCodeSetup.socialGroupSingleApi.setFilteredGroupActionButtons(
  823. * action => {
  824. * const requestDeliveryRedux = {
  825. * icon: {fontIconName: 'activity', weight: 200},
  826. * label: "Request for food delivery",
  827. * doFunction: () => ({type: "FOOD_DELIVERY_REQUEST"}) //Call custom redux action FOOD_DELIVERY_REQUEST
  828. * };
  829. * return [...action, requestDeliveryRedux];
  830. * }
  831. * );
  832. */
  833. setFilteredGroupActionButtons = (
  834. filteredGroupActionButtons: (
  835. buttons: GroupActionButton[]
  836. ) => GroupActionButton[]
  837. ) => {
  838. this.filteredGroupActionButtons = filteredGroupActionButtons;
  839. };
  840. HeaderRightComponent: React.ComponentType<
  841. HeaderRightComponentProps
  842. > | null = null;
  843. /**
  844. * You can use this hook to customize the button of the HeaderRightComponent.
  845. * @method
  846. * @param {React.ComponentType<HeaderRightComponentProps>} HeaderRightComponent
  847. * @example
  848. *
  849. * ...
  850. *
  851. * import AuthWrapper from "@src/components/AuthWrapper";
  852. * import {BottomSheetWrapper} from "../src/containers/SocialGroupsSingleScreen";
  853. * import IconButton from "@src/components/IconButton";
  854. * export const applyCustomCode = (externalCodeSetup: ExternalCodeSetup) => {
  855. * externalCodeSetup.socialGroupSingleApi.setHeaderRightComponent(
  856. * ({
  857. * styles,
  858. * t,
  859. * group,
  860. * colors,
  861. * global,
  862. * actionButtons,
  863. * onLinkPress,
  864. * icon,
  865. * headerColor,
  866. * rest
  867. * }) => (
  868. * <AuthWrapper>
  869. * <View style={styles.container}>
  870. * <BottomSheetWrapper
  871. * t={t}
  872. * group={group}
  873. * colors={colors}
  874. * global={global}
  875. * actionButtons={actionButtons}
  876. * onLinkPress={onLinkPress}
  877. * >
  878. * <IconButton
  879. * icon={icon}
  880. * webIcon={"IconAdd"}
  881. * tintColor={headerColor}
  882. * style={styles.icon}
  883. * {...rest}
  884. * />
  885. * </BottomSheetWrapper>
  886. * </View>
  887. * </AuthWrapper>
  888. * )
  889. * );
  890. * }
  891. */
  892. setHeaderRightComponent = (
  893. HeaderRightComponent: React.ComponentType<HeaderRightComponentProps> | null
  894. ) => {
  895. this.HeaderRightComponent = HeaderRightComponent;
  896. };
  897. ParentGroupBar: React.ComponentType<ParentGroupBarProps> | null = null;
  898. /**
  899. * You can use this hook to customize the ParentGroupBar component which is rendered if a group has a parent.
  900. * @method
  901. * @param {React.ComponentType<ParentGroupBarProps>} ParentGroupBar
  902. * @example
  903. *
  904. * ...
  905. *
  906. * import ParentGroupBar from "@src/components/Group/ParentGroupBar";
  907. *
  908. * export const applyCustomCode = (externalCodeSetup) => {
  909. *
  910. * externalCodeSetup.socialGroupSingleApi.setParentGroupBar(
  911. * ({parentGroup, styles, group, global, colors, navigateToParent, t}) => {
  912. * return !!parentGroup ? (
  913. * <ParentGroupBar
  914. * containerStyle={styles.container}
  915. * parentGroup={parentGroup}
  916. * subGroup={group}
  917. * global={global}
  918. * colors={colors}
  919. * onPress={navigateToParent}
  920. * t={t}
  921. * />
  922. * ) : null;
  923. * }
  924. * );
  925. *
  926. * }
  927. */
  928. setParentGroupBar = (
  929. ParentGroupBar: React.ComponentType<ParentGroupBarProps> | null
  930. ) => {
  931. this.ParentGroupBar = ParentGroupBar;
  932. };
  933. TabBadge: React.ComponentType<GroupTabBadgeProps> | null = null;
  934. /**
  935. * You can use this hook to customize the list item's badge.
  936. * @method
  937. * @param {React.ComponentType<GroupTabBadgeProps>} TabBadge
  938. * @example
  939. *
  940. * ...
  941. *
  942. * import {BubbleIcon} from "@src/components/BubbleIcon";
  943. *
  944. * export const applyCustomCode = (externalCodeSetup) => {
  945. * externalCodeSetup.socialGroupSingleApi.setTabBadge(
  946. * ({item, global, text, styles}) => (
  947. * <BubbleIcon
  948. * key={"tab_badge_" + item.label}
  949. * global={global}
  950. * text={text}
  951. * containerStyle={styles.container}
  952. * textStyle={styles.text}
  953. * />
  954. * )
  955. * );
  956. * }
  957. *
  958. */
  959. setTabBadge = (TabBadge: React.ComponentType<GroupTabBadgeProps> | null) => {
  960. this.TabBadge = TabBadge;
  961. };
  962. TabIcon: React.ComponentType<GroupTabIconProps> | null = null;
  963. /**
  964. * You can use this hook to customize the list item's icon.
  965. * @method
  966. * @param {React.ComponentType<GroupTabIconProps>} TabIcon
  967. * @example
  968. *
  969. * ...
  970. *
  971. * import Icon from "@src/components/Icon";
  972. *
  973. * export const applyCustomCode = (externalCodeSetup: ExternalCodeSetup) => {
  974. *
  975. * externalCodeSetup.socialGroupSingleApi.setTabIcon(
  976. * ({link, global, colors}) => {
  977. * return link.icon ? (
  978. * <View style={global.profileItemIconWrap}>
  979. * <Icon
  980. * tintColor={colors.textColor}
  981. * icon={link.icon}
  982. * styles={global.profileItemIcon}
  983. * />
  984. * </View>
  985. * ) : null;
  986. * }
  987. * );
  988. * }
  989. */
  990. setTabIcon = (TabIcon: React.ComponentType<GroupTabIconProps> | null) => {
  991. this.TabIcon = TabIcon;
  992. };
  993. TabArrowComponent: React.ComponentType<
  994. GroupTabArrowComponentProps
  995. > | null = null;
  996. /**
  997. * You can use this hook to customize the list item's arrow component.
  998. * @method
  999. * @param {React.ComponentType<GroupTabArrowComponentProps>} TabArrowComponent
  1000. * @example
  1001. *
  1002. * ...
  1003. *
  1004. * import Icon from "@src/components/Icon";
  1005. *
  1006. * export const applyCustomCode = (externalCodeSetup) => {
  1007. * externalCodeSetup.socialGroupSingleApi.setTabArrowComponent(
  1008. * ({tintColor, icon, styles}) => (
  1009. * <Icon
  1010. * webIcon={"IconArrowRight"}
  1011. * tintColor={tintColor}
  1012. * icon={icon}
  1013. * styles={styles.arrow}
  1014. * />
  1015. * )
  1016. * );
  1017. * }
  1018. *
  1019. */
  1020. setTabArrowComponent = (
  1021. TabArrowComponent: React.ComponentType<GroupTabArrowComponentProps> | null
  1022. ) => {
  1023. this.TabArrowComponent = TabArrowComponent;
  1024. };
  1025. TabTitleComponent: React.ComponentType<
  1026. GroupTabTitleComponentProps
  1027. > | null = null;
  1028. /**
  1029. * You can use this hook to customize the list item's title component.
  1030. * @method
  1031. * @param {React.ComponentType<GroupTabTitleComponentProps>} TabTitleComponent
  1032. * @example
  1033. *
  1034. * externalCodeSetup.socialGroupSingleApi.setTabTitleComponent(
  1035. * ({index, styles, title}) => (
  1036. * <Text key={"itemTitle_" + index} style={styles.title}>
  1037. * {title}
  1038. * </Text>
  1039. * )
  1040. * );
  1041. *
  1042. */
  1043. setTabTitleComponent = (
  1044. TabTitleComponent: React.ComponentType<GroupTabTitleComponentProps> | null
  1045. ) => {
  1046. this.TabTitleComponent = TabTitleComponent;
  1047. };
  1048. sendInvitesTabFilter = (tabs: GroupSendInvitesTab[]) => tabs;
  1049. /**
  1050. * You can use this hook to modify the tabs in the Group Send Invites screen.
  1051. * By default, only "Send Invites" and "Pending Invites" are available.
  1052. * @method
  1053. * @param {GroupSendInvitesTab[]} sendInvitesTabFilter
  1054. * @example
  1055. * externalCodeSetup.socialGroupSingleApi.setSendInvitesTabFilter(props => {
  1056. *
  1057. * const customTab = {
  1058. * icon: {fontIconName: 'comment', weight: 200},
  1059. * label: "About",
  1060. * onPress: () => Alert.alert("Navigate to custom invite screen"),
  1061. * };
  1062. *
  1063. * return [...props, customTab];
  1064. * });
  1065. */
  1066. setSendInvitesTabFilter = (
  1067. sendInvitesTabFilter: (tabs: GroupSendInvitesTab[]) => GroupSendInvitesTab[]
  1068. ) => {
  1069. this.sendInvitesTabFilter = sendInvitesTabFilter;
  1070. };
  1071. manageGroupTabFilter = (tabs: GroupManageTab[]) => tabs;
  1072. /**
  1073. * You can use this hook to modify the tabs in the Group Manage screen.
  1074. * @method
  1075. * @param {GroupManageTab[]} manageGroupTabFilter
  1076. * @example
  1077. * externalCodeSetup.socialGroupSingleApi.setManageGroupTabFilter(props => {
  1078. * const customTab = {
  1079. * icon: {fontIconName: 'comment', weight: 200},
  1080. * label: "About",
  1081. * onPress: () => Alert.alert("Navigate to custom manage screen")
  1082. * };
  1083. *
  1084. * return [...props, customTab];
  1085. * });
  1086. */
  1087. setManageGroupTabFilter = (
  1088. manageGroupTabFilter: (tabs: GroupManageTab[]) => GroupManageTab[]
  1089. ) => {
  1090. this.manageGroupTabFilter = manageGroupTabFilter;
  1091. };
  1092. }