|
| 1 | +import {BrandColors} from '../utils/Colors'; |
| 2 | +import React from 'react'; |
| 3 | +import { |
| 4 | + type GestureResponderEvent, |
| 5 | + StyleSheet, |
| 6 | + Text, |
| 7 | + TouchableHighlight, |
| 8 | + View, |
| 9 | +} from 'react-native'; |
| 10 | +import AccessibilityLabel from '../types/AccessibilityLabel'; |
| 11 | +import {TrackEncoding} from '@jellyfish-dev/react-native-client-sdk'; |
| 12 | + |
| 13 | +const LetterButtonStyles = StyleSheet.create({ |
| 14 | + common: { |
| 15 | + width: 44, |
| 16 | + height: 44, |
| 17 | + borderRadius: 22, |
| 18 | + justifyContent: 'center', |
| 19 | + alignItems: 'center', |
| 20 | + }, |
| 21 | + button: { |
| 22 | + borderWidth: 1, |
| 23 | + borderStyle: 'solid', |
| 24 | + borderColor: BrandColors.darkBlue100, |
| 25 | + }, |
| 26 | + buttonSelected: { |
| 27 | + backgroundColor: BrandColors.darkBlue100, |
| 28 | + }, |
| 29 | + buttonUnSelected: { |
| 30 | + backgroundColor: BrandColors.darkBlue20, |
| 31 | + }, |
| 32 | + text: { |
| 33 | + fontSize: 18, |
| 34 | + }, |
| 35 | + textSelected: { |
| 36 | + color: BrandColors.darkBlue20, |
| 37 | + }, |
| 38 | + textUnselected: { |
| 39 | + color: BrandColors.darkBlue100, |
| 40 | + }, |
| 41 | +}); |
| 42 | + |
| 43 | +type LetterButtonProps = { |
| 44 | + onPress: (event: GestureResponderEvent) => void; |
| 45 | + trackEncoding: TrackEncoding; |
| 46 | + selected: boolean; |
| 47 | +} & AccessibilityLabel; |
| 48 | + |
| 49 | +const LetterButton = ({ |
| 50 | + onPress, |
| 51 | + trackEncoding, |
| 52 | + selected, |
| 53 | +}: LetterButtonProps) => { |
| 54 | + const stylesForText = () => { |
| 55 | + return selected |
| 56 | + ? LetterButtonStyles.textSelected |
| 57 | + : LetterButtonStyles.textUnselected; |
| 58 | + }; |
| 59 | + |
| 60 | + const stylesForButton = () => { |
| 61 | + return selected |
| 62 | + ? LetterButtonStyles.buttonSelected |
| 63 | + : LetterButtonStyles.buttonUnSelected; |
| 64 | + }; |
| 65 | + return ( |
| 66 | + <TouchableHighlight |
| 67 | + onPress={onPress} |
| 68 | + style={[LetterButtonStyles.common, stylesForButton()]} |
| 69 | + key={trackEncoding}> |
| 70 | + <View |
| 71 | + style={[ |
| 72 | + LetterButtonStyles.common, |
| 73 | + LetterButtonStyles.button, |
| 74 | + stylesForButton(), |
| 75 | + ]}> |
| 76 | + <Text style={[LetterButtonStyles.text, stylesForText()]}> |
| 77 | + {trackEncoding.toUpperCase()} |
| 78 | + </Text> |
| 79 | + </View> |
| 80 | + </TouchableHighlight> |
| 81 | + ); |
| 82 | +}; |
| 83 | + |
| 84 | +export default LetterButton; |
0 commit comments