react-native-android-thumbnail
v1.0.2
Published
Turbo module for getting all images and Fabric component for showing visual image thumbnail
Downloads
1
Maintainers
Readme
react-native-android-thumbnail
A native android component, which loads a visual thumbnail for the given contentUri, useful for showing many images from android devices. The package also provides a module for getting images' info, such as uri, album name, size, image name and contentURI for loading thumbnail
Installation
npm install react-native-android-thumbnail
Updating manifests
Open your project's AndroidManifest.xml and add the following lines inside the tag:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Requesting Permissions
import { PermissionsAndroid, Permission } from 'react-native';
// ...
const permission: Permission = PermissionsAndroid.PERMISSIONS
.READ_EXTERNAL_STORAGE as 'android.permission.READ_EXTERNAL_STORAGE';
const requestReadExternalStoragePermission = async () => {
try {
const granted = await PermissionsAndroid.request(permission, {
title: 'Read External Storage Permission',
message:
'This App needs access to your media ' +
'so you can take awesome pictures.',
buttonNeutral: 'Ask Me Later',
buttonNegative: 'Cancel',
buttonPositive: 'OK',
});
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log('GRANTED!');
} else {
console.log('External Storage permission denied');
}
} catch (err) {
console.warn(err);
}
};
// ...
Usage
import { getPhotos, Thumbnail } from 'react-native-android-thumbnail';
// ...
const allPhotos = await getPhotos();
return (
<Thumbnail contentUri={allPhotos[0].contentUri} size={100} />
);
// ...
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library