import {countTools} from "@yoronsoft/js-utils"; import * as React from "react"; import {ColorValue, StyleSheet} from "react-native"; import app, {ThemeCss} from "../../app"; import BasicView from "../view"; import BasicText from "../text"; type IProps = { readonly width: number height?: number borderRadius?: number bg?: ColorValue selectBg?: ColorValue isProgress?: boolean progress: number progressColor?: ColorValue progressSize?: number isText?: boolean text?: string textColor?: ColorValue textSize?: number } const BasicProgress: React.FC = (props) => { const css = app.theme.useGet(); const styles = styleSheet(css); const width = countTools.multipliedBy(props.width, props.progress > 0 ? (Number(props.progress) / 100) : 0.01); const height = props.height ?? 4; const borderRadius = typeof props.borderRadius === "number" ? props.borderRadius : 2; const bg = props.bg ?? css.app.bg; const selectBg = props.selectBg ?? css.main; const isProgress = props.isProgress ?? false; const progressColor = props.progressColor ?? css.color.white; const progressSize = props.progressSize ?? 14; const isText = props.isText ?? false; const text = props.text; const textColor = props.textColor ?? css.font.color; const textSize = props.textSize ?? 14; return { isProgress && props.progress > 0 ? { isProgress ? : undefined } : isText ? : undefined } } const styleSheet = (css: ThemeCss) => StyleSheet.create({ view: { overflow: 'hidden', }, progress: { borderWidth: 0.5, borderColor: css.main, backgroundColor: css.main, }, }); export default BasicProgress