import React from 'react'; import {View, StyleSheet, TouchableOpacity} from 'react-native'; import PlayyText from '../PlayyText/PlayyText'; import {SwipeableListItemSwipeActionsProps, SwipeAction} from './types'; import {useTheme, ColorsScheme} from '../../theme/ThemeContext'; import {GLYPHS} from '../Glyphs'; /** * Swipe actions configuration for SwipeableListItem * This component doesn't render anything visible, but configures swipe behavior * * @example * ```tsx * {}} * onMute={() => {}} * onArchive={() => {}} * /> * ``` */ export const SwipeableListItemSwipeActions: React.FC = () => { // This component is used for configuration only, doesn't render return null; }; /** * Build left swipe actions based on configuration */ export const buildLeftSwipeActions = ( config: SwipeableListItemSwipeActionsProps | undefined, colors: ColorsScheme ): SwipeAction[] => { if (!config) return []; const actions: SwipeAction[] = []; // Custom left actions take precedence if (config.leftActions && config.leftActions.length > 0) { return config.leftActions; } // Read/Unread action if (config.readStatus) { actions.push({ comp: ( {GLYPHS['checkmark-message-fill'].char} {config.readStatus === 'unread' ? 'Unread' : 'Read'} ), color: config.leftActionColors?.read ?? colors.colors_blue, width: 64, onPress: config.onToggleReadStatus, }); } // Pin action if (config.showPinAction) { actions.push({ comp: ( {GLYPHS['pin-fill'].char} Pin ), color: config.leftActionColors?.pin ?? colors.gray_3, width: 64, onPress: config.onTogglePin, }); } return actions; }; /** * Build right swipe actions based on configuration */ export const buildRightSwipeActions = ( config: SwipeableListItemSwipeActionsProps | undefined, colors: ColorsScheme ): SwipeAction[] => { if (!config) return []; const actions: SwipeAction[] = []; // Custom right actions take precedence if (config.rightActions && config.rightActions.length > 0) { return config.rightActions; } // Mute action if (config.onMute) { actions.push({ comp: ( {GLYPHS['bell-slash-fill'].char} Mute ), color: config.rightActionColors?.mute ?? colors.red, width: 64, onPress: config.onMute, }); } // Archive action if (config.onArchive) { actions.push({ comp: ( {GLYPHS['archive-fill'].char} Archive ), color: config.rightActionColors?.archive ?? colors.colors_orange, width: 64, onPress: config.onArchive, }); } // More action if (config.onMore) { actions.push({ comp: ( {GLYPHS['menu-vertical'].char} More ), color: config.rightActionColors?.more ?? colors.gray_3, width: 64, onPress: config.onMore, }); } return actions; }; const styles = StyleSheet.create({ leftSwipeActionButton: { height: '100%', width: 64, justifyContent: 'center', alignItems: 'center', gap: 5, }, });