1
- using Newtonsoft . Json . Linq ;
1
+ using Newtonsoft . Json . Linq ;
2
2
using ReactNative . Reflection ;
3
3
using ReactNative . UIManager ;
4
4
using ReactNative . UIManager . Annotations ;
@@ -23,9 +23,31 @@ class ReactTextInputManager : BaseViewManager<ReactTextBox, ReactTextInputShadow
23
23
internal const int FocusTextInput = 1 ;
24
24
internal const int BlurTextInput = 2 ;
25
25
26
- private bool _onSelectionChange ;
26
+ //
27
+ // Grabbed these defaults from running a UWP app.
28
+ //
29
+
30
+ private const uint DefaultTextControlForeground = 0xFF000000 ;
31
+ private const uint DefaultTextControlForegroundPointerOver = 0xFF000000 ;
32
+ private const uint DefaultTextControlForegroundFocused = 0xFF000000 ;
33
+ private const uint DefaultTextControlForegroundDisabled = 0xFF7A7A7A ;
34
+
35
+ private const uint DefaultTextControlBackground = 0x66FFFFFF ;
36
+ private const uint DefaultTextControlBackgroundPointerOver = 0x99FFFFFF ;
37
+ private const uint DefaultTextControlBackgroundFocused = 0xFFFFFFFF ;
38
+ private const uint DefaultTextControlBackgroundDisabled = 0x33000000 ;
39
+
40
+ private const uint DefaultTextControlPlaceholderForeground = 0x99000000 ;
41
+ private const uint DefaultTextControlPlaceholderForegroundPointerOver = 0x99000000 ;
42
+ private const uint DefaultTextControlPlaceholderForegroundFocused = 0x66000000 ;
43
+ private const uint DefaultTextControlPlaceholderForegroundDisabled = 0xFF7A7A7A ;
27
44
28
- internal static readonly Color DefaultTextBoxBorder = Color . FromArgb ( 255 , 122 , 122 , 122 ) ;
45
+ private const uint DefaultTextControlBorderBrush = 0xFF7A7A7A ;
46
+ private const uint DefaultTextControlBorderBrushPointerOver = 0xFF171717 ;
47
+ private const uint DefaultTextControlBorderBrushFocused = 0xFF298FCC ;
48
+ private const uint DefaultTextControlBorderBrushDisabled = 0x33000000 ;
49
+
50
+ private bool _onSelectionChange ;
29
51
30
52
/// <summary>
31
53
/// The name of the view manager.
@@ -141,9 +163,21 @@ public void SetFontSize(ReactTextBox view, double fontSize)
141
163
[ ReactProp ( ViewProps . Color , CustomType = "Color" ) ]
142
164
public void SetColor ( ReactTextBox view , uint ? color )
143
165
{
144
- view . Foreground = color . HasValue
145
- ? new SolidColorBrush ( ColorHelpers . Parse ( color . Value ) )
146
- : null ;
166
+ if ( color . HasValue )
167
+ {
168
+ var brush = new SolidColorBrush ( ColorHelpers . Parse ( color . Value ) ) ;
169
+ view . Resources [ "TextControlForeground" ] = brush ;
170
+ view . Resources [ "TextControlForegroundPointerOver" ] = brush ;
171
+ view . Resources [ "TextControlForegroundFocused" ] = brush ;
172
+ view . Resources [ "TextControlForegroundDisabled" ] = brush ;
173
+ }
174
+ else
175
+ {
176
+ view . Resources [ "TextControlForeground" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlForeground ) ) ;
177
+ view . Resources [ "TextControlForegroundPointerOver" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlForegroundPointerOver ) ) ;
178
+ view . Resources [ "TextControlForegroundFocused" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlForegroundFocused ) ) ;
179
+ view . Resources [ "TextControlForegroundDisabled" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlForegroundDisabled ) ) ;
180
+ }
147
181
}
148
182
149
183
/// <summary>
@@ -222,10 +256,21 @@ public void SetPlaceholder(ReactTextBox view, string placeholder)
222
256
[ ReactProp ( "placeholderTextColor" , CustomType = "Color" ) ]
223
257
public void SetPlaceholderTextColor ( ReactTextBox view , uint ? color )
224
258
{
225
- //The 'PlaceholderTextColor' is not implemented in UWP - Use of this property
226
- //will be ignored...
227
-
228
- //TODO: #1039 #1040
259
+ if ( color . HasValue )
260
+ {
261
+ var brush = new SolidColorBrush ( ColorHelpers . Parse ( color . Value ) ) ;
262
+ view . Resources [ "TextControlPlaceholderForeground" ] = brush ;
263
+ view . Resources [ "TextControlPlaceholderForegroundPointerOver" ] = brush ;
264
+ view . Resources [ "TextControlPlaceholderForegroundFocused" ] = brush ;
265
+ view . Resources [ "TextControlPlaceholderForegroundDisabled" ] = brush ;
266
+ }
267
+ else
268
+ {
269
+ view . Resources [ "TextControlPlaceholderForeground" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlPlaceholderForeground ) ) ;
270
+ view . Resources [ "TextControlPlaceholderForegroundPointerOver" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlPlaceholderForegroundPointerOver ) ) ;
271
+ view . Resources [ "TextControlPlaceholderForegroundFocused" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlPlaceholderForegroundFocused ) ) ;
272
+ view . Resources [ "TextControlPlaceholderForegroundDisabled" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlPlaceholderForegroundDisabled ) ) ;
273
+ }
229
274
}
230
275
231
276
/// <summary>
@@ -236,9 +281,21 @@ public void SetPlaceholderTextColor(ReactTextBox view, uint? color)
236
281
[ ReactProp ( "borderColor" , CustomType = "Color" ) ]
237
282
public void SetBorderColor ( ReactTextBox view , uint ? color )
238
283
{
239
- view . BorderBrush = color . HasValue
240
- ? new SolidColorBrush ( ColorHelpers . Parse ( color . Value ) )
241
- : new SolidColorBrush ( DefaultTextBoxBorder ) ;
284
+ if ( color . HasValue )
285
+ {
286
+ var brush = new SolidColorBrush ( ColorHelpers . Parse ( color . Value ) ) ;
287
+ view . Resources [ "TextControlBorderBrush" ] = brush ;
288
+ view . Resources [ "TextControlBorderBrushPointerOver" ] = brush ;
289
+ view . Resources [ "TextControlBorderBrushFocused" ] = brush ;
290
+ view . Resources [ "TextControlBorderBrushDisabled" ] = brush ;
291
+ }
292
+ else
293
+ {
294
+ view . Resources [ "TextControlBorderBrush" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlBorderBrush ) ) ;
295
+ view . Resources [ "TextControlBorderBrushPointerOver" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlBorderBrushPointerOver ) ) ;
296
+ view . Resources [ "TextControlBorderBrushFocused" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlBorderBrushFocused ) ) ;
297
+ view . Resources [ "TextControlBorderBrushDisabled" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlBorderBrushDisabled ) ) ;
298
+ }
242
299
}
243
300
244
301
/// <summary>
@@ -249,9 +306,21 @@ public void SetBorderColor(ReactTextBox view, uint? color)
249
306
[ ReactProp ( ViewProps . BackgroundColor , CustomType = "Color" ) ]
250
307
public void SetBackgroundColor ( ReactTextBox view , uint ? color )
251
308
{
252
- view . Background = color . HasValue
253
- ? new SolidColorBrush ( ColorHelpers . Parse ( color . Value ) )
254
- : new SolidColorBrush ( Colors . White ) ;
309
+ if ( color . HasValue )
310
+ {
311
+ var brush = new SolidColorBrush ( ColorHelpers . Parse ( color . Value ) ) ;
312
+ view . Resources [ "TextControlBackground" ] = brush ;
313
+ view . Resources [ "TextControlBackgroundPointerOver" ] = brush ;
314
+ view . Resources [ "TextControlBackgroundFocused" ] = brush ;
315
+ view . Resources [ "TextControlBackgroundDisabled" ] = brush ;
316
+ }
317
+ else
318
+ {
319
+ view . Resources [ "TextControlBackground" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlBackground ) ) ;
320
+ view . Resources [ "TextControlBackgroundPointerOver" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlBackgroundPointerOver ) ) ;
321
+ view . Resources [ "TextControlBackgroundFocused" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlBackgroundFocused ) ) ;
322
+ view . Resources [ "TextControlBackgroundDisabled" ] = new SolidColorBrush ( ColorHelpers . Parse ( DefaultTextControlBackgroundDisabled ) ) ;
323
+ }
255
324
}
256
325
257
326
/// <summary>
0 commit comments