mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
RN: Add "Dismiss All" to YellowBox
Summary: Adds a "Dismiss All" button to YellowBox for people who see litter on the ground and continue walking. (Just kidding). public Reviewed By: vjeux Differential Revision: D2691764 fb-gh-sync-id: 9746b42bc1e5dc51f2320880f47f8cb17b952570
This commit is contained in:
parent
b86f14738e
commit
2c14ab582a
@ -122,7 +122,13 @@ const WarningRow = ({count, warning, onPress}) => {
|
||||
);
|
||||
};
|
||||
|
||||
const WarningInspector = ({count, warning, onClose, onDismiss}) => {
|
||||
const WarningInspector = ({
|
||||
count,
|
||||
warning,
|
||||
onClose,
|
||||
onDismiss,
|
||||
onDismissAll,
|
||||
}) => {
|
||||
const ScrollView = require('ScrollView');
|
||||
const Text = require('Text');
|
||||
const TouchableHighlight = require('TouchableHighlight');
|
||||
@ -151,7 +157,16 @@ const WarningInspector = ({count, warning, onClose, onDismiss}) => {
|
||||
style={styles.inspectorButton}
|
||||
underlayColor="transparent">
|
||||
<Text style={styles.inspectorButtonText}>
|
||||
Dismiss Warning
|
||||
Dismiss
|
||||
</Text>
|
||||
</TouchableHighlight>
|
||||
<TouchableHighlight
|
||||
activeOpacity={0.5}
|
||||
onPress={onDismissAll}
|
||||
style={styles.inspectorButton}
|
||||
underlayColor="transparent">
|
||||
<Text style={styles.inspectorButtonText}>
|
||||
Dismiss All
|
||||
</Text>
|
||||
</TouchableHighlight>
|
||||
</View>
|
||||
@ -175,9 +190,13 @@ class YellowBox extends React.Component {
|
||||
};
|
||||
this.dismissWarning = warning => {
|
||||
const {inspecting, warningMap} = this.state;
|
||||
warningMap.delete(warning);
|
||||
if (warning) {
|
||||
warningMap.delete(warning);
|
||||
} else {
|
||||
warningMap.clear();
|
||||
}
|
||||
this.setState({
|
||||
inspecting: inspecting === warning ? null : inspecting,
|
||||
inspecting: (warning && inspecting !== warning) ? inspecting : null,
|
||||
warningMap,
|
||||
});
|
||||
};
|
||||
@ -217,6 +236,7 @@ class YellowBox extends React.Component {
|
||||
warning={inspecting}
|
||||
onClose={() => this.setState({inspecting: null})}
|
||||
onDismiss={() => this.dismissWarning(inspecting)}
|
||||
onDismissAll={() => this.dismissWarning(null)}
|
||||
/> :
|
||||
null;
|
||||
|
||||
@ -280,11 +300,8 @@ var styles = StyleSheet.create({
|
||||
bottom: 0,
|
||||
},
|
||||
inspectorButton: {
|
||||
flex: 1,
|
||||
padding: 22,
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
},
|
||||
inspectorButtonText: {
|
||||
color: textColor,
|
||||
|
Loading…
x
Reference in New Issue
Block a user