UNPKG

react-native-simi-comps

Version:
48 lines 2.59 kB
import React from "react"; import { Pressable } from "react-native"; import useThemeColor from "../useThemeColor"; import { usePrimaryColor } from "../PrimaryColorContext"; import Text from "./Text"; var dangerColor = "#f65555"; export default function TextButton(_a) { var text = _a.text, onPress = _a.onPress, _b = _a.type, type = _b === void 0 ? "default" : _b, bgColor = _a.bgColor, textColor = _a.textColor, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.flex, flex = _d === void 0 ? true : _d, margin = _a.margin, marginHorizontal = _a.marginHorizontal, marginVertical = _a.marginVertical, marginLeft = _a.marginLeft, marginRight = _a.marginRight; var defaultTextColor = useThemeColor("text"); var defaultBorderColor = useThemeColor("border"); var disabledTextColor = useThemeColor("disabledText"); var disabledBgColor = useThemeColor("disabledBg"); var disabledBorderColor = useThemeColor("disabledBorder"); var primaryColor = usePrimaryColor(); var backgroundColor = (bgColor !== null && bgColor !== void 0 ? bgColor : type === "primary") ? primaryColor : type === "danger" ? dangerColor : "transparent"; var borderColor = (bgColor !== null && bgColor !== void 0 ? bgColor : type === "primary") ? primaryColor : type === "danger" ? dangerColor : defaultBorderColor; var color = (textColor !== null && textColor !== void 0 ? textColor : type === "default") ? defaultTextColor : "#fff"; return (React.createElement(Pressable, { onPress: onPress, disabled: disabled, style: { flex: flex ? 1 : 0, flexShrink: flex === false ? 1 : undefined, flexGrow: flex === false ? 0 : undefined, borderWidth: 1, borderRadius: 8, paddingVertical: 8, paddingHorizontal: 16, justifyContent: "center", alignItems: "center", elevation: 0, margin: margin, marginHorizontal: marginHorizontal, marginVertical: marginVertical, marginLeft: marginLeft, marginRight: marginRight, maxHeight: 42, backgroundColor: disabled ? disabledBgColor : backgroundColor, borderColor: disabled ? disabledBorderColor : borderColor } }, React.createElement(Text, { text: text, color: disabled ? disabledTextColor : color, size: 18, bold: true, centered: true, spaced: true, numberOfLines: 1, selectable: false }))); } //# sourceMappingURL=TextButton.js.map