From 93a99a13cb3f1bbbb00893ea583483a91bf0f1f1 Mon Sep 17 00:00:00 2001 From: Maciej Makowski Date: Tue, 10 Dec 2024 14:58:36 +0100 Subject: [PATCH] fix: fixed AudioFile.tsx and Button.tsx --- apps/common-app/src/components/Button.tsx | 20 +++++++++++++------ .../src/examples/AudioFile/AudioFile.tsx | 15 ++++++++++---- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/apps/common-app/src/components/Button.tsx b/apps/common-app/src/components/Button.tsx index 1da2f1bf..e6758bf8 100644 --- a/apps/common-app/src/components/Button.tsx +++ b/apps/common-app/src/components/Button.tsx @@ -6,17 +6,26 @@ import { colors, layout } from '../styles'; interface ButtonProps { title: string; onPress: () => void; + disabled?: boolean; + width?: number; } -const Button: FC = (props) => { - const { title, onPress } = props; - +const Button: FC = ({ + title, + onPress, + disabled = false, + width = 100, +}) => { return ( [ styles.button, - { backgroundColor: pressed ? `${colors.main}88` : colors.main }, + { + backgroundColor: pressed ? `${colors.main}88` : colors.main, + opacity: disabled ? 0.5 : 1, + width: width, + }, ]} > {title} @@ -28,7 +37,6 @@ const styles = StyleSheet.create({ button: { padding: layout.spacing, borderRadius: layout.radius, - width: 100, }, text: { color: colors.white, diff --git a/apps/common-app/src/examples/AudioFile/AudioFile.tsx b/apps/common-app/src/examples/AudioFile/AudioFile.tsx index 1f9d4f2f..6b2e6d3d 100644 --- a/apps/common-app/src/examples/AudioFile/AudioFile.tsx +++ b/apps/common-app/src/examples/AudioFile/AudioFile.tsx @@ -11,6 +11,7 @@ import { ActivityIndicator } from 'react-native'; const AudioFile: FC = () => { const [isPlaying, setIsPlaying] = useState(false); + const [isLoading, setIsLoading] = useState(false); const audioContextRef = useRef(null); const audioBufferSourceNodeRef = useRef(null); @@ -38,9 +39,10 @@ const AudioFile: FC = () => { if (result.canceled === false) { audioBufferSourceNodeRef.current?.stop(); setIsPlaying(false); - setAudioBuffer(null); + setIsLoading(true); await fetchAudioBuffer(result.assets[0].uri.replace('file://', '')); + setIsLoading(false); } } catch (error) { console.error('Error picking file:', error); @@ -86,12 +88,17 @@ const AudioFile: FC = () => { return ( -