Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
feat: updated example
Browse files Browse the repository at this point in the history
  • Loading branch information
killi8n committed Nov 4, 2020
1 parent 643ea06 commit 89e4a2a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
33 changes: 26 additions & 7 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,43 @@ import * as React from 'react';
import { StyleSheet, Button, SafeAreaView, Image, Text } from 'react-native';
import ImageSelector, {
ImageSelectorCallbackResponse,
ImageSelectorOptions,
} from 'react-native-image-selector';

const options: ImageSelectorOptions = {
// import Options
storageOptions: {
skipBackup: true,
path: 'hello',
},
permissionDenied: {
title: '권한 설정',
text: "이 기능을 이용하시려면 권한을 '허용'으로 변경해주세요.",
reTryTitle: '변경하러가기',
okTitle: '닫기',
},
title: '사진 선택',
cancelButtonTitle: '취소',
takePhotoButtonTitle: '사진 촬영',
chooseFromLibraryButtonTitle: '앨범에서 가져오기',
};

export default function App() {
const [
response,
setResponse,
] = React.useState<ImageSelectorCallbackResponse | null>(null);
const handlePhotos = async () => {
try {
ImageSelector.launchPicker(
(error, response: ImageSelectorCallbackResponse) => {
if (error) {
console.log(error);
return;
}
ImageSelector.launchPicker(options, (error, response) => {
if (error) {
console.log(error);
return;
}
if (response) {
setResponse(response);
}
);
});
} catch (e) {
console.error(e);
}
Expand Down
20 changes: 19 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ export interface ImageSelectorCallbackResponse {
path: string;
}

export interface ImageSelectorOptions {
title?: string;
cancelButtonTitle?: string;
takePhotoButtonTitle?: string;
chooseFromLibraryButtonTitle?: string;
storageOptions?: {
skipBackup?: boolean;
path?: string;
};
permissionDenied?: {
title?: string;
text?: string;
reTryTitle?: string;
okTitle?: string;
};
}

type ImageSelectorType = {
launchPicker: (
options: ImageSelectorOptions,
callback: (
error: { error: string },
response: ImageSelectorCallbackResponse
response?: ImageSelectorCallbackResponse
) => void
) => void;
};
Expand Down

0 comments on commit 89e4a2a

Please sign in to comment.