Last Updated on : 2025-07-29 03:05:04download
TimerPicker is a time period selection component that supports selection of start time and end time.
Note: for more information, see Demo.
import React, { Component } from "react";
 import { View, StyleSheet } from "react-native";
 import { TimerPicker } from "tuya-panel-kit";
 
export default class TimerPickerScene extends Component {
  state = {
    startTime: 0,
    endTime: 0,
  };
 
 _handleTimerChange = (startTime, endTime) => {
    this.setState({ startTime, endTime });
  };
 
 render() {
    return (
      <View style={styles.container}>
        <TimerPicker
          title="Time period selection"
          cancelText="Cancel"
          confirmText="Confirm"
          startTime={this.state.startTime}
          endTime={this.state.endTime}
          is12Hours={true}
          onTimerChange={this._handleTimerChange}
        />
      </View>
    );
  }
 }
 
const styles = StyleSheet.create({
  container: {
    flex: 1,
    paddingHorizontal: 16,
  },
 });
Specify the container style to encapsulate timerPicker.
| Type | Required | 
|---|---|
| ViewPropTypes.style | No | 
The start time.
| Type | Required | Default value | 
|---|---|---|
number | 
No | 480 (in minutes, that is, 08:00) | 
The end time.
| Type | Required | Default value | 
|---|---|---|
number | 
No | 840 (in minutes, that is, 14:00) | 
The color of the selector font.
| Type | Required | Default value | 
|---|---|---|
string | 
No | #333 | 
Whether the selector supports gesture operations.
| Type | Required | Default value | 
|---|---|---|
bool | 
No | false | 
Whether to support loop scrolling of the selector.
| Type | Required | Default value | 
|---|---|---|
bool | 
No | true | 
Whether it is 12-hour system.
| Type | Required | Default value | 
|---|---|---|
bool | 
No | true | 
Whether to support the single selector only.
| Type | Required | Default value | 
|---|---|---|
bool | 
No | false | 
Prefix position, that is, the position of AM and PM.
| Type | Required | Default value | 
|---|---|---|
enum: 'left', 'right' | 
No | right | 
Callback of changing the time period. The following parameters must be entered when calling:
| Type | Required | 
|---|---|
| (startTime, endTime) => void | No | 
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback