Skip to content

Commit 79d63e4

Browse files
Merge pull request #202 from hearti-lab/master
Custom scroll in year picker and allow editing button
2 parents 18784d9 + 09c1ffc commit 79d63e4

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/Date/DatePickerModalContent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export function DatePickerModalContent(
165165
locale={locale}
166166
editIcon={props?.editIcon}
167167
calendarIcon={props.calendarIcon}
168+
allowEditing={props.allowEditing || true}
168169
/>
169170
</DatePickerModalHeaderBackground>
170171
<AnimatedCrossView

src/Date/DatePickerModalContentHeader.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface HeaderPickProps {
1919
editIcon?: string
2020
calendarIcon?: string
2121
closeIcon?: string
22+
allowEditing?: boolean
2223
}
2324

2425
export interface HeaderContentProps extends HeaderPickProps {
@@ -62,19 +63,18 @@ export default function DatePickerModalContentHeader(
6263
editIcon,
6364
calendarIcon,
6465
inputDate,
66+
allowEditing,
6567
} = props
6668
const theme = useTheme()
6769
const label = getLabel(props.locale, props.mode, props.label)
6870

6971
const color = useHeaderTextColor()
70-
const supportingTextColor = theme.isV3 ? theme.colors.onSurfaceVariant : color
71-
let allowEditing = mode !== 'multiple'
7272

73-
if (inputDate !== undefined) {
74-
allowEditing = inputDate
75-
}
73+
const isAllowEditing = allowEditing && mode !== 'multiple' && inputDate !== undefined
74+
75+
const supportingTextColor = theme.isV3 ? theme.colors.onSurfaceVariant : color
7676

77-
let textFont = theme?.isV3
77+
const textFont = theme?.isV3
7878
? theme.fonts.labelMedium
7979
: (theme as any as MD2Theme).fonts.medium
8080

@@ -103,7 +103,7 @@ export default function DatePickerModalContentHeader(
103103
</View>
104104
</View>
105105
<View style={styles.fill} />
106-
{allowEditing ? (
106+
{isAllowEditing ? (
107107
<IconButton
108108
icon={
109109
collapsed

src/Date/YearPicker.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react'
2-
import { FlatList, StyleSheet, View } from 'react-native'
2+
import { FlatList, StyleSheet, View, ScrollView } from 'react-native'
33
import { MD2Theme, Text, TouchableRipple, useTheme } from 'react-native-paper'
44
import { range } from '../utils'
55

@@ -50,6 +50,9 @@ export default function YearPicker({
5050
ref={flatList}
5151
style={styles.list}
5252
data={years}
53+
renderScrollComponent={(sProps) => {
54+
return <ScrollView {...sProps} />
55+
}}
5356
renderItem={({ item }) => (
5457
<Year
5558
year={item}

0 commit comments

Comments
 (0)