import {createRef, PureComponent} from 'react' import {requireNativeModule} from 'expo' import {requireNativeViewManager} from 'expo-modules-core' import {type GifViewProps} from './GifView.types' interface GifViewNativeRef { playAsync: () => Promise pauseAsync: () => Promise toggleAsync: () => Promise } const NativeModule: { prefetchAsync: (sources: string[]) => Promise } = requireNativeModule('ExpoBlueskyGifView') const NativeView: React.ComponentType< GifViewProps & {ref: React.RefObject} > = requireNativeViewManager('ExpoBlueskyGifView') export class GifView extends PureComponent { private nativeRef: React.RefObject = createRef() constructor(props: GifViewProps | Readonly) { super(props) } static async prefetchAsync(sources: string[]): Promise { return await NativeModule.prefetchAsync(sources) } async playAsync(): Promise { await this.nativeRef.current?.playAsync() } async pauseAsync(): Promise { await this.nativeRef.current?.pauseAsync() } async toggleAsync(): Promise { await this.nativeRef.current?.toggleAsync() } render() { return } }