diff options
Diffstat (limited to 'modules/expo-bluesky-gif-view/src/GifView.tsx')
-rw-r--r-- | modules/expo-bluesky-gif-view/src/GifView.tsx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/modules/expo-bluesky-gif-view/src/GifView.tsx b/modules/expo-bluesky-gif-view/src/GifView.tsx new file mode 100644 index 000000000..87258de17 --- /dev/null +++ b/modules/expo-bluesky-gif-view/src/GifView.tsx @@ -0,0 +1,39 @@ +import React from 'react' +import {requireNativeModule} from 'expo' +import {requireNativeViewManager} from 'expo-modules-core' + +import {GifViewProps} from './GifView.types' + +const NativeModule = requireNativeModule('ExpoBlueskyGifView') +const NativeView: React.ComponentType< + GifViewProps & {ref: React.RefObject<any>} +> = requireNativeViewManager('ExpoBlueskyGifView') + +export class GifView extends React.PureComponent<GifViewProps> { + // TODO native types, should all be the same as those in this class + private nativeRef: React.RefObject<any> = React.createRef() + + constructor(props: GifViewProps | Readonly<GifViewProps>) { + super(props) + } + + static async prefetchAsync(sources: string[]): Promise<void> { + return await NativeModule.prefetchAsync(sources) + } + + async playAsync(): Promise<void> { + await this.nativeRef.current.playAsync() + } + + async pauseAsync(): Promise<void> { + await this.nativeRef.current.pauseAsync() + } + + async toggleAsync(): Promise<void> { + await this.nativeRef.current.toggleAsync() + } + + render() { + return <NativeView {...this.props} ref={this.nativeRef} /> + } +} |