xgfe / react-native-datepicker

react native datePicker component for both Android and IOS, useing DatePikcerAndroid, TimePickerAndroid and DatePickerIOS
MIT License
2.12k stars 725 forks source link

TimePicker is Showing But unable to retrieve the Time in the input #205

Open yarra2296 opened 6 years ago

yarra2296 commented 6 years ago

I am using TimePicker and I am not able to view the selected Time in the Input

Want to Get the Selected Time Input

Code

<TimePicker style={{width: 200}} time={this.state.time} mode="time" placeholder="select time" format='h:mm' minTime="00:00" maxTime="23:59" confirmBtnText="Confirm" cancelBtnText="Cancel" customStyles={{ dateIcon: { position: 'absolute', left: 0, top: 4, marginLeft: 0 }, dateInput: { marginLeft: 36 } // ... You can check the source to find the other keys. }} onTImeChange={(time) => {this.setState({time: time})}} />

Environment

  1. react-native -v:
  2. node -v:
  3. npm -v:
  4. yarn --version:
  5. target platform: Android | iOS
  6. operating system:
yarikgenza commented 6 years ago

The same issue ;(

RidaRidss commented 6 years ago

**

This code will change time also can show your desired time

**

import { Dimensions, Platform, StyleSheet } from "react-native";

const { width, height } = Dimensions.get("window");

const screenWidth = width < height ? width : height;

const halfScreenWidth = screenWidth / 2;

constructor(props) { super(props); this.state = { timeStart: "5:10 AM" } } <DatePicker style={{ width: halfScreenWidth, top: -2, height: 28 }} customStyles={{ btnTextConfirm: { fontFamily: Fonts.type.book, fontSize: Fonts.size.noraml, color: Colors.text.primary }, btnTextCancel: { fontFamily: Fonts.type.medium, fontSize: Fonts.size.normal, color: Colors.text.primary },

            dateIcon: {
              display: "none"
            },
            cancelStyle: {},
            dateInput: {
              borderWidth: 0,
              alignItems: "flex-start"
            },
            dateText: {
              color: Colors.text.primary,
              fontSize: Fonts.size.normal,
              fontFamily: Fonts.type.book
            }
          }}
    date={this.state.timeStart}
          mode="time"
          format="LT"
          confirmBtnText="Confirm"
          cancelBtnText="Cancel"
          showIcon={false}
          onDateChange={timeStart => {
            this.setState({ timeStart: timeStart });
          }}

/>