Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[createReactClass] Remove createReactClass from CameraRollView #21619

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions Libraries/CameraRoll/CameraRoll.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,34 +79,36 @@ const getPhotosParamChecker = createStrictShapeTypeChecker({
mimeTypes: PropTypes.arrayOf(PropTypes.string),
});

type GetPhotosReturn = Promise<{
edges: Array<{
node: {
type: string,
group_name: string,
image: {
uri: string,
height: number,
width: number,
isStored?: boolean,
playableDuration: number,
},
timestamp: number,
location?: {
latitude?: number,
longitude?: number,
altitude?: number,
heading?: number,
speed?: number,
},
export type PhotoIdentifier = {
node: {
type: string,
group_name: string,
image: {
uri: string,
height: number,
width: number,
isStored?: boolean,
playableDuration: number,
},
}>,
timestamp: number,
location?: {
latitude?: number,
longitude?: number,
altitude?: number,
heading?: number,
speed?: number,
},
},
};

export type PhotoIdentifiersPage = {
edges: Array<PhotoIdentifier>,
page_info: {
has_next_page: boolean,
start_cursor?: string,
end_cursor?: string,
},
}>;
};

/**
* Shape of the return value of the `getPhotos` function.
Expand Down Expand Up @@ -204,7 +206,7 @@ class CameraRoll {
*
* See https://facebook.github.io/react-native/docs/cameraroll.html#getphotos
*/
static getPhotos(params: GetPhotosParams): GetPhotosReturn {
static getPhotos(params: GetPhotosParams): Promise<PhotoIdentifiersPage> {
if (__DEV__) {
checkPropTypes(
{params: getPhotosParamChecker},
Expand Down
8 changes: 6 additions & 2 deletions RNTester/js/CameraRollExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const CameraRollView = require('./CameraRollView');

const AssetScaledImageExampleView = require('./AssetScaledImageExample');

import type {PhotoIdentifier} from 'CameraRoll';

class CameraRollExample extends React.Component<
$FlowFixMeProps,
$FlowFixMeState,
Expand Down Expand Up @@ -74,15 +76,17 @@ class CameraRollExample extends React.Component<
}
}

_renderImage = asset => {
_renderImage = (asset: PhotoIdentifier) => {
const imageSize = this.state.bigImages ? 150 : 75;
const imageStyle = [styles.image, {width: imageSize, height: imageSize}];
const {location} = asset.node;
const locationStr = location
? JSON.stringify(location)
: 'Unknown location';
return (
<TouchableOpacity key={asset} onPress={this.loadAsset.bind(this, asset)}>
<TouchableOpacity
key={asset.node.image.uri}
onPress={this.loadAsset.bind(this, asset)}>
<View style={styles.row}>
<Image source={asset.node.image} style={imageStyle} />
<View style={styles.info}>
Expand Down
Loading