Skip to content

Commit 3c7dd05

Browse files
committed
fix: remove constant progress bar width
1 parent 64170ca commit 3c7dd05

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

package/src/components/Attachment/AudioAttachment.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export type AudioAttachmentProps = {
3535
* UI Component to preview the audio files
3636
*/
3737
export const AudioAttachment = (props: AudioAttachmentProps) => {
38+
const [width, setWidth] = useState(0);
39+
const [progressControlTextWidth, setProgressControlTextWidth] = useState(0);
3840
const [currentSpeed, setCurrentSpeed] = useState<number>(1.0);
3941
const soundRef = React.useRef<SoundReturnType | null>(null);
4042
const {
@@ -252,7 +254,12 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
252254
<Pause fill={static_black} height={32} width={32} />
253255
)}
254256
</Pressable>
255-
<View style={[styles.leftContainer, leftContainer]}>
257+
<View
258+
onLayout={({ nativeEvent }) => {
259+
setWidth(nativeEvent.layout.width);
260+
}}
261+
style={[styles.leftContainer, leftContainer]}
262+
>
256263
<Text
257264
accessibilityLabel='File Name'
258265
numberOfLines={1}
@@ -281,7 +288,12 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
281288
uri={item.file.uri}
282289
/>
283290
)}
284-
<Text style={[styles.progressDurationText, { color: grey_dark }, progressDurationText]}>
291+
<Text
292+
onLayout={({ nativeEvent }) => {
293+
setProgressControlTextWidth(nativeEvent.layout.width);
294+
}}
295+
style={[styles.progressDurationText, { color: grey_dark }, progressDurationText]}
296+
>
285297
{progressDuration}
286298
</Text>
287299
{!hideProgressBar && (
@@ -307,7 +319,7 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
307319
onProgressDrag={handleProgressDrag}
308320
progress={item.progress as number}
309321
testID='progress-control'
310-
width={150}
322+
width={width - progressControlTextWidth}
311323
/>
312324
)}
313325
</View>

0 commit comments

Comments
 (0)