in src/web/AlertModalContent.tsx [102:166]
render() {
const theme = this.props.theme;
const buttons = this.props.buttons && this.props.buttons.map((btnSpec, i) => {
const isCancel = btnSpec.style === 'cancel';
const buttonStyle = [_styles.defaultButton, isCancel ? _styles.defaultCancelButton : undefined];
const buttonTextStyle = [_styles.defaultBtnText, isCancel ? _styles.defaultCancelBtnText : undefined];
// Is the mouse pointer currently hovering over this button?
if (this.state.hoverIndex === i) {
buttonStyle.push(_styles.defaultButtonHover);
}
if (theme) {
buttonStyle.push(theme.buttonStyle);
buttonTextStyle.push(theme.buttonTextStyle);
if (isCancel) {
buttonStyle.push(theme.cancelButtonStyle);
buttonTextStyle.push(theme.cancelButtonTextStyle);
}
if (this.state.hoverIndex === i) {
buttonStyle.push(isCancel ? theme.cancelButtonHoverStyle : theme.buttonHoverStyle);
}
}
return (
<View key={ 'button_' + i } style={ _styles.defaultButtonContainer }>
<Button
onPress={ e => this._onPressButton(btnSpec) }
onHoverStart={ () => this.setState({ hoverIndex: i }) }
onHoverEnd={ () => this.setState({ hoverIndex: -1 }) }
style={ buttonStyle }
>
<Text style={ buttonTextStyle }>
{ btnSpec.text }
</Text>
</Button>
</View>
);
});
return (
<View style={ _styles.background } onPress={ this._onPressBackground }>
<View style={ _styles.verticalRoot }>
<View
style={ [_styles.defaultBody, theme && theme.bodyStyle] }
onPress={ this._onPressBody }
>
<View>
<Text style={ [_styles.defaultTitleText, theme && theme.titleTextStyle] }>
{ this.props.title }
</Text>
</View>
<View>
<Text style={ [_styles.defaultMessageText, theme && theme.messageTextStyle] }>
{ this.props.message }
</Text>
</View>
{ buttons }
</View>
</View>
</View>
);
}