@@ -23,6 +23,7 @@ import DateTimePicker from "./DatePickerComponent";
2323
2424import type { Theme } from "../../styles/DefaultTheme" ;
2525import type { IconSlot } from "../../interfaces/Icon" ;
26+ import { extractStyles } from "../../utilities" ;
2627
2728const AnimatedText = Animated . createAnimatedComponent ( Text ) ;
2829
@@ -31,14 +32,13 @@ const BLUR_ANIMATION_DURATION = 180;
3132const ICON_SIZE = 24 ;
3233
3334type Props = {
34- style ?: StyleProp < ViewStyle > & { height ?: number } ;
35+ style ?: StyleProp < ViewStyle | TextStyle > & { height ?: number } ;
3536 theme : Theme ;
3637 // initialDate?: string;
3738 // locale?: string;
3839 // minuteInterval?: number;
3940 // timeZoneOffsetInMinutes?: number;
4041 // error?: boolean;
41- // type?: string;
4242 date ?: Date ;
4343 format ?: string ;
4444 onDateChange ?: ( data ?: Date ) => void ;
@@ -47,10 +47,14 @@ type Props = {
4747 mode ?: "date" | "time" | "datetime" ;
4848 type ?: "solid" | "underline" ;
4949 label ?: string ;
50+ labelSize ?: number ;
51+ labelColor ?: string ;
5052 placeholder ?: string ;
5153 leftIconName ?: string ;
5254 leftIconMode ?: "outset" | "inset" ;
5355 rightIconName ?: string ;
56+ borderColor ?: string ;
57+ borderColorActive ?: string ;
5458} & IconSlot &
5559 TextInputProps ;
5660
@@ -84,7 +88,11 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
8488 rightIconName,
8589 leftIconMode = "inset" ,
8690 label,
91+ labelSize,
92+ labelColor,
8793 placeholder,
94+ borderColor : inputBorderColor ,
95+ borderColorActive : inputBorderColorActive ,
8896 ...props
8997} ) => {
9098 const [ value , setValue ] = React . useState < any > ( date || defaultValue ) ;
@@ -106,6 +114,8 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
106114 width : number ;
107115 } > ( { measured : false , width : 0 } ) ;
108116
117+ const { viewStyles, textStyles } = extractStyles ( style ) ;
118+
109119 const getValidDate = ( ) : Date => {
110120 if ( ! value ) {
111121 return new Date ( ) ;
@@ -211,8 +221,11 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
211221
212222 const MINIMIZED_LABEL_Y_OFFSET = - ( typography . caption . lineHeight + 4 ) ;
213223 const OUTLINE_MINIMIZED_LABEL_Y_OFFSET = - ( 16 * 0.5 + 4 ) ;
214- const MAXIMIZED_LABEL_FONT_SIZE = typography . subtitle1 . fontSize ;
215- const MINIMIZED_LABEL_FONT_SIZE = typography . caption . fontSize ;
224+ const MAXIMIZED_LABEL_FONT_SIZE =
225+ textStyles . fontSize || typography . subtitle1 . fontSize ;
226+ const MINIMIZED_LABEL_FONT_SIZE = labelSize
227+ ? labelSize
228+ : typography . caption . fontSize ;
216229
217230 const hasActiveOutline = focused ;
218231
@@ -233,9 +246,9 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
233246 underlineColor = "transparent" ;
234247 backgroundColor = colors . divider ;
235248 } else {
236- activeColor = colors . primary ;
237- placeholderColor = borderColor = colors . light ;
238- underlineColor = colors . light ;
249+ activeColor = inputBorderColorActive || colors . primary ;
250+ placeholderColor = inputBorderColor || colors . light ;
251+ underlineColor = inputBorderColor || colors . light ;
239252 backgroundColor = colors . background ;
240253 }
241254
@@ -306,6 +319,7 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
306319 const labelStyle = {
307320 ...typography . subtitle1 ,
308321 top : type === "solid" ? 16 : 0 ,
322+ fontFamily : textStyles ?. fontFamily ,
309323 left :
310324 leftIconName && leftIconMode === "inset"
311325 ? ICON_SIZE + ( type === "solid" ? 16 : 12 )
@@ -364,7 +378,11 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
364378 < Icon { ...leftIconProps } style = { leftIconStyle } />
365379 ) : null }
366380 < View
367- style = { [ containerStyle , style ? { height : style . height } : { } ] }
381+ style = { [
382+ containerStyle ,
383+ style ? { height : style . height } : { } ,
384+ viewStyles ,
385+ ] }
368386 >
369387 { type === "underline" ? (
370388 // When type === 'flat', render an underline
@@ -406,7 +424,7 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
406424 type === "solid" ? { paddingHorizontal : 12 } : { } ,
407425 labelStyle ,
408426 {
409- color : colors . light ,
427+ color : labelColor || colors . light ,
410428 opacity : labeled . interpolate ( {
411429 inputRange : [ 0 , 1 ] ,
412430 outputRange : [ hasActiveOutline ? 1 : 0 , 0 ] ,
@@ -423,7 +441,7 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
423441 type === "solid" ? { paddingHorizontal : 12 } : { } ,
424442 labelStyle ,
425443 {
426- color : placeholderColor ,
444+ color : labelColor || placeholderColor ,
427445 opacity : hasActiveOutline ? labeled : 1 ,
428446 } ,
429447 ] }
@@ -453,7 +471,7 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
453471 onFocus = { _handleFocus }
454472 onBlur = { _handleBlur }
455473 underlineColorAndroid = { "transparent" }
456- style = { inputStyles }
474+ style = { [ inputStyles , textStyles ] }
457475 { ...props }
458476 />
459477 </ View >
0 commit comments