|
@@ -23,6 +23,10 @@ import {
|
|
|
import {
|
|
import {
|
|
|
NCoreUIKitTheme
|
|
NCoreUIKitTheme
|
|
|
} from "../../core/hooks";
|
|
} from "../../core/hooks";
|
|
|
|
|
+import {
|
|
|
|
|
+ ChevronRight as ChevronRightIcon,
|
|
|
|
|
+ ChevronLeft as ChevronLeftIcon
|
|
|
|
|
+} from "lucide-react-native";
|
|
|
import moment from "moment";
|
|
import moment from "moment";
|
|
|
import Text from "../text";
|
|
import Text from "../text";
|
|
|
|
|
|
|
@@ -33,6 +37,7 @@ const DateSelector = ({
|
|
|
viewDate: viewDateProp,
|
|
viewDate: viewDateProp,
|
|
|
dateRange,
|
|
dateRange,
|
|
|
dateRule,
|
|
dateRule,
|
|
|
|
|
+ setDate,
|
|
|
variant,
|
|
variant,
|
|
|
date
|
|
date
|
|
|
}: IDateSelectorProps, ref: Ref<IDateSelectorRef>) => {
|
|
}: IDateSelectorProps, ref: Ref<IDateSelectorRef>) => {
|
|
@@ -61,6 +66,8 @@ const DateSelector = ({
|
|
|
] = useState<Array<CalendarDay>>([]);
|
|
] = useState<Array<CalendarDay>>([]);
|
|
|
|
|
|
|
|
const {
|
|
const {
|
|
|
|
|
+ nextPrevToolChevronButton: nextPrevToolChevronButtonDynamicStyle,
|
|
|
|
|
+ nextPrevToolContainer: nextPrevToolContainerDynamicStyle,
|
|
|
todayIndicator: todayIndicatorDynamicStyle,
|
|
todayIndicator: todayIndicatorDynamicStyle,
|
|
|
dayOfWeek: dayOfWeekDynamicStyle,
|
|
dayOfWeek: dayOfWeekDynamicStyle,
|
|
|
day: dayDynamicStyle
|
|
day: dayDynamicStyle
|
|
@@ -77,7 +84,12 @@ const DateSelector = ({
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
setMonthDays(allDays);
|
|
setMonthDays(allDays);
|
|
|
- }, [viewDate]);
|
|
|
|
|
|
|
+ }, [
|
|
|
|
|
+ dateRange,
|
|
|
|
|
+ viewDate,
|
|
|
|
|
+ dateRule,
|
|
|
|
|
+ date
|
|
|
|
|
+ ]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if(viewDateProp) {
|
|
if(viewDateProp) {
|
|
@@ -89,11 +101,7 @@ const DateSelector = ({
|
|
|
ref,
|
|
ref,
|
|
|
() => ({
|
|
() => ({
|
|
|
changeCurrentMonth: (date: Date) => {
|
|
changeCurrentMonth: (date: Date) => {
|
|
|
- const allDays = getDaysOfViewMonth({
|
|
|
|
|
- tDate: date
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- setMonthDays(allDays);
|
|
|
|
|
|
|
+ setViewDate(date);
|
|
|
}
|
|
}
|
|
|
}),
|
|
}),
|
|
|
[]
|
|
[]
|
|
@@ -182,6 +190,20 @@ const DateSelector = ({
|
|
|
|
|
|
|
|
return <TouchableOpacity
|
|
return <TouchableOpacity
|
|
|
key={`day-${weekIndex}-${dayIndex}`}
|
|
key={`day-${weekIndex}-${dayIndex}`}
|
|
|
|
|
+ disabled={!dayItem.isCurrentMonth}
|
|
|
|
|
+ onPress={() => {
|
|
|
|
|
+ if(!dayItem.isCurrentMonth) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(variant === "single") {
|
|
|
|
|
+ setDate(dayItem.date.toDate());
|
|
|
|
|
+ } else if(variant === "range") {
|
|
|
|
|
+ console.log("range");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log("rrule");
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
style={[
|
|
style={[
|
|
|
stylesheet.day,
|
|
stylesheet.day,
|
|
|
dayDynamicStyle,
|
|
dayDynamicStyle,
|
|
@@ -212,6 +234,50 @@ const DateSelector = ({
|
|
|
</TouchableOpacity>;
|
|
</TouchableOpacity>;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const renderNextPrevTool = () => {
|
|
|
|
|
+ return <View
|
|
|
|
|
+ style={[
|
|
|
|
|
+ stylesheet.nextPrevToolContainer,
|
|
|
|
|
+ nextPrevToolContainerDynamicStyle
|
|
|
|
|
+ ]}
|
|
|
|
|
+ >
|
|
|
|
|
+ <TouchableOpacity
|
|
|
|
|
+ onPress={() => {
|
|
|
|
|
+ const prevViewDate = moment(viewDate).clone().subtract(1, "months");
|
|
|
|
|
+ setViewDate(prevViewDate.toDate());
|
|
|
|
|
+ }}
|
|
|
|
|
+ style={[
|
|
|
|
|
+ nextPrevToolChevronButtonDynamicStyle
|
|
|
|
|
+ ]}
|
|
|
|
|
+ >
|
|
|
|
|
+ <ChevronLeftIcon
|
|
|
|
|
+ color={colors.content.icon.default}
|
|
|
|
|
+ size={26}
|
|
|
|
|
+ />
|
|
|
|
|
+ </TouchableOpacity>
|
|
|
|
|
+ <Text
|
|
|
|
|
+ variant="labelLargeSize"
|
|
|
|
|
+ color="high"
|
|
|
|
|
+ >
|
|
|
|
|
+ {moment(viewDate).format("MMMM YYYY")}
|
|
|
|
|
+ </Text>
|
|
|
|
|
+ <TouchableOpacity
|
|
|
|
|
+ onPress={() => {
|
|
|
|
|
+ const nextViewDate = moment(viewDate).clone().add(1, "months");
|
|
|
|
|
+ setViewDate(nextViewDate.toDate());
|
|
|
|
|
+ }}
|
|
|
|
|
+ style={[
|
|
|
|
|
+ nextPrevToolChevronButtonDynamicStyle
|
|
|
|
|
+ ]}
|
|
|
|
|
+ >
|
|
|
|
|
+ <ChevronRightIcon
|
|
|
|
|
+ color={colors.content.icon.default}
|
|
|
|
|
+ size={26}
|
|
|
|
|
+ />
|
|
|
|
|
+ </TouchableOpacity>
|
|
|
|
|
+ </View>;
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
let weekDays = moment.weekdays(localeBasedFirstDayOfWeek ? true : false);
|
|
let weekDays = moment.weekdays(localeBasedFirstDayOfWeek ? true : false);
|
|
|
|
|
|
|
|
if(dayOfWeekLength === "short") {
|
|
if(dayOfWeekLength === "short") {
|
|
@@ -225,6 +291,9 @@ const DateSelector = ({
|
|
|
stylesheet.container
|
|
stylesheet.container
|
|
|
]}
|
|
]}
|
|
|
>
|
|
>
|
|
|
|
|
+ <View>
|
|
|
|
|
+ {renderNextPrevTool()}
|
|
|
|
|
+ </View>
|
|
|
<View
|
|
<View
|
|
|
style={[
|
|
style={[
|
|
|
stylesheet.contentContainer
|
|
stylesheet.contentContainer
|