Skip to content

Commit

Permalink
Towards #92 - Adds very early prototype of ReactTextViewManager.
Browse files Browse the repository at this point in the history
  • Loading branch information
rozele committed Jan 6, 2016
1 parent 3af3645 commit 3af5070
Show file tree
Hide file tree
Showing 18 changed files with 341 additions and 28 deletions.
4 changes: 2 additions & 2 deletions ReactWindows/Playground/Playground.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Facebook.CSSLayout">
<Reference Include="Facebook.CSSLayout, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\Facebook.CSSLayout.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup />
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
Expand Down
7 changes: 4 additions & 3 deletions ReactWindows/Playground/Resources/main.dev.jsbundle
Original file line number Diff line number Diff line change
Expand Up @@ -1188,12 +1188,13 @@ typeof global!=='undefined'?global:typeof self!=='undefined'?self:this);
__d('react-xaml-wpf/index.ios.js',function(global, require, module, exports) { 'use strict';

var React=require('react-native/Libraries/react-native/react-native.js');var
AppRegistry=React.AppRegistry;var View=React.View;
AppRegistry=React.AppRegistry;var View=React.View;var Text=React.Text;

var ReactRoot=React.createClass({displayName:'ReactRoot',
render:function(){
return (
React.createElement(View,{elevation:'1.0'}));}});
React.createElement(View,{elevation:'1.0'},
React.createElement(Text,null,'Hello React Native')));}});



Expand Down Expand Up @@ -57327,4 +57328,4 @@ module.exports=findDOMNode;
});
;require("InitializeJavaScriptAppEngine");
;require("react-xaml-wpf/index.ios.js");
__SSTOKENSTRING = "@generated SignedSource<<8a9aad82927145a159f9ecb21a3904c7>>";
__SSTOKENSTRING = "@generated SignedSource<<d545c00c0e8f6b3ae9b0c55ce3164c44>>";
6 changes: 5 additions & 1 deletion ReactWindows/ReactNative/ReactNative.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@
<Compile Include="UIManager\ViewManagersPropertyCache.cs" />
<Compile Include="UIManager\ViewProperties.cs" />
<Compile Include="Touch\ICatalystInterceptingViewGroup.cs" />
<Compile Include="Views\Text\ReactRawTextManager.cs" />
<Compile Include="Views\Text\ReactTextShadowNode.cs" />
<Compile Include="Views\Text\ReactTextViewManager.cs" />
<Compile Include="Views\View\ReactPanel.cs" />
<Compile Include="Views\View\ReactViewManager.cs" />
<EmbeddedResource Include="Properties\ReactNative.rd.xml" />
Expand All @@ -269,7 +272,8 @@
<Folder Include="JavaScript\uwp-native\" />
</ItemGroup>
<ItemGroup>
<Reference Include="Facebook.CSSLayout">
<Reference Include="Facebook.CSSLayout, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\Facebook.CSSLayout.dll</HintPath>
</Reference>
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions ReactWindows/ReactNative/Shell/MainReactPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using ReactNative.Modules.Core;
using ReactNative.Modules.WebSocket;
using ReactNative.UIManager;
using ReactNative.Views.Text;
using ReactNative.Views.View;
using System;
using System.Collections.Generic;
using Windows.UI.Xaml;

