Skip to content

Commit

Permalink
feat(RCTTextBox): TextInput functionality for UWP
Browse files Browse the repository at this point in the history
This cleans up a lot of the behavior for TextInput, but not all of it. The properties that seem to be working are:
* autoCorrect
* keyboardType
* maxLength
* onFocus/onBlur
* onSelectionChange
* onEndEditing
* onSubmitEditing
* clearTextOnFocus
* selectTextOnFocus
* placeholder
* selectionColor
* editable

The properties that are not working are:
* numberOfLines
* password
* placeholderTextColor
* autoCapitalize

We do not yet support formatted children in the TextInput, which will likely require the use of RichEditBox and RTF. The multiline kind of works, but really only when you do some auto-resizing. The focus and blur methods are not working either.

Fixes microsoft#96
  • Loading branch information
rozele authored and GantMan committed Sep 29, 2016
1 parent c641bad commit 32c3f31
Show file tree
Hide file tree
Showing 23 changed files with 949 additions and 588 deletions.
1 change: 0 additions & 1 deletion ReactNative.Tests/ReactNative.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@
<Compile Include="UnitTestApp.xaml.cs">
<DependentUpon>UnitTestApp.xaml</DependentUpon>
</Compile>
<Compile Include="Views\TextInput\ReactTextBoxPropertiesTests.cs" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="UnitTestApp.xaml">
Expand Down
68 changes: 0 additions & 68 deletions ReactNative.Tests/Views/TextInput/ReactTextBoxPropertiesTests.cs

This file was deleted.

