在星期天反应本机日历禁用触摸事件
react native calendar disable touch event on sundays
嗨,我是 React Native 的新手,我正在尝试禁用星期日和今天之前的所有日期我正在使用 react-native-calendars 我设法禁用了所有星期日,但触摸事件仍然有效
有什么帮助吗?
here's the code to disable sundays
import React, {Component} from 'react';
import { isSunday } from "date-fns";
import Day from "react-native-calendars/src/calendar/day/basic";
export class CustomDay extends Component {
render() {
const { date, marking } = this.props;
marking.disabled = isSunday(date.timestamp);
return <Day {...this.props} />;
}
}
<Calendar
dayComponent={props => {
return <CustomDay {...props} />;
}}
/>
````
你能试试这个吗?
react-native-calendars
设置了默认事件。但是,当值为disabled
.
时,未指定值true
和false
import React, {Component} from 'react';
import { isSunday } from "date-fns";
import Day from "react-native-calendars/src/calendar/day/basic";
export class CustomDay extends Component {
render() {
const { date, marking } = this.props;
marking.disabled = isSunday(date.timestamp);
marking.disableTouchEvent = marking.disabled === true ? true : false
return <Day {...this.props} />;
}
}
Day
的定义
<TouchableOpacity
testID={this.props.testID}
style={containerStyle}
onPress={this.onDayPress}
onLongPress={this.onDayLongPress}
activeOpacity={marking.activeOpacity}
disabled={marking.disableTouchEvent}
>
<Text allowFontScaling={false} style={textStyle}>{String(this.props.children)}</Text>
{dot}
</TouchableOpacity>
嗨,我是 React Native 的新手,我正在尝试禁用星期日和今天之前的所有日期我正在使用 react-native-calendars 我设法禁用了所有星期日,但触摸事件仍然有效 有什么帮助吗?
here's the code to disable sundays
import React, {Component} from 'react';
import { isSunday } from "date-fns";
import Day from "react-native-calendars/src/calendar/day/basic";
export class CustomDay extends Component {
render() {
const { date, marking } = this.props;
marking.disabled = isSunday(date.timestamp);
return <Day {...this.props} />;
}
}
<Calendar
dayComponent={props => {
return <CustomDay {...props} />;
}}
/>
````
你能试试这个吗?
react-native-calendars
设置了默认事件。但是,当值为disabled
.
true
和false
import React, {Component} from 'react';
import { isSunday } from "date-fns";
import Day from "react-native-calendars/src/calendar/day/basic";
export class CustomDay extends Component {
render() {
const { date, marking } = this.props;
marking.disabled = isSunday(date.timestamp);
marking.disableTouchEvent = marking.disabled === true ? true : false
return <Day {...this.props} />;
}
}
Day
<TouchableOpacity
testID={this.props.testID}
style={containerStyle}
onPress={this.onDayPress}
onLongPress={this.onDayLongPress}
activeOpacity={marking.activeOpacity}
disabled={marking.disableTouchEvent}
>
<Text allowFontScaling={false} style={textStyle}>{String(this.props.children)}</Text>
{dot}
</TouchableOpacity>