From c70ec1ce1aff6072934add1f543576d5200c1b02 Mon Sep 17 00:00:00 2001
From: Samuel Newman <mozzius@protonmail.com>
Date: Fri, 30 Aug 2024 18:45:49 +0100
Subject: [Video] Captions and alt text (#5009)

* video settings modal in composer

* show done button on web

* rm download options

* fix logic for showing settings button

* add language picker (wip)

* subtitle list with language select

* send captions & alt text with video when posting

* style "ensure you have selected a language" text

* include aspect ratio with video

* filter out captions where the lang is not set

* rm log

* fix label and add hint

* minor scrubber fix
---
 .../com/composer/videos/SubtitleFilePicker.tsx     | 63 ++++++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 src/view/com/composer/videos/SubtitleFilePicker.tsx

(limited to 'src/view/com/composer/videos/SubtitleFilePicker.tsx')

diff --git a/src/view/com/composer/videos/SubtitleFilePicker.tsx b/src/view/com/composer/videos/SubtitleFilePicker.tsx
new file mode 100644
index 000000000..9e0fe0aee
--- /dev/null
+++ b/src/view/com/composer/videos/SubtitleFilePicker.tsx
@@ -0,0 +1,63 @@
+import React, {useRef} from 'react'
+import {View} from 'react-native'
+import {msg, Trans} from '@lingui/macro'
+import {useLingui} from '@lingui/react'
+
+import * as Toast from '#/view/com/util/Toast'
+import {atoms as a} from '#/alf'
+import {Button, ButtonIcon, ButtonText} from '#/components/Button'
+import {CC_Stroke2_Corner0_Rounded as CCIcon} from '#/components/icons/CC'
+
+export function SubtitleFilePicker({
+  onSelectFile,
+  disabled,
+}: {
+  onSelectFile: (file: File) => void
+  disabled?: boolean
+}) {
+  const {_} = useLingui()
+  const ref = useRef<HTMLInputElement>(null)
+
+  const handleClick = () => {
+    ref.current?.click()
+  }
+
+  const handlePick = (evt: React.ChangeEvent<HTMLInputElement>) => {
+    const selectedFile = evt.target.files?.[0]
+    if (selectedFile) {
+      if (selectedFile.type === 'text/vtt') {
+        onSelectFile(selectedFile)
+      } else {
+        Toast.show(_(msg`Only WebVTT (.vtt) files are supported`))
+      }
+    }
+  }
+
+  return (
+    <View style={a.gap_lg}>
+      <input
+        type="file"
+        accept=".vtt"
+        ref={ref}
+        style={a.hidden}
+        onChange={handlePick}
+        disabled={disabled}
+        aria-disabled={disabled}
+      />
+      <View style={a.flex_row}>
+        <Button
+          onPress={handleClick}
+          label={_('Select subtitle file (.vtt)')}
+          size="medium"
+          color="primary"
+          variant="solid"
+          disabled={disabled}>
+          <ButtonIcon icon={CCIcon} />
+          <ButtonText>
+            <Trans>Select subtitle file (.vtt)</Trans>
+          </ButtonText>
+        </Button>
+      </View>
+    </View>
+  )
+}
-- 
cgit 1.4.1

