Skip to content

Commit e4994cb

Browse files
committed
ExpandableCalendar - fix Android bottom padding in open position.
Calendars demo screen - fix crash
1 parent 9b3c072 commit e4994cb

File tree

3 files changed

+14
-40
lines changed

3 files changed

+14
-40
lines changed

example/src/screens/calendars.tsx

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ const INITIAL_DATE = '2020-02-02';
77

88
const CalendarsScreen = () => {
99
const [selected, setSelected] = useState(INITIAL_DATE);
10-
const [showMarkedDatesExamples, setShowMarkedDatesExamples] = useState(false);
11-
12-
const toggleSwitch = () => {
13-
setShowMarkedDatesExamples(!showMarkedDatesExamples);
14-
};
1510

1611
const onDayPress: CalendarProps['onDayPress'] = day => {
1712
setSelected(day.dateString);
@@ -259,7 +254,8 @@ const CalendarsScreen = () => {
259254
elevation: 2
260255
},
261256
text: {
262-
color: 'red'
257+
color: 'red',
258+
marginTop: 0
263259
}
264260
}
265261
},
@@ -454,19 +450,6 @@ const CalendarsScreen = () => {
454450
);
455451
};
456452

457-
const renderMarkedDatesExamples = () => {
458-
return (
459-
<Fragment>
460-
{renderCalendarWithMarkedDatesAndHiddenArrows()}
461-
{renderCalendarWithMultiDotMarking()}
462-
{renderCalendarWithPeriodMarkingAndSpinner()}
463-
{renderCalendarWithPeriodMarkingAndDotMarking()}
464-
{renderCalendarWithMultiPeriodMarking()}
465-
{renderCalendarWithCustomMarkingType()}
466-
</Fragment>
467-
);
468-
};
469-
470453
const renderExamples = () => {
471454
return (
472455
<Fragment>
@@ -477,29 +460,19 @@ const CalendarsScreen = () => {
477460
{renderCalendarWithInactiveDays()}
478461
{renderCalendarWithCustomHeaderTitle()}
479462
{renderCalendarWithCustomHeader()}
463+
{renderCalendarWithMarkedDatesAndHiddenArrows()}
464+
{renderCalendarWithMultiDotMarking()}
465+
{renderCalendarWithPeriodMarkingAndSpinner()}
466+
{renderCalendarWithPeriodMarkingAndDotMarking()}
467+
{renderCalendarWithMultiPeriodMarking()}
468+
{renderCalendarWithCustomMarkingType()}
480469
</Fragment>
481470
);
482471
};
483472

484-
const renderSwitch = () => {
485-
// Workaround for Detox 18 migration bug
486-
return (
487-
<View style={styles.switchContainer}>
488-
<Switch
489-
trackColor={{false: '#d9e1e8', true: '#00BBF2'}}
490-
onValueChange={toggleSwitch}
491-
value={showMarkedDatesExamples}
492-
/>
493-
<Text style={styles.switchText}>Show markings examples</Text>
494-
</View>
495-
);
496-
};
497-
498473
return (
499474
<ScrollView showsVerticalScrollIndicator={false} testID={testIDs.calendars.CONTAINER}>
500-
{renderSwitch()}
501-
{showMarkedDatesExamples && renderMarkedDatesExamples()}
502-
{!showMarkedDatesExamples && renderExamples()}
475+
{renderExamples()}
503476
</ScrollView>
504477
);
505478
};

src/expandableCalendar/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {CALENDAR_KNOB} from '../testIDs';
2626
import {page, weekDayNames} from '../dateutils';
2727
import {parseDate, toMarkingFormat} from '../interface';
2828
import {Theme, DateData, Direction} from '../types';
29-
import styleConstructor, {HEADER_HEIGHT} from './style';
29+
import styleConstructor, {HEADER_HEIGHT, KNOB_CONTAINER_HEIGHT} from './style';
3030
import CalendarList, {CalendarListProps} from '../calendar-list';
3131
import Calendar from '../calendar';
3232
import asCalendarConsumer from './asCalendarConsumer';
@@ -43,7 +43,6 @@ const SPEED = 20;
4343
const BOUNCINESS = 6;
4444
const CLOSED_HEIGHT = 120; // header + 1 week
4545
const WEEK_HEIGHT = 46;
46-
const KNOB_CONTAINER_HEIGHT = 20;
4746
const DAY_NAMES_PADDING = 24;
4847
const PAN_GESTURE_THRESHOLD = 30;
4948
const LEFT_ARROW = require('../calendar/img/previous.png');
@@ -271,7 +270,7 @@ class ExpandableCalendar extends Component<ExpandableCalendarProps, State> {
271270
if (!this.props.horizontal) {
272271
return Math.max(commons.screenHeight, commons.screenWidth);
273272
}
274-
return CLOSED_HEIGHT + WEEK_HEIGHT * (this.numberOfWeeks - 1) + (this.props.hideKnob ? 12 : KNOB_CONTAINER_HEIGHT);
273+
return CLOSED_HEIGHT + (WEEK_HEIGHT * (this.numberOfWeeks - 1)) + (this.props.hideKnob ? 12 : KNOB_CONTAINER_HEIGHT) + (commons.isAndroid ? 3 : 0);
275274
}
276275

277276
getYear(date: XDate) {

src/expandableCalendar/style.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {Theme} from '../types';
55

66
const commons = require('./commons');
77
export const HEADER_HEIGHT = 68;
8+
export const KNOB_CONTAINER_HEIGHT = 24;
9+
810

911
export default function styleConstructor(theme: Theme = {}) {
1012
const appStyle = {...defaultStyle, ...theme};
@@ -35,7 +37,7 @@ export default function styleConstructor(theme: Theme = {}) {
3537
position: 'absolute',
3638
left: 0,
3739
right: 0,
38-
height: 24,
40+
height: KNOB_CONTAINER_HEIGHT,
3941
bottom: 0,
4042
alignItems: 'center',
4143
justifyContent: 'center',

0 commit comments

Comments
 (0)