namespace ReactNative.Shell
{
Expand Down Expand Up @@ -36,12 +36,12 @@ public IReadOnlyList<ViewManager> CreateViewManagers(
//new ReactHorizontalScrollViewManager(),
//new ReactImageManager(),
//new ReactProgressBarViewManager(),
//new ReactRawTextManager(),
new ReactRawTextManager(),
//new RecyclerViewBackedScrollViewManager(),
//new ReactScrollViewManager(),
//new ReactSwitchManager(),
//new ReactTextInputManager(),
//new ReactTextViewManager(),
new ReactTextViewManager(),
//new ReactToolbarManager(),
new ReactViewManager(),
//new ReactViewPagerManager(),
Expand Down
8 changes: 0 additions & 8 deletions ReactWindows/ReactNative/UIManager/BaseViewManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ public abstract class BaseViewManager<TFrameworkElement, TLayoutShadowNode> : Vi
private const string PROP_DECOMPOSED_MATRIX_TRANSLATE_Y = "translateY";
private const string PROP_OPACITY = "opacity";

/// <summary>
/// Sets the background color of the <see cref="ReactPanel"/>.
/// </summary>
/// <param name="view"></param>
/// <param name="backgroundColor"></param>
[ReactProperty(PROP_BACKGROUND_COLOR, DefaultInteger = 0x00FFFFFF /* Colors.Transparent */, CustomType = "Color")]
public abstract void SetBackgroundColor(TFrameworkElement view, int backgroundColor);

/// <summary>
/// Set's the <typeparamref name="TFrameworkElement"/> styling layout
/// properties, based on the <see cref="JObject"/> map.
Expand Down
15 changes: 14 additions & 1 deletion ReactWindows/ReactNative/UIManager/LayoutShadowNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,23 @@ public void SetBorderWidth(int index, float borderWidth)
public void SetPosition(string position)
{
PositionType = position != null
? Parse<CSSPositionType>(position)
? ParsePositionType(position)
: CSSPositionType.Relative;
}

private static CSSPositionType ParsePositionType(string position)
{
switch (position.ToLowerInvariant())
{
case "relative":
return CSSPositionType.Relative;
case "absolute":
return CSSPositionType.Absolute;
default:
throw new ArgumentException("Invalid position type.", position);
}
}

private static T Parse<T>(string value)
{
return (T)Enum.Parse(typeof(T), value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void UpdateLayout(int parentTag, int tag, int x, int y, int width, int he
{
var viewToUpdate = ResolveView(tag);
// TODO: call viewToUpdate.Measure()
throw new NotImplementedException();
//throw new NotImplementedException();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void HandleManageChildren(ReactShadowNode nodeToManage, int[] indicesToRe
// the time this method is called, these views have already been
// removed from the shadow hierarchy and the indices are no longer
// useful to operate on.
for (var i = 0; i< tagsToRemove.Length; ++i)
for (var i = 0; i < tagsToRemove.Length; ++i)
{
var tagToRemove = tagsToRemove[i];
var delete = tagsToDelete.Contains(tagToRemove);
Expand Down
4 changes: 2 additions & 2 deletions ReactWindows/ReactNative/UIManager/ReactShadowNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public virtual bool IsVirtual
/// <see cref="NativeViewHierarchyManager"/> will not try to perform
/// manage children operations on such views.
/// </summary>
public bool IsVirtualAnchor
public virtual bool IsVirtualAnchor
{
get
{
Expand Down Expand Up @@ -534,7 +534,7 @@ internal void DispatchUpdates(
/// <summary>
/// Marks a node as updated.
/// </summary>
protected void MarkUpdated()
protected virtual void MarkUpdated()
{
if (_nodeUpdated)
{
Expand Down
4 changes: 2 additions & 2 deletions ReactWindows/ReactNative/UIManager/SimpleViewManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public abstract class SimpleViewManager<TFrameworkElement> : BaseViewManager<TFr
/// Creates a <see cref="LayoutShadowNode"/> instance.
/// </summary>
/// <returns>The shadow node instance.</returns>
public override ReactShadowNode CreateShadowNodeInstance()
protected sealed override LayoutShadowNode CreateShadowNodeInstanceCore()
{
return new LayoutShadowNode();
}
Expand All @@ -26,7 +26,7 @@ public override ReactShadowNode CreateShadowNodeInstance()
/// </summary>
/// <param name="root">The root view.</param>
/// <param name="extraData">The extra data.</param>
public override void UpdateExtraData(FrameworkElement root, object extraData)
protected override void UpdateExtraData(TFrameworkElement root, object extraData)
{
}
}
Expand Down
2 changes: 1 addition & 1 deletion ReactWindows/ReactNative/UIManager/SizeMonitoringPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ReactNative.UIManager
/// <summary>
/// allows registering for size change events. The main purpose for this class is to hide complexity of ReactRootView
/// </summary>
public partial class SizeMonitoringPanel : Panel
public partial class SizeMonitoringPanel : Grid
{
private ISizeChangedListener _onSizeChangedListener;

Expand Down
4 changes: 2 additions & 2 deletions ReactWindows/ReactNative/UIManager/UIImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public void ManageChildren(
var numToRemove = removeFrom?.Length ?? 0;
var viewsToAdd = new ViewAtIndex[numToMove + numToAdd];
var indicesToRemove = new int[numToMove + numToRemove];
var tagsToRemove = new int[addAtIndices.Length];
var tagsToRemove = new int[indicesToRemove.Length];
var tagsToDelete = new int[numToRemove];

if (numToMove > 0)
Expand All @@ -250,7 +250,7 @@ public void ManageChildren(

if (numToAdd > 0)
{
for (var i = 0; i < numToRemove; ++i)
for (var i = 0; i < numToAdd; ++i)
{
viewsToAdd[numToMove + i] = new ViewAtIndex(addChildTags[i], addAtIndices[i]);
}
Expand Down
33 changes: 33 additions & 0 deletions ReactWindows/ReactNative/Views/Text/ReactRawTextManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using ReactNative.UIManager;
using System;
using Windows.UI.Xaml.Controls;

namespace ReactNative.Views.Text
{
public class ReactRawTextManager : ReactTextViewManager
{
private const string ReactClass = "RCTRawText";

public override string Name
{
get
{
return ReactClass;
}
}

protected override TextBlock CreateViewInstanceCore(ThemedReactContext reactContext)
{
throw new InvalidOperationException("RCTRawText does not map to a native view.");
}

protected override void UpdateExtraData(TextBlock root, object extraData)
{
}

protected override ReactTextShadowNode CreateShadowNodeInstanceCore()
{
return new ReactTextShadowNode(true);
}
}
}
Loading

0 comments on commit 3af5070

Please sign in to comment.