in TestApp/app/screens/CrashesScreen.js [104:216]
render() {
const switchRenderItem = ({ item: { title, value, toggle } }) => (
<View style={SharedStyles.item}>
<Text style={SharedStyles.itemTitle}>{title}</Text>
<Switch value={this.state[value]} onValueChange={toggle} />
</View>
);
const valueRenderItem = ({ item: { title, value, onChange } }) => {
if (onChange) {
return (
<View style={SharedStyles.item}>
<Text style={SharedStyles.itemTitle}>{title}</Text>
<TextInput style={SharedStyles.underlinedItemInput} onChangeText={onChange}>{this.state[value]}</TextInput>
</View>);
}
return (
<View style={SharedStyles.item}>
<Text style={SharedStyles.itemTitle}>{title}</Text>
<Text>{this.state[value]}</Text>
</View>);
};
const actionRenderItem = ({ item: { title, action } }) => (
<TouchableOpacity style={SharedStyles.item} onPress={action}>
<Text style={SharedStyles.itemButton}>{title}</Text>
</TouchableOpacity>
);
return (
<View style={SharedStyles.container}>
<SectionList
renderItem={({ item }) => <Text style={[SharedStyles.item, SharedStyles.itemTitle]}>{item}</Text>}
renderSectionHeader={({ section: { title } }) => <Text style={SharedStyles.header}>{title}</Text>}
keyExtractor={(item, index) => item + index}
sections={[
{
title: 'Settings',
data: [
{
title: 'Crashes Enabled',
value: 'crashesEnabled',
toggle: async () => {
await Crashes.setEnabled(!this.state.crashesEnabled);
const crashesEnabled = await Crashes.isEnabled();
this.setState({ crashesEnabled });
}
},
],
renderItem: switchRenderItem
},
{
title: 'Actions',
data: [
{
title: 'Crash JavaScript',
action: this.jsCrash
},
{
title: 'Crash native code',
action: this.nativeCrash
},
{
title: 'Generate low memory warning',
action: this.generateLowMemoryWarning
},
{
title: 'Generate low memory warning from native code',
action: this.generateNativeLowMemoryWarning
},
{
title: 'Select image as binary error attachment',
action: this.showFilePicker
},
],
renderItem: actionRenderItem
},
{
title: 'Track error',
data: [
{
title: 'Track error',
action: () => this.trackError(false)
},
{
title: 'Track error with properties',
action: () => this.trackError(true)
},
],
renderItem: actionRenderItem
},
{
title: 'Miscellaneous',
data: [
{ title: 'Last session status', value: 'lastSessionStatus' },
{ title: 'Memory warning', value: 'memoryWarning' },
{ title: 'Binary attachment', value: 'binaryAttachment' },
{
title: 'Text attachment',
value: 'textAttachment',
onChange: (textAttachment) => {
this.setState({ textAttachment });
AttachmentsProvider.saveTextAttachment(textAttachment);
}
}
],
renderItem: valueRenderItem
},
]}
/>
</View>
);
}