...
 
Commits (5)
import 'react-native';
import React from 'react';
import { Platform, CameraRoll, TouchableOpacity } from "react-native";
import { shallow } from 'enzyme';
import CaptureGallery from '../../src/capture/CaptureGallery';
import { shallow, render } from 'enzyme';
import androidPermission from '../../src/common/services/android-permissions.service';
import { getPhotosFaker } from '../../__mocks__/fake/CameraRollFaker';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
jest.mock('../../src/common/services/android-permissions.service');
//jest.mock('TouchableOpacity', () => 'TouchableOpacity' )
jest.mock('CameraRoll');
CameraRoll.getPhotos = jest.fn();
// fake camera roll data
const response = getPhotosFaker(5);
CameraRoll.getPhotos.mockResolvedValue(response);
import CaptureGallery from '../../src/capture/CaptureGallery';
/**
* Tests
*/
describe('cature gallery component', () => {
beforeEach(() => {
CameraRoll.getPhotos.mockClear();
androidPermission.checkReadExternalStorage.mockClear();
androidPermission.readExternalStorage.mockClear();
});
it('should renders correctly', () => {
it('should renders correctly', async() => {
const galley = renderer.create(
<CaptureGallery />
<CaptureGallery />
).toJSON();
expect(galley).toMatchSnapshot();
});
it('should load photos on mount', () => {
const spyWillMount = jest.spyOn(CaptureGallery.prototype, '_loadPhotos');
const spyWillMount = jest.spyOn(CaptureGallery.prototype, 'loadPhotos');
Platform.OS = 'ios';
......@@ -35,7 +42,6 @@ describe('cature gallery component', () => {
<CaptureGallery />
);
// the call is dalayed (setTimeout) so we fast-forward timers
jest.runAllTimers();
......@@ -78,30 +84,20 @@ describe('cature gallery component', () => {
it('should calls onSelected when the user select an image', async(done) => {
// fake camera roll data
const response = getPhotosFaker(5);
CameraRoll.getPhotos = jest.fn();
CameraRoll.getPhotos.mockResolvedValue(response);
const mockFn = jest.fn();
try {
const wrapper = shallow(
<CaptureGallery onSelected={mockFn}/>
);
const wrapper = renderer.create(<CaptureGallery onSelected={mockFn}/>);
// load phoyos
await wrapper.instance()._loadPhotos();
await wrapper.getInstance()._loadPhotos();
// update component
wrapper.update();
expect( CameraRoll.getPhotos).toBeCalled();
// find TouchableOpacity (rendered images in lists)
const images = wrapper.find(TouchableOpacity);
const images = wrapper.root.findAllByType(TouchableOpacity);
// simulate press on image
images.at(1).simulate('press');
images[0].props.onPress();
// expect fn to be called once
expect(mockFn).toBeCalled();
......@@ -112,27 +108,16 @@ describe('cature gallery component', () => {
});
it('should show loaded images', async(done) => {
// fake camera roll data
const response = getPhotosFaker(5);
CameraRoll.getPhotos = jest.fn();
CameraRoll.getPhotos.mockResolvedValue(response);
const mockFn = jest.fn();
try {
const wrapper = shallow(
<CaptureGallery onSelected={mockFn}/>
);
const wrapper = renderer.create(<CaptureGallery onSelected={mockFn}/>);
// load phoyos
await wrapper.instance()._loadPhotos();
// update component
wrapper.update();
await wrapper.getInstance()._loadPhotos();
// find TouchableOpacity (rendered images in lists)
const images = wrapper.find(TouchableOpacity);
const images = wrapper.root.findAllByType(TouchableOpacity);
// expect 5 images rendered
expect(images.length).toEqual(5);
......
import 'react-native';
import React from 'react';
import { Alert } from 'react-native';
import { Alert, CameraRoll } from 'react-native';
import { shallow } from 'enzyme';
import { Icon } from 'react-native-elements'
import CapturePoster from '../../src/capture/CapturePoster';
import CapturePreview from '../../src/capture/CapturePreview';
import CaptureGallery from '../../src/capture/CaptureGallery';
import UserStore from '../../src/auth/UserStore';
import CaptureStore from '../../src/capture/CaptureStore';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
import { getPhotosFaker } from '../../__mocks__/fake/CameraRollFaker';
jest.mock('../../src/auth/UserStore');
jest.mock('../../src/capture/CaptureStore');
jest.mock('../../src/capture/CapturePostButton', () => 'CapturePostButton');
jest.mock('../../src/capture/CapturePosterFlags', () => 'CapturePosterFlags');
jest.mock('../../src/capture/CapturePreview', () => 'CapturePreview');
jest.mock('../../src/capture/CapturePosterFlags', () => 'CapturePosterFlags');
jest.mock('../../src/common/services/translation.service');
Alert.alert = jest.fn();
jest.mock('CameraRoll');
CameraRoll.getPhotos = jest.fn();
// fake camera roll data
const response = getPhotosFaker(5);
CameraRoll.getPhotos.mockResolvedValue(response);
/**
* Tests
......@@ -43,14 +50,15 @@ describe('cature poster component', () => {
});
it('should renders correctly', () => {
const galley = renderer.create(
const screen = renderer.create(
<CapturePoster.wrappedComponent
user={userStore}
capture={capture}
navigation={navigation}
/>
).toJSON();
expect(galley).toMatchSnapshot();
expect(screen).toMatchSnapshot();
});
it('should receive text parameters on did mount', () => {
......@@ -118,8 +126,12 @@ describe('cature poster component', () => {
it('should show the preview when an image is attached', async (done) => {
try {
// emulate image attachment
capture.attachment.hasAttachment = true;
capture.attachment.uri = paramsImage.uri;
capture.attachment.type = paramsImage.type;
const wrapper = shallow(
const wrapper = renderer.create(
<CapturePoster.wrappedComponent
user={userStore}
capture={capture}
......@@ -127,18 +139,14 @@ describe('cature poster component', () => {
/>
);
// emulate image attachment
capture.attachment.hasAttachment = true;
capture.attachment.uri = paramsImage.uri;
capture.attachment.type = paramsImage.type;
const gallery = wrapper.root.findByType(CaptureGallery);
// update component
wrapper.update();
await gallery.instance._loadPhotos();
// find Capture Preview
const preview = wrapper.find(CapturePreview);
const preview = wrapper.root.findByType(CapturePreview);
expect(preview.length).toBe(1);
expect(preview).toBeDefined();
done();
} catch (e) {
......@@ -148,8 +156,12 @@ describe('cature poster component', () => {
it('should show the preview when a video is attached', async (done) => {
try {
// emulate video attachment
capture.attachment.hasAttachment = true;
capture.attachment.uri = paramsVideo.uri;
capture.attachment.type = paramsVideo.type;
const wrapper = shallow(
const wrapper = renderer.create(
<CapturePoster.wrappedComponent
user={userStore}
capture={capture}
......@@ -157,18 +169,14 @@ describe('cature poster component', () => {
/>
);
// emulate video attachment
capture.attachment.hasAttachment = true;
capture.attachment.uri = paramsVideo.uri;
capture.attachment.type = paramsVideo.type;
const gallery = wrapper.root.findByType(CaptureGallery);
// update component
wrapper.update();
await gallery.instance._loadPhotos();
// find Capture Preview
const preview = wrapper.find(CapturePreview);
const preview = wrapper.root.findByType(CapturePreview);
expect(preview.length).toBe(1);
expect(preview).toBeDefined();
done();
} catch (e) {
......@@ -184,7 +192,7 @@ describe('cature poster component', () => {
capture.attachment.uri = paramsVideo.uri;
capture.attachment.type = paramsVideo.type;
const wrapper = shallow(
const wrapper = renderer.create(
<CapturePoster.wrappedComponent
user={userStore}
capture={capture}
......@@ -192,13 +200,17 @@ describe('cature poster component', () => {
/>
);
const gallery = wrapper.root.findByType(CaptureGallery);
await gallery.instance._loadPhotos();
// find delete icon
const icon = wrapper.find(Icon);
const icon = wrapper.root.findByType(Icon);
expect(icon.length).toBe(1);
expect(icon).toBeDefined();
// simulate press on image
icon.at(0).simulate('press');
icon.props.onPress();
// should be called
expect(capture.attachment.delete).toHaveBeenCalled();
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`cature gallery component should renders correctly 1`] = `
<View>
<View
style={
Object {
"flex": 1,
}
<View
style={
Object {
"alignItems": "center",
"backgroundColor": "white",
"flex": 1,
"justifyContent": "center",
"minHeight": 100,
}
>
<View
style={
Object {
"height": 125,
}
}
>
<View
style={
Object {
"flex": 1,
"flexDirection": "row",
"paddingLeft": 1,
"paddingRight": 1,
}
}
>
<View
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"alignContent": "center",
"alignItems": "center",
"backgroundColor": "#FFF",
"borderColor": "#ECECEC",
"borderWidth": 1,
"flex": 1,
"flexDirection": "column",
"justifyContent": "center",
"margin": 1,
}
}
>
<View
style={
Object {
"alignContent": "center",
"alignItems": "center",
"flexDirection": "column",
"justifyContent": "center",
}
}
>
<Text
allowFontScaling={false}
style={
Array [
Object {
"color": undefined,
"fontSize": 36,
},
Object {
"color": "#444",
},
Object {
"fontFamily": "Ionicons",
"fontStyle": "normal",
"fontWeight": "normal",
},
Object {},
]
}
>
</Text>
<Text
style={
Object {
"color": "#444",
"letterSpacing": 1.25,
}
}
>
Gallery
</Text>
</View>
</View>
<View
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"alignContent": "center",
"alignItems": "center",
"backgroundColor": "#FFF",
"borderColor": "#ECECEC",
"borderWidth": 1,
"flex": 1,
"flexDirection": "column",
"justifyContent": "center",
"margin": 1,
}
}
>
<View
style={
Object {
"alignContent": "center",
"alignItems": "center",
"flexDirection": "column",
"justifyContent": "center",
}
}
>
<Text
allowFontScaling={false}
style={
Array [
Object {
"color": undefined,
"fontSize": 36,
},
Object {
"color": "#444",
},
Object {
"fontFamily": "Ionicons",
"fontStyle": "normal",
"fontWeight": "normal",
},
Object {},
]
}
>
</Text>
<Text
style={
Object {
"color": "#444",
"letterSpacing": 1.25,
}
}
>
Photo
</Text>
</View>
</View>
<View
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"alignContent": "center",
"alignItems": "center",
"backgroundColor": "#FFF",
"borderColor": "#ECECEC",
"borderWidth": 1,
"flex": 1,
"flexDirection": "column",
"justifyContent": "center",
"margin": 1,
}
}
>
<View
style={
Object {
"alignContent": "center",
"alignItems": "center",
"flexDirection": "column",
"justifyContent": "center",
}
}
>
<Text
allowFontScaling={false}
style={
Array [
Object {
"color": undefined,
"fontSize": 36,
},
Object {
"color": "#444",
},
Object {
"fontFamily": "Ionicons",
"fontStyle": "normal",
"fontWeight": "normal",
},
Object {},
]
}
>
</Text>
<Text
style={
Object {
"color": "#444",
"letterSpacing": 1.25,
}
}
>
Video
</Text>
</View>
</View>
</View>
</View>
</View>
<View
style={
Object {
"alignItems": "center",
"backgroundColor": "white",
"flex": 1,
"justifyContent": "center",
"minHeight": 100,
}
}
>
<ActivityIndicator
animating={true}
color="#999999"
hidesWhenStopped={true}
size="large"
/>
</View>
}
>
<ActivityIndicator
animating={true}
color="#999999"
hidesWhenStopped={true}
size="large"
/>
</View>
`;
......@@ -8,316 +8,23 @@ exports[`cature poster component should renders correctly 1`] = `
}
}
>
<RCTScrollView
keyboardShouldPersistTaps="always"
<View
style={
Object {
"alignItems": "center",
"backgroundColor": "white",
"flex": 1,
"justifyContent": "center",
"minHeight": 100,
}
}
>
<View>
<View
pointerEvents="box-none"
style={
Object {
"backgroundColor": "#FFF",
"flexDirection": "row",
"minHeight": 100,
}
}
>
<TextInput
allowFontScaling={true}
editable={false}
multiline={true}
onChangeText={[Function]}
onSelectionChange={[Function]}
placeholder="Speak your mind..."
placeholderTextColor="#ccc"
rejectResponderTermination={true}
selectTextOnFocus={false}
style={
Object {
"flex": 1,
"padding": 12,
"paddingTop": 24,
}
}
testID="PostInput"
underlineColorAndroid="transparent"
value=""
/>
</View>
<CapturePosterFlags
containerStyle={
Array [
Object {
"flexDirection": "row",
"justifyContent": "flex-end",
},
]
}
hideShare={true}
lockValue={null}
matureValue={false}
nsfwValue={Array []}
onLocking={[Function]}
onMature={[Function]}
onNsfw={[Function]}
onShare={[Function]}
shareValue={Object {}}
/>
<View>
<View
style={
Object {
"flex": 1,
}
}
>
<View
style={
Object {
"height": 125,
}
}
>
<View
style={
Object {
"flex": 1,
"flexDirection": "row",
"paddingLeft": 1,
"paddingRight": 1,
}
}
>
<View
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"alignContent": "center",
"alignItems": "center",
"backgroundColor": "#FFF",
"borderColor": "#ECECEC",
"borderWidth": 1,
"flex": 1,
"flexDirection": "column",
"justifyContent": "center",
"margin": 1,
}
}
>
<View
style={
Object {
"alignContent": "center",
"alignItems": "center",
"flexDirection": "column",
"justifyContent": "center",
}
}
>
<Text
allowFontScaling={false}
style={
Array [
Object {
"color": undefined,
"fontSize": 36,
},
Object {
"color": "#444",
},
Object {
"fontFamily": "Ionicons",
"fontStyle": "normal",
"fontWeight": "normal",
},
Object {},
]
}
>
</Text>
<Text
style={
Object {
"color": "#444",
"letterSpacing": 1.25,
}
}
>
Gallery
</Text>
</View>
</View>
<View
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"alignContent": "center",
"alignItems": "center",
"backgroundColor": "#FFF",
"borderColor": "#ECECEC",
"borderWidth": 1,
"flex": 1,
"flexDirection": "column",
"justifyContent": "center",
"margin": 1,
}
}
>
<View
style={
Object {
"alignContent": "center",
"alignItems": "center",
"flexDirection": "column",
"justifyContent": "center",
}
}
>
<Text
allowFontScaling={false}
style={
Array [
Object {
"color": undefined,
"fontSize": 36,
},
Object {
"color": "#444",
},
Object {
"fontFamily": "Ionicons",
"fontStyle": "normal",
"fontWeight": "normal",
},
Object {},
]
}
>
</Text>
<Text
style={
Object {
"color": "#444",
"letterSpacing": 1.25,
}
}
>
Photo
</Text>
</View>
</View>
<View
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"alignContent": "center",
"alignItems": "center",
"backgroundColor": "#FFF",
"borderColor": "#ECECEC",
"borderWidth": 1,
"flex": 1,
"flexDirection": "column",
"justifyContent": "center",
"margin": 1,
}
}
>
<View
style={
Object {
"alignContent": "center",
"alignItems": "center",
"flexDirection": "column",
"justifyContent": "center",
}
}
>
<Text
allowFontScaling={false}
style={
Array [
Object {
"color": undefined,
"fontSize": 36,
},
Object {
"color": "#444",
},
Object {
"fontFamily": "Ionicons",
"fontStyle": "normal",
"fontWeight": "normal",
},
Object {},
]
}
>
</Text>
<Text
style={
Object {
"color": "#444",
"letterSpacing": 1.25,
}
}
>
Video
</Text>
</View>
</View>
</View>
</View>
</View>
<View
style={
Object {
"alignItems": "center",
"backgroundColor": "white",
"flex": 1,
"justifyContent": "center",
"minHeight": 100,
}
}
>
<ActivityIndicator
animating={true}
color="#999999"
hidesWhenStopped={true}
size="large"
/>
</View>
</View>
</View>
</RCTScrollView>
<ActivityIndicator
animating={true}
color="#999999"
hidesWhenStopped={true}
size="large"
/>
</View>
</View>
`;
import _ from 'lodash';
import React, {
PureComponent
} from 'react';
import {
Text,
StyleSheet,
CameraRoll,
ActivityIndicator,
TouchableOpacity,
InteractionManager,
Image,
View,
FlatList,
......@@ -21,7 +16,6 @@ import Icon from 'react-native-vector-icons/Ionicons';
import { Button } from 'react-native-elements';
import CenteredLoading from '../common/components/CenteredLoading'
import CaptureTabs from './CaptureTabs';
import androidPermissionsService from '../common/services/android-permissions.service';
import testID from '../common/helpers/testID';
import logService from '../common/services/log.service';
......@@ -31,12 +25,14 @@ import logService from '../common/services/log.service';
*/
export default class CaptureGallery extends PureComponent {
listRef = null;
state = {
header: null,
photos: [],
imageUri: '',
isPosting: false,
imagesLoaded: false,
offset: '',
hasMore: true,
loading: false
}
static navigationOptions = {
......@@ -64,26 +60,36 @@ export default class CaptureGallery extends PureComponent {
/**
* Load photos
*/
_loadPhotos() {
_loadPhotos = async() => {
if (this.state.loading || !this.state.hasMore) {
return;
}
const params = {
first: 30,
assetType: 'All',
}
this.setState({loading: true});
if (Platform.OS === 'ios') params.groupTypes = 'All';
if (this.state.offset) params.after = this.state.offset;
try {
const result = await CameraRoll.getPhotos(params);
CameraRoll.getPhotos(params)
.then(r => {
this.setState({
imagesLoaded: true,
photos: r.edges,
navigation: r.page_info,
});
})
.catch((err) => {
logService.exception('[CaptureGallery] loadPhotos', err)
//Error Loading Images
this.setState({
imagesLoaded: true,
photos: this.state.photos.concat(result.edges),
offset: result.page_info.end_cursor,
hasMore: result.page_info.has_next_page,
loading: false
});
} catch (err) {
logService.exception('[CaptureGallery] loadPhotos', err)
this.setState({loading: false});
}
}
/**
......@@ -100,28 +106,37 @@ export default class CaptureGallery extends PureComponent {
*/
render() {
const body = this.state.imagesLoaded ?
_.chunk(this.state.photos.map((p, i) => this.renderTile(p, i)), 3)
.map((c, i) => <View style={styles.row} key={i}>{c}</View>)
: <CenteredLoading />
if (!this.state.imagesLoaded) {
return <CenteredLoading />
}
return (
<View>
<CaptureTabs onSelectedMedia={this.onSelected} />
{body}
</View>
<FlatList
ref={this.setListRef}
ListHeaderComponent={this.props.header}
data={this.state.photos}
renderItem={this.renderTile}
onEndReached={this._loadPhotos}
ListFooterComponent={this.state.loading ? <CenteredLoading /> : null}
numColumns={3}
/>
)
}
/**
* Sets List reference
*/
setListRef = ref => this.listRef = ref;
/**
* render list tile
*/
renderTile = (item, index) => {
const node = item.node;
renderTile = (item) => {
const node = item.item.node;
return (
<TouchableOpacity
style={styles.tileImage}
key={index}
key={item.index}
onPress={() => {
this.onSelected({
uri: node.image.uri,
......@@ -142,7 +157,13 @@ export default class CaptureGallery extends PureComponent {
);
}
/**
* On media selected
*/
onSelected = (response) => {
// scroll to top on selection
this.listRef.scrollToOffset({x: 0, y: 0, animated: true});
this.props.onSelected(response);
}
......
......@@ -4,11 +4,7 @@ import {
View,
ScrollView,
Text,
Alert,
Button,
TouchableHighlight,
TouchableOpacity,
ActivityIndicator
Alert
} from 'react-native';
import { observer, inject } from 'mobx-react/native';
......@@ -37,6 +33,7 @@ import testID from '../common/helpers/testID';
import logService from '../common/services/log.service';
import i18n from '../common/services/i18n.service';
import settingsStore from '../settings/SettingsStore';
import CaptureTabs from './CaptureTabs';
// workaround for android copy/paste
import TextInput from '../common/components/TextInput';
......@@ -105,6 +102,9 @@ export default class CapturePoster extends Component {
this.loadNsfwFromPersistentStorage();
}
/**
* Load last saved nsfw values
*/
async loadNsfwFromPersistentStorage() {
this.setState({
nsfw: settingsStore.creatorNsfw,
......@@ -164,10 +164,71 @@ export default class CapturePoster extends Component {
this.setState({selection: event.nativeEvent.selection});
}
/**
* Get header
*
* @param {boolean} showAttachmentFeatures
*/
getHeader(showAttachmentFeatures = false) {
return (
<React.Fragment>
{this.showContext()}
<View style={styles.posterWrapper}>
<TextInput
style={styles.poster}
editable={true}
placeholder={i18n.t('capture.placeholder')}
placeholderTextColor='#ccc'
underlineColorAndroid='transparent'
onChangeText={this.setText}
value={this.state.text}
multiline={true}
selectTextOnFocus={false}
onSelectionChange={this.onSelectionChanges}
{...testID('PostInput')}
/>
</View>
{showAttachmentFeatures && this.getAttachFeature()}
</React.Fragment>
)
}
/**
* Render
*/
render() {
const params = this.props.navigation.state.params || {};
return params.isRemind ? this.renderRemind() : this.renderNormal();
}
/**
* Screen content for poster
*/
renderNormal() {
const navigation = this.props.navigation;
const params = navigation.state.params || {};
return (
<View style={CS.flexContainer}>
<CaptureGallery
onSelected={this.onAttachedMedia}
header={this.getHeader(true)}
/>
<UserAutocomplete
text={this.props.capture.text}
selection={this.state.selection}
onSelect={this.onSelectTag}
/>
</View>
);
}
/**
* Screen content for remind
*/
renderRemind() {
const text = this.props.capture.text;
const navigation = this.props.navigation;
......@@ -175,24 +236,9 @@ export default class CapturePoster extends Component {
return (
<View style={CS.flexContainer}>
<ScrollView style={styles.posterAndPreviewWrapper} keyboardShouldPersistTaps={'always'}>
{this.showContext()}
<View style={styles.posterWrapper} pointerEvents="box-none">
<TextInput
style={styles.poster}
editable={true}
placeholder={i18n.t('capture.placeholder')}
placeholderTextColor='#ccc'
underlineColorAndroid='transparent'
onChangeText={this.setText}
value={text}
multiline={true}
selectTextOnFocus={false}
onSelectionChange={this.onSelectionChanges}
{...testID('PostInput')}
/>
</View>
{!params.isRemind ? this.getAttachFeature() : this.getRemind()}
<ScrollView style={styles.posterAndPreviewWrapper} keyboardShouldPersistTaps={'always'} removeClippedSubviews={false}>
{this.getHeader()}
{this.getRemind()}
</ScrollView>
<UserAutocomplete
text={text}
......@@ -245,10 +291,7 @@ export default class CapturePoster extends Component {
/>
<Icon raised name="md-close" type="ionicon" color='#fff' size={22} containerStyle={styles.deleteAttachment} onPress={() => this.deleteAttachment()} {...testID('Attachment Delete Button')} />
</View>}
<CaptureGallery
onSelected={this.onAttachedMedia}
/>
<CaptureTabs onSelectedMedia={this.onAttachedMedia} />
</React.Fragment>
);
}
......@@ -285,6 +328,9 @@ export default class CapturePoster extends Component {
}
}
/**
* Create a remind
*/
async remind() {
const { params } = this.props.navigation.state;
const message = this.props.capture.text;
......@@ -312,7 +358,7 @@ export default class CapturePoster extends Component {
}
/**
* Submit
* Submit post
*/
async submit() {
const attachment = this.props.capture.attachment;
......@@ -402,16 +448,26 @@ export default class CapturePoster extends Component {
}
}
/**
* Set text
* @param {string} text
*/
setText = (text) => {
this.props.capture.setText(text);
this.props.capture.embed.richEmbedCheck(text);
};
/**
* On mature value change
*/
onMature = () => {
const mature = !this.state.mature;
this.setState({ mature });
}
/**
* On nsfw value change
*/
onNsfw = values => {
const nsfw = [...values];
this.setState({ nsfw });
......