diff --git a/src/DateTimePickerModal.android.js b/src/DateTimePickerModal.android.js
index 3495d1b..b910452 100644
--- a/src/DateTimePickerModal.android.js
+++ b/src/DateTimePickerModal.android.js
@@ -1,6 +1,6 @@
-import React, { useEffect, useRef, useState, memo } from "react";
-import PropTypes from "prop-types";
-import DateTimePicker from "@react-native-community/datetimepicker";
+import React, { useEffect, useRef, useState, memo } from 'react';
+import PropTypes from 'prop-types';
+import DateTimePicker from '@react-native-community/datetimepicker';
// Memo workaround for https://github.com/react-native-community/datetimepicker/issues/54
const areEqual = (prevProps, nextProps) => {
@@ -17,7 +17,7 @@ const DateTimePickerModal = memo(
useEffect(() => {
if (isVisible && currentMode === null) {
- setCurrentMode(mode === "time" ? "time" : "date");
+ setCurrentMode(mode === 'time' ? 'time' : 'date');
} else if (!isVisible) {
setCurrentMode(null);
}
@@ -26,18 +26,18 @@ const DateTimePickerModal = memo(
if (!isVisible || !currentMode) return null;
const handleChange = (event, date) => {
- if (event.type === "dismissed") {
+ if (event.type === 'dismissed') {
onCancel();
onHide(false);
return;
}
let nextDate = date;
- if (mode === "datetime") {
- if (currentMode === "date") {
- setCurrentMode("time");
+ if (mode === 'datetime') {
+ if (currentMode === 'date') {
+ setCurrentMode('time');
currentDateRef.current = new Date(date);
return;
- } else if (currentMode === "time") {
+ } else if (currentMode === 'time') {
const year = currentDateRef.current.getFullYear();
const month = currentDateRef.current.getMonth();
const day = currentDateRef.current.getDate();
@@ -51,15 +51,10 @@ const DateTimePickerModal = memo(
};
return (
-
+
);
},
- areEqual
+ areEqual,
);
DateTimePickerModal.propTypes = {
diff --git a/src/DateTimePickerModal.ios.js b/src/DateTimePickerModal.ios.js
index 3f5e722..dc25da9 100644
--- a/src/DateTimePickerModal.ios.js
+++ b/src/DateTimePickerModal.ios.js
@@ -1,26 +1,20 @@
-import React from "react";
-import PropTypes from "prop-types";
-import {
- StyleSheet,
- Text,
- TouchableHighlight,
- View,
- Appearance,
-} from "react-native";
-import DateTimePicker from "@react-native-community/datetimepicker";
-import Modal from "./Modal";
-import { isIphoneX } from "./utils";
+import React from 'react';
+import PropTypes from 'prop-types';
+import { StyleSheet, Text, TouchableHighlight, View, Appearance } from 'react-native';
+import DateTimePicker from '@react-native-community/datetimepicker';
+import Modal from './Modal';
+import { isIphoneX } from './utils';
-export const BACKGROUND_COLOR_LIGHT = "white";
-export const BACKGROUND_COLOR_DARK = "#0E0E0E";
-export const BORDER_COLOR = "#d5d5d5";
-export const BORDER_COLOR_DARK = "#272729";
+export const BACKGROUND_COLOR_LIGHT = 'white';
+export const BACKGROUND_COLOR_DARK = '#0E0E0E';
+export const BORDER_COLOR = '#d5d5d5';
+export const BORDER_COLOR_DARK = '#272729';
export const BORDER_RADIUS = 13;
-export const BUTTON_FONT_WEIGHT = "normal";
-export const BUTTON_FONT_COLOR = "#007ff9";
+export const BUTTON_FONT_WEIGHT = 'normal';
+export const BUTTON_FONT_COLOR = '#007ff9';
export const BUTTON_FONT_SIZE = 20;
-export const HIGHLIGHT_COLOR_DARK = "#444444";
-export const HIGHLIGHT_COLOR_LIGHT = "#ebebeb";
+export const HIGHLIGHT_COLOR_DARK = '#444444';
+export const HIGHLIGHT_COLOR_LIGHT = '#ebebeb';
export class DateTimePickerModal extends React.PureComponent {
static propTypes = {
@@ -50,8 +44,8 @@ export class DateTimePickerModal extends React.PureComponent {
};
static defaultProps = {
- cancelTextIOS: "Cancel",
- confirmTextIOS: "Confirm",
+ cancelTextIOS: 'Cancel',
+ confirmTextIOS: 'Confirm',
modalPropsIOS: {},
date: new Date(),
isDarkModeEnabled: undefined,
@@ -126,12 +120,10 @@ export class DateTimePickerModal extends React.PureComponent {
buttonTextColorIOS,
...otherProps
} = this.props;
- const isAppearanceModuleAvailable = !!(
- Appearance && Appearance.getColorScheme
- );
+ const isAppearanceModuleAvailable = !!(Appearance && Appearance.getColorScheme);
const _isDarkModeEnabled =
isDarkModeEnabled === undefined && isAppearanceModuleAvailable
- ? Appearance.getColorScheme() === "dark"
+ ? Appearance.getColorScheme() === 'dark'
: isDarkModeEnabled || false;
const ConfirmButtonComponent = customConfirmButtonIOS || ConfirmButton;
@@ -152,27 +144,17 @@ export class DateTimePickerModal extends React.PureComponent {
backdropStyle={backdropStyleIOS}
{...modalPropsIOS}
>
-
+
{HeaderComponent && }
- {!HeaderComponent && display === "inline" && (
-
- )}
+ {!HeaderComponent && display === 'inline' && }
-
- {label}
-
+ {label}
);
};
@@ -263,9 +236,9 @@ export const ConfirmButton = ({
export const confirmButtonStyles = StyleSheet.create({
button: {
borderTopWidth: StyleSheet.hairlineWidth,
- backgroundColor: "transparent",
+ backgroundColor: 'transparent',
height: 57,
- justifyContent: "center",
+ justifyContent: 'center',
},
buttonLight: {
borderColor: BORDER_COLOR,
@@ -274,11 +247,11 @@ export const confirmButtonStyles = StyleSheet.create({
borderColor: BORDER_COLOR_DARK,
},
text: {
- textAlign: "center",
+ textAlign: 'center',
color: BUTTON_FONT_COLOR,
fontSize: BUTTON_FONT_SIZE,
fontWeight: BUTTON_FONT_WEIGHT,
- backgroundColor: "transparent",
+ backgroundColor: 'transparent',
},
});
@@ -293,9 +266,7 @@ export const CancelButton = ({
const themedButtonStyle = isDarkModeEnabled
? cancelButtonStyles.buttonDark
: cancelButtonStyles.buttonLight;
- const underlayColor = isDarkModeEnabled
- ? HIGHLIGHT_COLOR_DARK
- : HIGHLIGHT_COLOR_LIGHT;
+ const underlayColor = isDarkModeEnabled ? HIGHLIGHT_COLOR_DARK : HIGHLIGHT_COLOR_LIGHT;
return (
-
- {label}
-
+ {label}
);
};
@@ -323,7 +287,7 @@ export const cancelButtonStyles = StyleSheet.create({
borderRadius: BORDER_RADIUS,
height: 57,
marginBottom: isIphoneX() ? 20 : 0,
- justifyContent: "center",
+ justifyContent: 'center',
},
buttonLight: {
backgroundColor: BACKGROUND_COLOR_LIGHT,
@@ -333,10 +297,10 @@ export const cancelButtonStyles = StyleSheet.create({
},
text: {
padding: 10,
- textAlign: "center",
+ textAlign: 'center',
color: BUTTON_FONT_COLOR,
fontSize: BUTTON_FONT_SIZE,
- fontWeight: "600",
- backgroundColor: "transparent",
+ fontWeight: '600',
+ backgroundColor: 'transparent',
},
});
diff --git a/src/DateTimePickerModal.js b/src/DateTimePickerModal.js
index 18bd621..0bd42c3 100644
--- a/src/DateTimePickerModal.js
+++ b/src/DateTimePickerModal.js
@@ -1,5 +1,5 @@
-import React from "react";
-import { Platform } from "react-native";
+import React from 'react';
+import { Platform } from 'react-native';
export function DateTimePickerModal() {
React.useEffect(() => {
diff --git a/src/Modal.js b/src/Modal.js
index ab94984..8458c88 100644
--- a/src/Modal.js
+++ b/src/Modal.js
@@ -1,5 +1,5 @@
-import React, { Component } from "react";
-import PropTypes from "prop-types";
+import React, { Component } from 'react';
+import PropTypes from 'prop-types';
import {
Animated,
DeviceEventEmitter,
@@ -8,7 +8,7 @@ import {
Modal as ReactNativeModal,
StyleSheet,
TouchableWithoutFeedback,
-} from "react-native";
+} from 'react-native';
const MODAL_ANIM_DURATION = 300;
const MODAL_BACKDROP_OPACITY = 0.4;
@@ -29,8 +29,8 @@ export class Modal extends Component {
state = {
isVisible: this.props.isVisible,
- deviceWidth: Dimensions.get("window").width,
- deviceHeight: Dimensions.get("window").height,
+ deviceWidth: Dimensions.get('window').width,
+ deviceHeight: Dimensions.get('window').height,
};
animVal = new Animated.Value(0);
@@ -44,8 +44,8 @@ export class Modal extends Component {
this.show();
}
this._deviceEventEmitter = DeviceEventEmitter.addListener(
- "didUpdateDimensions",
- this.handleDimensionsUpdate
+ 'didUpdateDimensions',
+ this.handleDimensionsUpdate,
);
}
@@ -65,10 +65,7 @@ export class Modal extends Component {
handleDimensionsUpdate = (dimensionsUpdate) => {
const deviceWidth = dimensionsUpdate.window.width;
const deviceHeight = dimensionsUpdate.window.height;
- if (
- deviceWidth !== this.state.deviceWidth ||
- deviceHeight !== this.state.deviceHeight
- ) {
+ if (deviceWidth !== this.state.deviceWidth || deviceHeight !== this.state.deviceHeight) {
this.setState({ deviceWidth, deviceHeight });
}
};
@@ -99,13 +96,7 @@ export class Modal extends Component {
};
render() {
- const {
- children,
- onBackdropPress,
- contentStyle,
- backdropStyle,
- ...otherProps
- } = this.props;
+ const { children, onBackdropPress, contentStyle, backdropStyle, ...otherProps } = this.props;
const { deviceHeight, deviceWidth, isVisible } = this.state;
const backdropAnimatedStyle = {
opacity: this.animVal.interpolate({
@@ -119,18 +110,13 @@ export class Modal extends Component {
translateY: this.animVal.interpolate({
inputRange: [0, 1],
outputRange: [deviceHeight, 0],
- extrapolate: "clamp",
+ extrapolate: 'clamp',
}),
},
],
};
return (
-
+
{
- const { height, width } = Dimensions.get("window");
+ const { height, width } = Dimensions.get('window');
return (
- Platform.OS === "ios" &&
+ Platform.OS === 'ios' &&
!Platform.isPad &&
!Platform.isTVOS &&
(height === 780 ||