@kirz/react-native-toolkit
Version:
Toolkit to speed up React Native development
68 lines • 3.08 kB
TypeScript
import React, { ForwardedRef } from 'react';
import { SharedValue } from 'react-native-reanimated';
import { TinderPhotoSwiperCardProps } from './TinderPhotoSwiperCard';
import { ViewProps } from '../View';
export type Asset = {
uri: string;
favorite?: boolean;
};
export type Anim = {
left?: number;
top?: number;
opacity?: number;
scale?: number;
rotation?: number;
overlayColor?: [number, number, number, number];
};
export type TinderDecision<T extends Asset = Asset> = {
date: Date;
decision: 'like' | 'dislike' | 'skip';
photoId: string;
asset: TinderPhoto<T>;
};
export type TinderPhoto<T extends Asset = Asset> = ({
id: string;
} & T) | {
id: string;
loader: () => Promise<T>;
};
export type TinderPhotoSwiperProps<T extends Asset = Asset> = ViewProps & {
likeActivationValue?: SharedValue<number>;
dislikeActivationValue?: SharedValue<number>;
favouriteActivationValue?: SharedValue<number>;
photos: TinderPhoto<T>[];
states: TinderPhotoSwiperCardProps['states'];
cardProps?: Pick<TinderPhotoSwiperCardProps<T>, 'imageProps'>;
windowSize?: number;
onDecisionsChange?: (decision: TinderDecision | null, allDecisions: IterableIterator<TinderDecision>) => void;
onFavoriteChange?: (photo: T, value: boolean) => void;
onFinish?: () => void;
};
export type TinderPhotoSwiperRef = {
likePhoto: () => void;
dislikePhoto: () => void;
skipPhoto: () => void;
toggleFavorite: () => void;
revertDecision: () => void;
};
declare function TinderPhotoSwiperInner<T extends Asset = Asset>({ photos: initialPhotos, states, cardProps, likeActivationValue: likeActivationValueRef, dislikeActivationValue: dislikeActivationValueRef, favouriteActivationValue: favouriteActivationValueRef, windowSize, onDecisionsChange, onFavoriteChange, onFinish, ...props }: TinderPhotoSwiperProps<T>, ref: ForwardedRef<TinderPhotoSwiperRef>): JSX.Element;
export declare const TinderPhotoSwiper: <T extends Asset = Asset>(props: Omit<import("react-native").ViewProps, "style"> & {
style?: import("react-native").StyleProp<import("../View").ViewStyle>;
skeleton?: boolean | undefined;
skeletonStyle?: import("react-native").StyleProp<import("../View").ViewStyle>;
} & {
likeActivationValue?: SharedValue<number> | undefined;
dislikeActivationValue?: SharedValue<number> | undefined;
favouriteActivationValue?: SharedValue<number> | undefined;
photos: TinderPhoto<T>[];
states: TinderPhotoSwiperCardProps['states'];
cardProps?: Pick<TinderPhotoSwiperCardProps<T, Anim>, "imageProps"> | undefined;
windowSize?: number | undefined;
onDecisionsChange?: ((decision: TinderDecision | null, allDecisions: IterableIterator<TinderDecision>) => void) | undefined;
onFavoriteChange?: ((photo: T, value: boolean) => void) | undefined;
onFinish?: (() => void) | undefined;
} & {
ref?: React.ForwardedRef<TinderPhotoSwiperRef> | undefined;
}) => ReturnType<typeof TinderPhotoSwiperInner>;
export {};
//# sourceMappingURL=TinderPhotoSwiper.d.ts.map