Files
Bartol Karuzaandidrissakhi c230dd0074 feat(all): fix various issues and big maintenance update of the library (#404) (#411) BREAKING
Fixes
fix(ci): fixed android release build as a CI test step

fix(android): Fix MediaStore issues and support scopped storage #322 #244

fix(android): Fix saveImageToCameraRoll #248 #254

fix(android): remove JCenter #340 #401

fix(ios): Fix performance issues #276

fix(ios): add method to get file Path from internal PH ID #135

fix(react-native): Bump used dependencies #393 ...

Fixes #322
Fixes #244
Fixes #248
Fixes #254
Fixes #340
Fixes #401
Fixes #276
Fixes #135
Fixes #393

new Features

feat(ios): now it's possible to listen to library selection changes
`useEffect(() => {
let subscription: EmitterSubscription;
if (isAboveIOS14) {
subscription = cameraRollEventEmitter.addListener('onLibrarySelectionChange', (_event) => {
getUnloadedPictures();
});
}

return () => {
if (isAboveIOS14 && subscription) {
subscription.remove();
}
};`

feat(ios): possibility to open native modal to update selection when authorization is limited
iosRefreshGallerySelection()
feat(ios): Convert HEIC images on demand to upload to server
BREAKING CHANGE: root import changed!
```
import { CameraRoll } from @react-native-community/cameraroll
instead of
import CameraRoll from @react-native-community/cameraroll
```

Co-authored-by: idrissakhi <85105624+idrissakhi@users.noreply.github.com>
2022-08-23 08:13:10 +00:00

106 lines
2.6 KiB
TypeScript

import React from 'react';
import {Component} from 'react';
import {
SafeAreaView,
StyleSheet,
View,
Button,
Modal,
TouchableWithoutFeedback,
} from 'react-native';
// @ts-ignore: CameraRollExample has no typings in same folder
import CameraRollExample from './CameraRollExample';
import GetPhotosPerformanceExample from './GetPhotosPerformanceExample';
interface Props {}
interface State {
showChangeExampleModal: boolean;
currentExampleIndex: number;
}
interface Example {
label: string;
Component: React.ComponentType;
}
const examples: Example[] = [
{
label: 'CameraRollExample',
Component: CameraRollExample,
},
{
label: 'GetPhotosPerformanceExample',
Component: GetPhotosPerformanceExample,
},
];
/**
* Container for displaying and switching between multiple examples.
*
* Shows a button which opens up a Modal to switch between examples, as well
* as the current example itself.
*/
export default class ExamplesContainer extends Component<Props, State> {
state: State = {showChangeExampleModal: false, currentExampleIndex: 0};
render() {
const {currentExampleIndex} = this.state;
return (
<SafeAreaView style={styles.flex1}>
<Button
title="Change example"
onPress={() => this.setState({showChangeExampleModal: true})}
/>
{this._renderChangeExampleModal()}
<View style={styles.flex1}>
{React.createElement(examples[currentExampleIndex].Component)}
</View>
</SafeAreaView>
);
}
_renderChangeExampleModal() {
const {showChangeExampleModal} = this.state;
return (
<Modal visible={showChangeExampleModal} transparent>
<TouchableWithoutFeedback
onPress={() => this.setState({showChangeExampleModal: false})}>
<View style={styles.modalScrim}>
<SafeAreaView>
<View style={styles.modalInner}>
{examples.map((example, index) => (
<Button
key={example.label}
title={example.label}
onPress={() =>
this.setState({
currentExampleIndex: index,
showChangeExampleModal: false,
})
}
/>
))}
</View>
</SafeAreaView>
</View>
</TouchableWithoutFeedback>
</Modal>
);
}
}
const styles = StyleSheet.create({
modalScrim: {
flex: 1,
backgroundColor: '#00000080',
},
flex1: {
flex: 1,
},
modalInner: {
margin: 20,
backgroundColor: '#fff',
},
});