11import { TextView as TextViewDefinition } from "." ;
22import {
3- EditableTextBase , editableProperty , hintProperty , textProperty , colorProperty ,
3+ EditableTextBase , editableProperty , hintProperty , textProperty , colorProperty , placeholderColorProperty ,
44 borderTopWidthProperty , borderRightWidthProperty , borderBottomWidthProperty , borderLeftWidthProperty ,
55 paddingTopProperty , paddingRightProperty , paddingBottomProperty , paddingLeftProperty ,
66 Length , _updateCharactersInRangeReplacementString , Color , layout
77} from "../editable-text-base" ;
88
9- import { ios } from "../../utils/utils" ;
10-
119export * from "../editable-text-base" ;
1210
1311class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate {
@@ -108,18 +106,44 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
108106 }
109107 }
110108
109+ private _refreshColor ( ) {
110+ if ( this . _isShowingHint ) {
111+ const placeholderColor = this . style . placeholderColor ;
112+ const color = this . style . color ;
113+
114+ if ( placeholderColor ) {
115+ this . nativeView . textColor = placeholderColor . ios ;
116+ } else if ( color ) {
117+ // Use semi-transparent vesion of color for back-compatibility
118+ this . nativeView . textColor = color . ios . colorWithAlphaComponent ( 0.22 ) ;
119+ } else {
120+ this . nativeView . textColor = UIColor . blackColor . colorWithAlphaComponent ( 0.22 ) ;
121+ }
122+ } else {
123+ const color = this . style . color ;
124+
125+ if ( color ) {
126+ this . nativeView . textColor = color . ios ;
127+ } else {
128+ this . nativeView . textColor = UIColor . blackColor ;
129+ }
130+ }
131+ }
132+
111133 public showHint ( hint : string ) {
112134 const nativeView = this . nativeView ;
113- nativeView . textColor = nativeView . textColor ? nativeView . textColor . colorWithAlphaComponent ( 0.22 ) : ios . getter ( UIColor , UIColor . blackColor ) . colorWithAlphaComponent ( 0.22 ) ;
135+
136+ this . _isShowingHint = true ;
137+ this . _refreshColor ( ) ;
138+
114139 const hintAsString : string = ( hint === null || hint === undefined ) ? '' : hint . toString ( ) ;
115140 nativeView . text = hintAsString ;
116- this . _isShowingHint = true ;
117141 }
118142
119143 public showText ( ) {
120- this . nativeView . textColor = this . color ? this . color . ios : null ;
121- this . _setNativeText ( ) ;
122144 this . _isShowingHint = false ;
145+ this . _refreshColor ( ) ;
146+ this . _setNativeText ( ) ;
123147 }
124148
125149 get [ textProperty . native ] ( ) : string {
@@ -144,23 +168,18 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
144168 }
145169
146170 get [ colorProperty . native ] ( ) : UIColor {
147- let textView = this . nativeView ;
148- if ( this . _isShowingHint && textView . textColor ) {
149- return textView . textColor . colorWithAlphaComponent ( 1 ) ;
150- }
151- else {
152- return textView . textColor ;
153- }
171+ return null ;
154172 }
155- set [ colorProperty . native ] ( color : UIColor | Color ) {
156- let textView = this . nativeView ;
157- let uiColor = color instanceof Color ? color . ios : color ;
158- if ( this . _isShowingHint && uiColor ) {
159- textView . textColor = uiColor . colorWithAlphaComponent ( 0.22 ) ;
160- } else {
161- textView . textColor = uiColor ;
162- textView . tintColor = uiColor ;
163- }
173+ set [ colorProperty . native ] ( color : Color ) {
174+ this . _refreshColor ( ) ;
175+
176+ }
177+
178+ get [ placeholderColorProperty . native ] ( ) : Color {
179+ return null ;
180+ }
181+ set [ placeholderColorProperty . native ] ( value : Color ) {
182+ this . _refreshColor ( ) ;
164183 }
165184
166185 get [ borderTopWidthProperty . native ] ( ) : Length {
@@ -246,7 +265,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
246265 let bottom = layout . toDeviceIndependentPixels ( this . effectivePaddingBottom + this . effectiveBorderBottomWidth ) ;
247266 this . nativeView . textContainerInset = { top : inset . top , left : inset . left , bottom : bottom , right : inset . right } ;
248267 }
249-
268+
250269 get [ paddingLeftProperty . native ] ( ) : Length {
251270 return {
252271 value : this . nativeView . textContainerInset . left ,
0 commit comments