-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(infiniteAgendaList): add the ability to set item height per item (…
…#2515) * feat(infiniteAgendaList): add the ability to set item height per item * Update infiniteAgendaList.tsx * add example * Fix PR comment * Rename itemType to itemCustomHeightType
- Loading branch information
Showing
7 changed files
with
105 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React, {useRef, useCallback} from 'react'; | ||
import {StyleSheet, View} from 'react-native'; | ||
import {ExpandableCalendar, AgendaList, CalendarProvider, WeekCalendar} from 'react-native-calendars'; | ||
import testIDs from '../testIDs'; | ||
import {agendaItems, getMarkedDates} from '../mocks/agendaItems'; | ||
import AgendaItem from '../mocks/AgendaItem'; | ||
import {getTheme, themeColor, lightThemeColor} from '../mocks/theme'; | ||
|
||
const leftArrowIcon = require('../img/previous.png'); | ||
const rightArrowIcon = require('../img/next.png'); | ||
const ITEMS: any[] = agendaItems; | ||
|
||
interface Props { | ||
weekView?: boolean; | ||
} | ||
|
||
const AgendaInfiniteListScreen = (props: Props) => { | ||
const {weekView} = props; | ||
const marked = useRef(getMarkedDates()); | ||
const theme = useRef(getTheme()); | ||
const todayBtnTheme = useRef({ | ||
todayButtonTextColor: themeColor | ||
}); | ||
|
||
const renderItem = useCallback(({item}: any) => { | ||
const isLongItem = item.itemCustomHeightType === 'LongEvent'; | ||
return <View style={{paddingTop: isLongItem ? 40 : 0}}><AgendaItem item={item}/></View>; | ||
}, []); | ||
|
||
return ( | ||
<CalendarProvider | ||
date={ITEMS[1]?.title} | ||
showTodayButton | ||
theme={todayBtnTheme.current} | ||
> | ||
{weekView ? ( | ||
<WeekCalendar testID={testIDs.weekCalendar.CONTAINER} firstDay={1} markedDates={marked.current}/> | ||
) : ( | ||
<ExpandableCalendar | ||
testID={testIDs.expandableCalendar.CONTAINER} | ||
theme={theme.current} | ||
firstDay={1} | ||
markedDates={marked.current} | ||
leftArrowImageSource={leftArrowIcon} | ||
rightArrowImageSource={rightArrowIcon} | ||
/> | ||
)} | ||
<AgendaList | ||
sections={ITEMS} | ||
renderItem={renderItem} | ||
sectionStyle={styles.section} | ||
infiniteListProps={ | ||
{ | ||
itemHeight: 80, | ||
titleHeight: 50, | ||
itemHeightByType: { | ||
LongEvent: 120, | ||
} | ||
} | ||
} | ||
/> | ||
</CalendarProvider> | ||
); | ||
}; | ||
|
||
export default AgendaInfiniteListScreen; | ||
|
||
const styles = StyleSheet.create({ | ||
calendar: { | ||
paddingLeft: 20, | ||
paddingRight: 20 | ||
}, | ||
header: { | ||
backgroundColor: 'lightgrey' | ||
}, | ||
section: { | ||
backgroundColor: lightThemeColor, | ||
color: 'grey', | ||
textTransform: 'capitalize' | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters