Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/example/app/(drawer)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,12 @@ const Calendar = () => {
end={23 * 60}
spaceFromBottom={safeBottom}
defaultDuration={60}
// Test the new margin customization feature
scrollViewTopMargin={50}
scrollViewBottomMargin={50}
scrollViewContentContainerStyle={{
backgroundColor: 'rgba(0, 0, 0, 0.1)', // Light red background to visualize the margins
}}
onDragEventEnd={async (event) => {
console.log('onDragEventEnd', event);

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-calendar-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@howljs/calendar-kit",
"version": "2.5.6",
"version": "2.5.7",
"description": "React Native Calendar Kit",
"scripts": {
"test": "jest",
Expand Down
10 changes: 10 additions & 0 deletions packages/react-native-calendar-kit/src/CalendarBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ const CalendarBody: React.FC<CalendarBodyProps> = ({
resourcePerPage,
resourcePagingEnabled,
linkedScrollGroup,
scrollViewTopMargin,
scrollViewBottomMargin,
scrollViewContentContainerStyle,
} = useCalendar();
const { onTouchStart, onWheel } = linkedScrollGroup.addAndGet(
ScrollType.calendarGrid,
Expand Down Expand Up @@ -324,6 +327,13 @@ const CalendarBody: React.FC<CalendarBodyProps> = ({
showsVerticalScrollIndicator={false}
onLayout={_onLayout}
onScroll={_onScroll}
contentContainerStyle={[
scrollViewContentContainerStyle,
{
paddingTop: scrollViewTopMargin,
paddingBottom: scrollViewBottomMargin,
},
]}
refreshControl={
onRefresh ? (
<RefreshControl refreshing={false} onRefresh={_onRefresh} />
Expand Down
9 changes: 9 additions & 0 deletions packages/react-native-calendar-kit/src/CalendarContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ const CalendarContainer: React.ForwardRefRenderFunction<
enableResourceScroll = false,
resourcePerPage = 3,
resourcePagingEnabled = false,
scrollViewTopMargin = 0,
scrollViewBottomMargin = 0,
scrollViewContentContainerStyle,
},
ref
) => {
Expand Down Expand Up @@ -798,6 +801,9 @@ const CalendarContainer: React.ForwardRefRenderFunction<
resourcePerPage,
resourcePagingEnabled,
linkedScrollGroup,
scrollViewTopMargin,
scrollViewBottomMargin,
scrollViewContentContainerStyle,
}),
[
calendarLayout,
Expand Down Expand Up @@ -852,6 +858,9 @@ const CalendarContainer: React.ForwardRefRenderFunction<
resourcePerPage,
resourcePagingEnabled,
linkedScrollGroup,
scrollViewTopMargin,
scrollViewBottomMargin,
scrollViewContentContainerStyle,
]
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { WeekdayNumbers } from 'luxon';
import type { FC, PropsWithChildren } from 'react';
import React from 'react';
import type { ViewStyle } from 'react-native';
import type { AnimatedRef, SharedValue } from 'react-native-reanimated';
import type Animated from 'react-native-reanimated';
import type HapticService from '../service/HapticService';
Expand Down Expand Up @@ -63,6 +64,9 @@ export interface CalendarContextProps {
resourcePerPage: number;
resourcePagingEnabled: boolean;
linkedScrollGroup: LinkedScrollGroup;
scrollViewTopMargin: number;
scrollViewBottomMargin: number;
scrollViewContentContainerStyle?: ViewStyle;
}

export const CalendarContext = React.createContext<
Expand Down
25 changes: 24 additions & 1 deletion packages/react-native-calendar-kit/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export interface ThemeConfigs {

/** Default style of the event */
eventTitleStyle?: TextStyle;

/** Custom style for the ScrollView content container */
scrollViewContentContainerStyle?: ViewStyle;
}

export type GoToDateOptions = {
Expand Down Expand Up @@ -553,14 +556,34 @@ export interface CalendarProviderProps extends ActionsProviderProps {
/** Enable resource scroll
*
* Default: true - (Web: false)
*/
/** Enable resource scroll */
enableResourceScroll?: boolean;

/** Resource per page */
resourcePerPage?: number;

/** Resource paging enabled */
resourcePagingEnabled?: boolean;

/**
* Custom margin for the top of the ScrollView content
*
* Default: `0`
*/
scrollViewTopMargin?: number;

/**
* Custom margin for the bottom of the ScrollView content
*
* Default: `0`
*/
scrollViewBottomMargin?: number;

/**
* Custom style for the ScrollView content container
* This allows for advanced styling including custom margins, padding, etc.
*/
scrollViewContentContainerStyle?: ViewStyle;
}

export interface ResourceItem extends Record<string, any> {
Expand Down