about summary refs log tree commit diff
path: root/modules/expo-bluesky-swiss-army/src/HLSDownload/index.native.tsx
diff options
context:
space:
mode:
authorHailey <me@haileyok.com>2024-08-15 11:23:48 -0700
committerGitHub <noreply@github.com>2024-08-15 11:23:48 -0700
commit11061b628ef5b5805c6435155ca2a571001e4643 (patch)
treed1e3c672d225592af7e1341332c6c6aeb979f216 /modules/expo-bluesky-swiss-army/src/HLSDownload/index.native.tsx
parentb9975697e22ef729e60b9111883127961258445b (diff)
downloadvoidsky-11061b628ef5b5805c6435155ca2a571001e4643.tar.zst
[Video] Download videos (#4886)
Co-authored-by: Samuel Newman <10959775+mozzius@users.noreply.github.com>
Diffstat (limited to 'modules/expo-bluesky-swiss-army/src/HLSDownload/index.native.tsx')
-rw-r--r--modules/expo-bluesky-swiss-army/src/HLSDownload/index.native.tsx39
1 files changed, 39 insertions, 0 deletions
diff --git a/modules/expo-bluesky-swiss-army/src/HLSDownload/index.native.tsx b/modules/expo-bluesky-swiss-army/src/HLSDownload/index.native.tsx
new file mode 100644
index 000000000..92f26192e
--- /dev/null
+++ b/modules/expo-bluesky-swiss-army/src/HLSDownload/index.native.tsx
@@ -0,0 +1,39 @@
+import React from 'react'
+import {StyleProp, ViewStyle} from 'react-native'
+import {requireNativeModule, requireNativeViewManager} from 'expo-modules-core'
+
+import {HLSDownloadViewProps} from './types'
+
+const NativeModule = requireNativeModule('ExpoHLSDownload')
+const NativeView: React.ComponentType<
+  HLSDownloadViewProps & {
+    ref: React.RefObject<any>
+    style: StyleProp<ViewStyle>
+  }
+> = requireNativeViewManager('ExpoHLSDownload')
+
+export default class HLSDownloadView extends React.PureComponent<HLSDownloadViewProps> {
+  private nativeRef: React.RefObject<any> = React.createRef()
+
+  constructor(props: HLSDownloadViewProps) {
+    super(props)
+  }
+
+  static isAvailable(): boolean {
+    return NativeModule.isAvailable()
+  }
+
+  async startDownloadAsync(sourceUrl: string): Promise<void> {
+    return await this.nativeRef.current.startDownloadAsync(sourceUrl)
+  }
+
+  render() {
+    return (
+      <NativeView
+        ref={this.nativeRef}
+        style={{height: 0, width: 0}}
+        {...this.props}
+      />
+    )
+  }
+}