File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
1414
1515import { useTextField } from './logic' ;
1616import { $addendumStyle } from './styles' ;
17+ import TextFieldErrorIcon from './TextFieldErrorIcon' ;
1718import type { InternalTheme , ThemeProp } from '../../types' ;
1819
1920export type TextFieldVariant = 'filled' | 'outlined' ;
@@ -306,14 +307,16 @@ function TextField(props: TextFieldProps) {
306307 ) }
307308 </ View >
308309
309- { ! ! TrailingAccessory && (
310+ { TrailingAccessory ? (
310311 < TrailingAccessory
311312 style = { $trailingAccessoryStyles }
312313 status = { status }
313314 editable = { ! disabled }
314315 multiline = { ! ! textInputProps . multiline }
315316 />
316- ) }
317+ ) : hasError ? (
318+ < TextFieldErrorIcon style = { $trailingAccessoryStyles } theme = { theme } />
319+ ) : null }
317320 </ View >
318321
319322 < View style = { $addendumStyle } >
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { StyleProp , View , ViewStyle } from 'react-native' ;
3+
4+ import { ACCESSORY_SIZE , ERROR_ICON_SIZE } from './constants' ;
5+ import { useInternalTheme } from '../../core/theming' ;
6+ import type { ThemeProp } from '../../types' ;
7+ import Icon from '../Icon' ;
8+
9+ interface TextFieldErrorIconProps {
10+ style ?: StyleProp < ViewStyle > ;
11+ theme ?: ThemeProp ;
12+ }
13+
14+ const TextFieldErrorIcon = ( {
15+ style : $wrapperStyle ,
16+ theme : themeOverride ,
17+ } : TextFieldErrorIconProps ) => {
18+ const theme = useInternalTheme ( themeOverride ) ;
19+
20+ const $circleStyle : ViewStyle = {
21+ width : ACCESSORY_SIZE ,
22+ height : ACCESSORY_SIZE ,
23+ borderRadius : ACCESSORY_SIZE / 2 ,
24+ justifyContent : 'center' ,
25+ alignItems : 'center' ,
26+ backgroundColor : theme . colors . error ,
27+ } ;
28+
29+ return (
30+ < View style = { $wrapperStyle } >
31+ < View style = { $circleStyle } >
32+ < Icon
33+ source = "exclamation-thick"
34+ size = { ERROR_ICON_SIZE }
35+ color = { theme . colors . onError }
36+ />
37+ </ View >
38+ </ View >
39+ ) ;
40+ } ;
41+
42+ export default TextFieldErrorIcon ;
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ export const ACCESSORY_SIZE = 24;
2121export const PREFIX_END_PADDING = 2 ;
2222export const SUFFIX_START_PADDING = 2 ;
2323
24+ export const ERROR_ICON_SIZE = 16 ;
25+
2426// ===============
2527// TYPOGRAPHY
2628// ===============
You can’t perform that action at this time.
0 commit comments