diff options
author | Ivan Chen <ivan@tagg.id> | 2021-06-29 17:06:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-29 17:06:19 -0400 |
commit | 66c974161b59f1e3570e2a4a42334fabc16c2129 (patch) | |
tree | 7a1546101e2966b7bb38bf92bca4be64b1ccd7b6 /src/components/camera/FlashButton.tsx | |
parent | 53bdc94cf0491e348b7d4ad61e51ce1844423773 (diff) | |
parent | d4b210518eaffd3bf1320ca7ce7fa4a6d611528f (diff) |
Merge pull request #476 from shravyaramesh/tma937-tagg-camera
[TMA-937] Tagg Camera
Diffstat (limited to 'src/components/camera/FlashButton.tsx')
-rw-r--r-- | src/components/camera/FlashButton.tsx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/components/camera/FlashButton.tsx b/src/components/camera/FlashButton.tsx new file mode 100644 index 00000000..06a4e44e --- /dev/null +++ b/src/components/camera/FlashButton.tsx @@ -0,0 +1,42 @@ +import React, {Dispatch, SetStateAction} from 'react'; +import {Text, TouchableOpacity} from 'react-native'; +import {FlashMode} from 'react-native-camera'; +import FlashOffIcon from '../../assets/icons/camera/flash-off.svg'; +import FlashOnIcon from '../../assets/icons/camera/flash-on.svg'; +import {styles} from './styles'; + +interface FlashButtonProps { + flashMode: keyof FlashMode; + setFlashMode: Dispatch<SetStateAction<keyof FlashMode>>; +} + +/* + * Toggles between flash on/off modes + */ +export const FlashButton: React.FC<FlashButtonProps> = ({ + flashMode, + setFlashMode, +}) => ( + <TouchableOpacity + onPress={() => setFlashMode(flashMode === 'on' ? 'off' : 'on')} + style={styles.flashButtonContainer}> + {flashMode === 'on' ? ( + <FlashOnIcon + height={30} + width={20} + color={'white'} + style={styles.flashIcon} + /> + ) : ( + <FlashOffIcon + height={30} + width={20} + color={'white'} + style={styles.flashIcon} + /> + )} + <Text style={styles.saveButtonLabel}>Flash</Text> + </TouchableOpacity> +); + +export default FlashButton; |