import { Text, View } from "@tarojs/components"; import Taro, { Component } from "@tarojs/taro"; import { BG_COLOR_LIST, SIZE, TEXT_COLOR_LIST } from "../../lib/model"; import { IProps } from "../../../@types/modal"; import { classNames } from "../../lib"; export default class ClModal extends Component { static options = { addGlobalClass: true }; state = { showModal: this.props.show }; componentWillReceiveProps(nextProps: IProps) { const show = nextProps.show; if (show !== this.state.showModal) { this.setState({ showModal: show }); } } render() { const titleBgColorClassName = this.props.titleBgColor ? BG_COLOR_LIST[this.props.titleBgColor] : ""; const actionColor = this.props.actionColor ? BG_COLOR_LIST[this.props.actionColor] : ""; const title = this.props.title; const actions = this.props.actions || []; const onClick = (index: number) => { this.props.onClick && this.props.onClick(index); }; const actionsComponent = actions.map((item, index) => ( 0 ? "solid-left" : ""} action margin-0 flex-sub`} key={"key-" + item.text} onClick={() => { onClick(index); }} > {item.text} )); const dealSize = (size: any) => { if (!size || size === "normal") return ""; else return `-${SIZE[size]}`; }; return ( { this.props.closeWithShadow && this.setState({ showModal: false }); this.props.onCancel && this.props.onCancel(); }} > { e.stopPropagation(); }} > {this.props.custom ? ( this.props.renderTitle ) : ( {title} {this.props.close ? ( { this.setState({ showModal: false }); this.props.onClose && this.props.onClose(); }} > ) : ( "" )} )} {this.props.children} {this.props.custom ? ( this.props.renderAction ) : ( {actionsComponent} )} ); } }