From b0804b9159f269fc3b0ccb4198455cbddd96cba1 Mon Sep 17 00:00:00 2001 From: Shravya Ramesh Date: Wed, 4 Aug 2021 10:15:23 -0700 Subject: Swap buttons, Add styles --- src/components/camera/FlashButton.tsx | 78 +++++++++++++++++++++++------------ src/components/camera/styles.tsx | 16 ++++--- 2 files changed, 62 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/components/camera/FlashButton.tsx b/src/components/camera/FlashButton.tsx index 06a4e44e..f7791d5b 100644 --- a/src/components/camera/FlashButton.tsx +++ b/src/components/camera/FlashButton.tsx @@ -1,8 +1,10 @@ -import React, {Dispatch, SetStateAction} from 'react'; -import {Text, TouchableOpacity} from 'react-native'; +import {BlurView} from '@react-native-community/blur'; +import React, {Dispatch, SetStateAction, useMemo} from 'react'; +import {Text, TouchableOpacity, View} 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 {normalize} from 'react-native-elements'; +import FlashOnIcon from '../../assets/icons/camera/flash-off.svg'; +import FlashOffIcon from '../../assets/icons/camera/flash-on.svg'; import {styles} from './styles'; interface FlashButtonProps { @@ -16,27 +18,51 @@ interface FlashButtonProps { export const FlashButton: React.FC = ({ flashMode, setFlashMode, -}) => ( - setFlashMode(flashMode === 'on' ? 'off' : 'on')} - style={styles.flashButtonContainer}> - {flashMode === 'on' ? ( - - ) : ( - - )} - Flash - -); +}) => { + return useMemo( + () => ( + <> + + setFlashMode(flashMode === 'on' ? 'off' : 'on')} + style={[styles.flashButtonContainerBackground]}> + + {flashMode === 'off' ? ( + + ) : ( + + )} + Flash + + + + ), + [flashMode], + ); +}; export default FlashButton; diff --git a/src/components/camera/styles.tsx b/src/components/camera/styles.tsx index 33b47cc4..beae7082 100644 --- a/src/components/camera/styles.tsx +++ b/src/components/camera/styles.tsx @@ -18,9 +18,16 @@ export const styles = StyleSheet.create({ zIndex: 999, }, flashButtonContainer: { + zIndex: 3, + height: 86, + width: 49, + flexDirection: 'column', + justifyContent: 'center', + alignItems: 'center', + borderRadius: 30, + }, + flashButtonContainerBackground: { position: 'absolute', - backgroundColor: '#808080', - opacity: 0.25, zIndex: 1, top: normalize(50), right: 0, @@ -30,7 +37,7 @@ export const styles = StyleSheet.create({ flexDirection: 'column', justifyContent: 'center', alignItems: 'center', - borderRadius: 30, + borderRadius: 50, }, galleryIcon: { borderWidth: 2, @@ -47,7 +54,4 @@ export const styles = StyleSheet.create({ height: 40, backgroundColor: 'grey', }, - flashIcon: { - zIndex: 2, - }, }); -- cgit v1.2.3-70-g09d2 From 58f3946125df54b1c630a7a06f705eaa9b31c4da Mon Sep 17 00:00:00 2001 From: Shravya Ramesh Date: Thu, 5 Aug 2021 12:03:57 -0700 Subject: Address issues --- src/assets/icons/camera/flash-off.svg | 2 +- src/assets/icons/camera/flash-on.svg | 2 +- src/components/camera/FlashButton.tsx | 73 +++++++++++++---------------------- src/components/camera/styles.tsx | 13 +++++++ 4 files changed, 42 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/assets/icons/camera/flash-off.svg b/src/assets/icons/camera/flash-off.svg index fb04efd2..b4608b75 100644 --- a/src/assets/icons/camera/flash-off.svg +++ b/src/assets/icons/camera/flash-off.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/camera/flash-on.svg b/src/assets/icons/camera/flash-on.svg index b4608b75..fb04efd2 100644 --- a/src/assets/icons/camera/flash-on.svg +++ b/src/assets/icons/camera/flash-on.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/components/camera/FlashButton.tsx b/src/components/camera/FlashButton.tsx index f7791d5b..65c773d9 100644 --- a/src/components/camera/FlashButton.tsx +++ b/src/components/camera/FlashButton.tsx @@ -1,10 +1,9 @@ import {BlurView} from '@react-native-community/blur'; -import React, {Dispatch, SetStateAction, useMemo} from 'react'; +import React, {Dispatch, SetStateAction} from 'react'; import {Text, TouchableOpacity, View} from 'react-native'; import {FlashMode} from 'react-native-camera'; -import {normalize} from 'react-native-elements'; -import FlashOnIcon from '../../assets/icons/camera/flash-off.svg'; -import FlashOffIcon from '../../assets/icons/camera/flash-on.svg'; +import FlashOnIcon from '../../assets/icons/camera/flash-on.svg'; +import FlashOffIcon from '../../assets/icons/camera/flash-off.svg'; import {styles} from './styles'; interface FlashButtonProps { @@ -19,49 +18,31 @@ export const FlashButton: React.FC = ({ flashMode, setFlashMode, }) => { - return useMemo( - () => ( - <> - + + setFlashMode(flashMode === 'on' ? 'off' : 'on')} + style={styles.flashButtonContainerBackground}> + - setFlashMode(flashMode === 'on' ? 'off' : 'on')} - style={[styles.flashButtonContainerBackground]}> - - {flashMode === 'off' ? ( - - ) : ( - - )} - Flash - - - - ), - [flashMode], + styles.flashButtonContainer, + // eslint-disable-next-line react-native/no-inline-styles + {opacity: flashMode === 'off' ? 0.5 : 1}, + ]}> + {flashMode === 'off' ? ( + + ) : ( + + )} + Flash + + + ); }; diff --git a/src/components/camera/styles.tsx b/src/components/camera/styles.tsx index beae7082..dbe1500b 100644 --- a/src/components/camera/styles.tsx +++ b/src/components/camera/styles.tsx @@ -54,4 +54,17 @@ export const styles = StyleSheet.create({ height: 40, backgroundColor: 'grey', }, + blurView: { + position: 'absolute', + zIndex: 1, + top: normalize(50), + right: 0, + marginRight: normalize(18), + height: 86, + width: 49, + flexDirection: 'column', + justifyContent: 'center', + alignItems: 'center', + borderRadius: 24.5, + }, }); -- cgit v1.2.3-70-g09d2