16 changes: 10 additions & 6 deletions ReactNative/ReactNative.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
<Compile Include="Touch\JavaScriptResponderHandler.cs" />
<Compile Include="Animation\ReactAnimationRegistry.cs" />
<Compile Include="UIManager\BaseViewManager.cs" />
<Compile Include="UIManager\ILayoutManager.cs" />
<Compile Include="UIManager\IViewManager.cs" />
<Compile Include="UIManager\IViewParentManager.cs" />
<Compile Include="UIManager\LayoutAnimation\BaseLayoutAnimation.cs" />
Expand Down Expand Up @@ -287,8 +288,14 @@
<Compile Include="Views\Scroll\ReactScrollViewCommandHelper.cs" />
<Compile Include="Views\Scroll\ScrollEventType.cs" />
<Compile Include="Views\Scroll\ScrollEventTypeExtensions.cs" />
<Compile Include="Views\TextInput\ReactMultilineTextInputManager.cs" />
<Compile Include="Views\TextInput\TextBoxExtensions.cs" />
<Compile Include="Views\TextInput\InputScopeHelpers.cs" />
<Compile Include="Views\TextInput\ReactTextBox.cs" />
<Compile Include="Views\TextInput\ReactTextChangedEvent.cs" />
<Compile Include="Views\TextInput\ReactTextInputBlurEvent.cs" />
<Compile Include="Views\TextInput\ReactTextInputEndEditingEvent.cs" />
<Compile Include="Views\TextInput\ReactTextInputFocusEvent.cs" />
<Compile Include="Views\TextInput\ReactTextInputSelectionEvent.cs" />
<Compile Include="Views\TextInput\ReactTextInputSubmitEditingEvent.cs" />
<Compile Include="Views\Text\FontStyleHelpers.cs" />
<Compile Include="UIManager\RootViewHelper.cs" />
<Compile Include="UIManager\RootViewManager.cs" />
Expand Down Expand Up @@ -320,19 +327,16 @@
<Compile Include="UIManager\ViewManager.cs" />
<Compile Include="UIManager\ViewManagerRegistry.cs" />
<Compile Include="Views\Scroll\ReactScrollViewManager.cs" />
<Compile Include="Views\TextInput\ReactTextBoxProperties.cs" />
<Compile Include="Views\TextInput\ReactTextInputShadowNode.cs" />
<Compile Include="Views\Switch\ReactSwitchManager.cs" />
<Compile Include="Views\Switch\ReactSwitchShadowNode.cs" />
<Compile Include="UIManager\CSSNodeVisitor.cs" />
<Compile Include="Views\ViewManagersPropertyCache.cs" />
<Compile Include="UIManager\ViewProperties.cs" />
<Compile Include="Views\Text\ReactRawTextManager.cs" />
<Compile Include="Views\Text\ReactTextShadowNode.cs" />
<Compile Include="Views\Text\ReactTextViewManager.cs" />
<Compile Include="Views\Text\ReactVirtualTextViewManager.cs" />
<Compile Include="Views\TextInput\ReactTextChangedEvent.cs" />
<Compile Include="Views\TextInput\ReactTextInputBlurEvent.cs" />
<Compile Include="Views\TextInput\ReactTextInputFocusEvent.cs" />
<Compile Include="Views\View\ReactViewManager.cs" />
<Compile Include="Views\TextInput\ReactTextInputManager.cs" />
<Compile Include="Modules\Toast\ToastHelper.cs" />
Expand Down
1 change: 0 additions & 1 deletion ReactNative/Shell/MainReactPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public IReadOnlyList<IViewManager> CreateViewManagers(
new ReactScrollViewManager(),
new ReactSwitchManager(),
new ReactTextInputManager(),
new ReactMultilineTextInputManager(),
new ReactTextViewManager(),
//new ReactToolbarManager(),
new ReactViewManager(),
Expand Down
35 changes: 35 additions & 0 deletions ReactNative/UIManager/CSSNodeVisitor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Facebook.CSSLayout;
using System;
using System.Collections.Generic;

namespace ReactNative.UIManager
{
abstract class CSSNodeVisitor<T>
{
public T Visit(CSSNode node)
{
if (node == null)
{
throw new ArgumentNullException(nameof(node));
}

var n = node.ChildCount;
if (n == 0)
{
return Make(node, Array.Empty<T>());
}
else
{
var children = new List<T>(n);
foreach (var child in node.Children)
{
children.Add(Visit(child));
}

return Make(node, children);
}
}

protected abstract T Make(CSSNode node, IList<T> children);
}
}
19 changes: 19 additions & 0 deletions ReactNative/UIManager/ILayoutManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Windows.UI.Xaml;

namespace ReactNative.UIManager
{
/// <summary>
/// Interface for overriding layout behavior for a view.
/// </summary>
public interface ILayoutManager
{
/// <summary>
/// Updates the layout of the current instance.
/// </summary>
/// <param name="x">The left coordinate.</param>
/// <param name="y">The top coordinate.</param>
/// <param name="width">The layout width.</param>
/// <param name="height">The layout height.</param>
void UpdateLayout(int x, int y, int width, int height);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void InitializeFromConfig(JObject config)
/// </returns>
public bool ShouldAnimateLayout(FrameworkElement view)
{
return _shouldAnimateLayout && view.Parent != null;
return _shouldAnimateLayout && view.Parent != null && !(view is ILayoutManager);
}

/// <summary>
Expand Down
7 changes: 6 additions & 1 deletion ReactNative/UIManager/NativeViewHierarchyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void UpdateViewExtraData(int tag, object extraData)
/// <param name="parentTag">The parent view tag.</param>
/// <param name="tag">The view tag.</param>
/// <param name="x">The left coordinate.</param>
/// <param name="y">The right coordinate.</param>
/// <param name="y">The top coordinate.</param>
/// <param name="width">The layout width.</param>
/// <param name="height">The layout height.</param>
public void UpdateLayout(int parentTag, int tag, int x, int y, int width, int height)
Expand Down Expand Up @@ -507,10 +507,15 @@ private void DropView(FrameworkElement view)

private void UpdateLayout(FrameworkElement viewToUpdate, int x, int y, int width, int height)
{
var layoutManager = default(ILayoutManager);
if (_layoutAnimator.ShouldAnimateLayout(viewToUpdate))
{
_layoutAnimator.ApplyLayoutUpdate(viewToUpdate, x, y, width, height);
}
else if ((layoutManager = viewToUpdate as ILayoutManager) != null)
{
layoutManager.UpdateLayout(x, y, width, height);
}
else
{
Canvas.SetLeft(viewToUpdate, x);
Expand Down
1 change: 1 addition & 0 deletions ReactNative/UIManager/ViewProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public static class ViewProperties
public const string Value = "value";
public const string ResizeMode = "resizeMode";
public const string TextAlign = "textAlign";
public const string TextAlignVertical = "textAlignVertical";

public const string BorderWidth = "borderWidth";
public const string BorderLeftWidth = "borderLeftWidth";
Expand Down
Loading

0 comments on commit 32c3f31

Please sign in to comment.