diff --git a/src/components/Form/index.tsx b/src/components/Form/index.tsx index cf414ad..cafbf94 100644 --- a/src/components/Form/index.tsx +++ b/src/components/Form/index.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { ArrowLeft } from 'phosphor-react-native'; -import { View, TextInput, Image, Text, TouchableOpacity } from 'react-native'; +import { View, TextInput, Image, Text, TouchableOpacity, Keyboard } from 'react-native'; import { theme } from '../../theme'; import { feedbackTypes } from '../../utils/feedbackTypes'; import { Button } from '../Button'; @@ -19,22 +19,32 @@ interface Props { feedbackType: FeedbackType onFeedbackReset: () => void; onFeedbackSent: () => void; + onFeedbackTakingScreenshot: (data: -1 | 0 | 1) => void; } -export function Form({feedbackType, onFeedbackReset, onFeedbackSent}: Props) { +export function Form({feedbackType, onFeedbackReset, onFeedbackSent, onFeedbackTakingScreenshot}: Props) { const [comment, setComment] = useState(''); const [screenshot, setScreenshot] = useState(null); const [isSendingFeedback, setIsSendingFeedback] = useState(false); const feedbackTypeInfo = feedbackTypes[feedbackType]; - function handleScreenshot() { - captureScreen({ - format: 'jpg', - quality: 0.8, - }) - .then(uri => setScreenshot(uri)) - .catch(error => console.log(error)); + async function handleScreenshot() { + onFeedbackTakingScreenshot(0); + Keyboard.dismiss(); + + setTimeout(() => { + captureScreen({ + format: 'jpg', + quality: 0.7, + }) + .then(uri => setScreenshot(uri)) + .catch(error => console.log(error)); + }, 250); + + setTimeout(() => { + onFeedbackTakingScreenshot(1); + }, 500); } function handleRemoveScreenshot() { diff --git a/src/components/WidgetWrapper/index.tsx b/src/components/WidgetWrapper/index.tsx index f85c323..0d4673d 100644 --- a/src/components/WidgetWrapper/index.tsx +++ b/src/components/WidgetWrapper/index.tsx @@ -24,6 +24,7 @@ interface Props { function WidgetWrapper({children} : Props) { const [feedbackType, setFeedbackType] = useState(null); const [feedbackSent, setFeedbackSent] = useState(false); + const [feedbackSheetIndex, setFeedbackSheetIndex] = useState< -1 |0 | 1 >(-1); const bottomSheetRef = useRef(null); @@ -65,11 +66,12 @@ function WidgetWrapper({children} : Props) { + onClose={handleFeedbackReset}> { feedbackSent @@ -82,7 +84,8 @@ function WidgetWrapper({children} : Props) {
+ onFeedbackSent={handleFeedbackSent} + onFeedbackTakingScreenshot={setFeedbackSheetIndex}/> :