import * as React from 'react'; import { StyleSheet, View, Button, Text, TextInput, Keyboard, Appearance, } from 'react-native'; import {CameraRoll} from '@react-native-camera-roll/camera-roll'; import type { // GetAlbumsParams, Album, } from '@react-native-camera-roll/camera-roll'; interface State { colorScheme: 'light' | 'dark'; fetchingAlbums: boolean; timeTakenMillis: number | null; output: Album[] | null; } /** * Example for testing performance differences between `getPhotos` and * `getPhotosFast` */ export default class GetPhotosPerformanceExample extends React.PureComponent< {}, State > { state: State = { colorScheme: Appearance.getColorScheme() === 'light' ? 'light' : 'dark', fetchingAlbums: false, timeTakenMillis: null, output: null, }; startFetchingAlbums = async () => { this.setState({fetchingAlbums: true}); Keyboard.dismiss(); // const params: GetAlbumsParams = {assetType: 'All'}; const startTime = Date.now(); const output: Album[] = await CameraRoll.getAlbums({assetType: 'All'}); const endTime = Date.now(); this.setState({ output, timeTakenMillis: endTime - startTime, fetchingAlbums: false, }); }; componentDidMount(): void { Appearance.addChangeListener(({colorScheme}) => { this.setState({colorScheme: colorScheme === 'light' ? 'light' : 'dark'}); }); } get styles() { return { container: { backgroundColor: this.state.colorScheme === 'light' ? '#fff' : '#000', }, text: { color: this.state.colorScheme === 'light' ? '#000' : '#fff', }, }; } render() { const {fetchingAlbums, timeTakenMillis, output} = this.state; return (