更新时间:2022-01-06 02:48:21
选择时间
显示倒计时
countdownSubpage组件,用来设置和显示倒计时,可以通过路由参数传递属性
| 字段名 | 类型 | 描述 | 默认值 |
|---|---|---|---|
| countdown | number | 当前倒计时剩余时间(秒) | 空 |
| renderHeader | () => ReactNode | 头部内容 | 空 |
| onCountdownText | string | 开灯倒计时文本 | 空 |
| offCountdownText | string | 关灯倒计时文本 | 空 |
| onSave | (time: number)=>void | 点击确认按钮回调函数 | 空 |
| background | string | 页面背景颜色 | 空 |
| hourLabel | string | 小时文本 | 空 |
| minuteLabel | string | 分钟文本 | 空 |
| secondLabel | string | 秒钟文本 | 空 |
| confirmButtonStyle | StyleProp |
确认按钮样式 | 空 |
| confirmText | string | 确认文本 | 空 |
| confirmTextStyle | StyleProp |
确认文本样式 | 空 |
| cancelButtonStyle | StyleProp |
取消按钮样式 | 空 |
| cancelText | string | 取消文本 | 空 |
| cancelTextStyle | StyleProp |
取消文本样式 | 空 |
| clock | ClockProps | clock属性 | 空 |
| picker | PickerProps | picker属性 | 空 |
| 字段名 | 类型 | 描述 | 默认值 |
|---|---|---|---|
| countdown | number | 当前倒计时剩余时间(秒) | 空 |
| totalCountDown | number | 总倒计时 | 空 |
| hourLabel | string | 小时文本 | 空 |
| minuteLabel | string | 分钟文本 | 空 |
| secondLabel | string | 秒钟文本 | 空 |
| subTitleStyle: | StyleProp |
子标题文本样式 | 空 |
| onReset | ()=>void | 重置倒计时回调事件 | 空 |
| onCancel | () => void | 取消倒计时回调事件 | 空 |
| innerBackgroundColor | string | clock圈内背景色 | 空 |
| isShowHour | boolean | 当倒计时小于一小时,clock中是否显示小时数 | 空 |
| timeTextStyle | StyleProp |
时间文本样式 | 空 |
| unitTextStyle | StyleProp |
时分秒文本样式 | 空 |
| lineColor | string | 已消耗指针的颜色 | 空 |
| activeColor | string | 剩余指针的颜色 | 空 |
| lineHeight | number | clock外圈指针高度 | 空 |
| lineNum | number | clock外圈指针书数量 | 空 |
| resetText | string | 重置文本 | 空 |
| resetStyle | StyleProp |
重置样式 | 空 |
| resetTextStyle | StyleProp |
重置文本样式 | 空 |
| size: | number | clock大小 | 空 |
| 字段名 | 类型 | 描述 | 默认值 |
|---|---|---|---|
| hourLabel | string | 小时文本 | 空 |
| minuteLabel | string | 分钟文本 | 空 |
| secondLabel | string | 秒钟文本 | 空 |
| timeTextColor | string | 时间文本颜色 | 空 |
| timeTextSize | number | 时间文本字体大小 | 空 |
| unitTextStyle | StyleProp |
时间单位文本字体大小 | 空 |
| time | number | 时间 | 空 |
| isShowSecond | boolean | 是否显示秒 | 空 |
| onChange | (value: number) => void | 时间选择器改变回调 | 空 |
import React from 'react';
import { Utils } from 'tuya-panel-kit';
import { CountdownSubPage } from '@tuya/tuya-panel-lamp-sdk';
import Strings from '../../../i18n';
const { winWidth, convertX } = Utils.RatioUtils;
const cx = (value: number) => {
return Math.floor(convertX(value));
};
const CountdownSubPageDemo = () => {
const params = {
background: '#fff',
countdown: 100,
minuteLabel: Strings.getLang('TYLamp_minute'),
secondLabel: Strings.getLang('TYLamp_second'),
hourLabel: Strings.getLang('TYLamp_hour'),
onSave: (time: number) => {},
onCountdownText: Strings.getLang('TYLamp_onCountdown'),
offCountdownText: Strings.getLang('TYLamp_offCountdown'),
confirmText: Strings.getLang('TYLamp_confirm'),
confirmButtonStyle: {
backgroundColor: '#87cefa',
height: 48,
width: winWidth - cx(32),
paddingHorizontal: cx(16),
borderRadius: 24,
alignItems: 'center',
justifyContent: 'center',
marginBottom: cx(16),
marginHorizontal: cx(16),
},
confirmTextStyle: {
color: '#fff',
fontSize: 16,
},
cancelButtonStyle: {
marginHorizontal: cx(16),
height: 48,
width: winWidth - cx(32),
borderRadius: 24,
backgroundColor: '#333',
marginBottom: cx(16),
alignItems: 'center',
justifyContent: 'center',
},
cancelText: Strings.getLang('TYLamp_cancel'),
cancelTextStyle: {
color: '#fff',
fontSize: 16,
},
picker: {
time: 250,
isShowSecond: false,
unitTextStyle: { fontSize: 14, color: 'rgba(255,255,255,0.5)' },
timeTextColor: '#333',
timeTextSize: 40,
minuteLabel: Strings.getLang('TYLamp_minute'),
secondLabel: Strings.getLang('TYLamp_second'),
hourLabel: Strings.getLang('TYLamp_hour'),
},
clock: {
countdown: 200,
totalCountDown: 200,
minuteLabel: Strings.getLang('TYLamp_minute'),
secondLabel: Strings.getLang('TYLamp_second'),
hourLabel: Strings.getLang('TYLamp_hour'),
timeTextStyle: { fontSize: 40, color: '#000' },
unitTextStyle: { fontSize: 14, color: 'rgba(255,255,255,0.5)' },
lineColor: '#e3e3e3',
activeColor: '#87cefa',
innerBackgroundColor: 'rgba(255,255,255,0.85)',
isShowHour: false,
size: 280,
lineHeight: 5,
lineWidth: 1,
lineNum: 100,
resetStyle: {},
resetText: Strings.getLang('TYLamp_resetCountdown'),
resetTextStyle: {
color: '#888',
},
onReset: () => {},
onCancel: () => {},
},
};
return (
<CountdownSubPage
route={{
params,
}}
/>
);
};
export default CountdownSubPageDemo;
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