| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- import { Button, View, Text } from "@tarojs/components";
- import './Buttons.scss'
- import { ButtonType, ComponentStatus } from "../../utils/types";
- import { Button as RNButton } from 'react-native';
- import { AtActivityIndicator } from 'taro-ui';
- import "taro-ui/dist/style/components/activity-indicator.scss";
- import 'taro-ui/dist/style/components/loading.scss';
- /*
- export default function Buttons(props: { title: string, type?: ButtonType, status?: ComponentStatus,onClick?:()=>void,style?:any }) {
-
- const myStyle = props.status == ComponentStatus.disable ? { opacity: 0.4 } : {}
- return (
- <View style={{...myStyle}}>
- <Button className={props.type == ButtonType.outline ? 'outline_btn' : 'btn'} style={{...props.style}} onClick={props.onClick}>{props.title}</Button>
- </View>
- )
- }*/
- export default function Buttons(props: {
- title: string,
- type?: ButtonType,
- className?: any,
- onClick: () => void,
- disabled?: boolean,
- lowLight?: boolean,
- openType?: string,
- btnStyle?: any,
- showLoading?: boolean,
- lightLoading?: boolean
- }) {
- function onClick(e) {
- if (process.env.TARO_ENV == 'weapp') {
- e.stopPropagation()
- }
- if (props.disabled) return
- props.onClick()
- }
- var mainClass = 'elevated'
- var textClass = 'elevated_text'
- if (props.type == ButtonType.text) {
- mainClass = 'texted'
- return <View style={{ opacity: (props.lowLight || props.disabled) ? 0.4 : 1 }} onClick={onClick}>
- <Text
- style={{
- ...props.btnStyle,
- fontWeight: 'bold',
- }} className={props.className ? props.className : ''}>{props.title}</Text>
- </View>
- }
- if (props.type == ButtonType.outline) {
- mainClass = 'outlined'
- textClass = 'outlined_text'
- return (
- <View className={mainClass} style={{ ...props.btnStyle, opacity: props.lowLight ? 0.4 : 1 }} onClick={onClick}>
- {
- props.showLoading && <View style={{ marginBottom: 2, marginRight: 5 }}>
- <AtActivityIndicator size={32} color={props.btnStyle.color} />
- </View>
- }
- <Text
- style={{
- color: props.btnStyle.color,
- fontSize: props.btnStyle.fontSize,
- fontWeight: 'bold',
- marginBottom: 2
- }}>{props.title}</Text>
- </View>
- )
- }
- // else {
- // mainClass = 'puretext'
- // textClass = 'puretext_text'
- // }
- return (
- <View className={mainClass} style={{ ...props.btnStyle, opacity: props.lowLight ? 0.4 : 1 }} onClick={onClick}>
- {
- props.showLoading && <View style={{ marginBottom: 2, marginRight: 5 }}>
- <AtActivityIndicator size={32} color={props.lightLoading ? '#999' : '#000'} />
- </View>
- }
- <Text
- // onClick={onClick}
- style={{
- color: props.btnStyle.color,
- fontSize: props.btnStyle.fontSize,
- fontWeight: 'bold',
- marginBottom: 2
- }}>{props.title}</Text>
- </View>
- // <View onClick={onClick}>
- // <Text
- // style={{
- // height: props.btnStyle.height,
- // lineHeight: props.btnStyle.height,
- // color: props.btnStyle.color,
- // fontSize: props.btnStyle.fontSize
- // }}>{props.title}</Text>
- // </View>
- )
- }
|