Skip to content

Commit

Permalink
chore: fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
lodev09 committed Jan 23, 2025
1 parent e73f18e commit 46a2777
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions example/components/ThemedRecorderSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Animated, {
type WithSpringConfig,
} from 'react-native-reanimated'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { Recorder, type RecorderRef } from '@lodev09/expo-recorder'
import { Recorder, type RecordInfo, type RecorderRef } from '@lodev09/expo-recorder'
import { type TrueSheetProps, TrueSheet } from '@lodev09/react-native-true-sheet'

import { useThemeColor } from '@/hooks/useThemeColor'
Expand Down Expand Up @@ -69,23 +69,26 @@ export const ThemedRecorderSheet = forwardRef(

const scale = useSharedValue(1)

const handleRecordStop = (record?: RecordInfo) => {
scale.value = withSpring(1, SPRING_SHORT_CONFIG)
setIsRecording(false)

recorderRef.current?.startPlayback()

// Use this uri. Yay! 🎉
console.log(record?.uri)
console.log(record?.duration)
// console.log(record?.meterings)
}

const toggleRecording = async () => {
const permissionStatus = await Audio.getPermissionsAsync()
if (!permissionStatus.granted) return

Haptics.selectionAsync()
if (isRecording) {
const record = await recorderRef.current?.stopRecording()

scale.value = withSpring(1, SPRING_SHORT_CONFIG)
setIsRecording(false)

recorderRef.current?.startPlayback()

// Use this uri. Yay! 🎉
console.log(record?.uri)
console.log(record?.duration)
// console.log(record?.meterings)
handleRecordStop(record)
} else {
await recorderRef.current?.startRecording()

Expand Down Expand Up @@ -141,6 +144,7 @@ export const ThemedRecorderSheet = forwardRef(
timelineColor={timelineColor}
backgroundColor={recorderBackgroundColor}
progressBackgroundColor={progressBackgroundColor}
onRecordStop={handleRecordStop}
onRecordReset={() => {
scale.value = 1
setIsRecording(false)
Expand Down

0 comments on commit 46a2777

Please sign in to comment.