Skip to content

Commit

Permalink
Fixes microsoft#64 - Adds UIImplementation
Browse files Browse the repository at this point in the history
Adds various other stubs that we will need to implement as we move forward.
  • Loading branch information
rozele authored and GantMan committed Sep 29, 2016
1 parent 10df53b commit f918d51
Show file tree
Hide file tree
Showing 18 changed files with 941 additions and 109 deletions.
1 change: 1 addition & 0 deletions ReactNative.Tests/Internal/MockEvent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Newtonsoft.Json.Linq;
using ReactNative.UIManager.Events;
using System;
using System.Collections.Generic;

namespace ReactNative.Tests
{
Expand Down
5 changes: 5 additions & 0 deletions ReactNative.Tests/UIManager/UIManagerModuleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public IReadOnlyDictionary<string, string> NativeProperties
return null;
}
}

public ReactShadowNode CreateShadowNodeInstance()
{
return null;
}
}
}
}
5 changes: 5 additions & 0 deletions ReactNative/ReactNative.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@
<Compile Include="Shell\MainReactPackage.cs" />
<Compile Include="Touch\JSResponderHandler.cs" />
<Compile Include="Touch\OnInterceptTouchEventListener.cs" />
<Compile Include="UIManager\CatalystStylesDiffMap.cs" />
<Compile Include="CSSLayout\CSSLayoutContext.cs" />
<Compile Include="UIManager\Events\Event.cs" />
<Compile Include="UIManager\Events\EventDispatcher.cs" />
<Compile Include="UIManager\Events\RCTEventEmitter.cs" />
Expand All @@ -205,6 +207,8 @@
<Compile Include="UIManager\Events\TouchEventType.cs" />
<Compile Include="UIManager\Events\TouchEventTypeExtensions.cs" />
<Compile Include="UIManager\IViewManager.cs" />
<Compile Include="UIManager\NativeViewHierarchyOptimizer.cs" />
<Compile Include="UIManager\OnLayoutEvent.cs" />
<Compile Include="UIManager\PointerEvents.cs" />
<Compile Include="UIManager\SizeMonitoringFrameLayout.cs" />
<Compile Include="UIManager\NativeViewHierarchyManager.cs" />
Expand All @@ -218,6 +222,7 @@
<Compile Include="UIManager\UIManagerModule.cs" />
<Compile Include="UIManager\UIManagerModule.Constants.cs" />
<Compile Include="UIManager\UIViewOperationQueue.cs" />
<Compile Include="UIManager\ViewAtIndex.cs" />
<Compile Include="UIManager\ViewManager.cs" />
<Compile Include="UIManager\ViewManagerRegistry.cs" />
<Compile Include="UIManager\ViewManagersPropertyCache.cs" />
Expand Down
14 changes: 14 additions & 0 deletions ReactNative/UIManager/CatalystStylesDiffMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Newtonsoft.Json.Linq;

namespace ReactNative.UIManager
{
public class CatalystStylesDiffMap
{
private JObject properties;

public CatalystStylesDiffMap(JObject properties)
{
this.properties = properties;
}
}
}
1 change: 1 addition & 0 deletions ReactNative/UIManager/Events/RCTEventEmitter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Newtonsoft.Json.Linq;
using ReactNative.Bridge;
using System.Collections.Generic;

namespace ReactNative.UIManager.Events
{
Expand Down
6 changes: 6 additions & 0 deletions ReactNative/UIManager/IViewManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,11 @@ public interface IViewManager
/// The native properties.
/// </summary>
IReadOnlyDictionary<string, string> NativeProperties { get; }

/// <summary>
/// Creates a shadow node for the view manager.
/// </summary>
/// <returns>The shadow node instance.</returns>
ReactShadowNode CreateShadowNodeInstance();
}
}
43 changes: 43 additions & 0 deletions ReactNative/UIManager/NativeViewHierarchyOptimizer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;

namespace ReactNative.UIManager
{
class NativeViewHierarchyOptimizer
{
private readonly UIViewOperationQueue _uiViewOperationQueue;
private readonly ShadowNodeRegistry _shadowNodeRegistry;

public NativeViewHierarchyOptimizer(
UIViewOperationQueue uiViewOperationQueue,
ShadowNodeRegistry shadowNodeRegistry)
{
_uiViewOperationQueue = uiViewOperationQueue;
_shadowNodeRegistry = shadowNodeRegistry;
}

internal void OnBatchComplete()
{
throw new NotImplementedException();
}

internal void HandleCreateView(ReactShadowNode cssNode, ThemedReactContext themedContext, CatalystStylesDiffMap styles)
{
throw new NotImplementedException();
}

internal void HandleUpdateView(ReactShadowNode cssNode, string className, CatalystStylesDiffMap styles)
{
throw new NotImplementedException();
}

internal void HandleManageChildren(ReactShadowNode cssNodeToManage, int[] indicesToRemove, int[] tagsToRemove, ViewAtIndex[] viewsToAdd, int[] tagsToDelete)
{
throw new NotImplementedException();
}

internal void HandleRemoveNode(ReactShadowNode nodeToRemove)
{
throw new NotImplementedException();
}
}
}
48 changes: 48 additions & 0 deletions ReactNative/UIManager/OnLayoutEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Newtonsoft.Json.Linq;
using ReactNative.UIManager.Events;
using System;

namespace ReactNative.UIManager
{
class OnLayoutEvent : Event
{
private int _x;
private int _y;
private int _width;
private int _height;

private OnLayoutEvent(int viewTag, int x, int y, int width, int height)
: base(viewTag, TimeSpan.FromTicks(Environment.TickCount))
{
_x = x;
_y = y;
_width = width;
_height = height;
}

public override string EventName
{
get
{
return "topLayout";
}
}

public override void Dispatch(RCTEventEmitter eventEmitter)
{
var eventArgs = new JObject
{
{ "target", ViewTag },
{ "layout", null /* TODO: create layout arguments */ },
};

eventEmitter.receiveEvent(ViewTag, EventName, eventArgs);
}

public static OnLayoutEvent Obtain(int viewTag, int x, int y, int width, int height)
{
// TODO: Introduce pooling mechanism
return new OnLayoutEvent(viewTag, x, y, width, height);
}
}
}
96 changes: 91 additions & 5 deletions ReactNative/UIManager/ReactShadowNode.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

using ReactNative.csslayout;
using ReactNative.CSSLayout;
using System.Collections.Generic;
using System;
using ReactNative.UIManager.Events;

namespace ReactNative.UIManager
{
public class ReactShadowNode : CSSNode
{
private int _ReactTag;
private int _reactTag;
private float _AbsoluteLeft;
private float _AbsoluteTop;
private float _AbsoluteRight;
Expand All @@ -18,9 +19,94 @@ public class ReactShadowNode : CSSNode
private ReactShadowNode mNativeParent;
private List<ReactShadowNode> mNativeChildren;

public int getReactTag()
public int ReactTag
{
return _ReactTag;
get;
set;
}

public string ViewClassName
{
get;
set;
}
public int StyleWidth
{
get;
set;
}

public int StyleHeight
{
get;
set;
}
public ReactShadowNode RootNode
{
get;
set;
}

public ReactShadowNode Parent
{
get;
set;
}

public ThemedReactContext ThemedContext
{
get;
set;
}
public bool IsVirtual { get; internal set; }

public void UpdateProperties(CatalystStylesDiffMap styles)
{
throw new NotImplementedException();
}

internal IList<ReactShadowNode> Children
{
get
{
throw new NotImplementedException();
}
}

public bool IsVirtualAnchor { get; internal set; }
public bool IsLayoutOnly { get; internal set; }
public bool HasUpdates { get; internal set; }
public double LayoutX { get; internal set; }
public double LayoutY { get; internal set; }
public bool ShouldNotifyOnLayout { get; internal set; }
public int ScreenX { get; internal set; }
public int ScreenWidth { get; internal set; }
public int ScreenHeight { get; internal set; }
public int ScreenY { get; internal set; }

internal int IndexOf(ReactShadowNode oldNode)
{
throw new NotImplementedException();
}

internal void CalculateLayout(CSSLayoutContext _layoutContext)
{
throw new NotImplementedException();
}

internal void OnBeforeLayout()
{
throw new NotImplementedException();
}

internal void DispatchUpdates(double absoluteX, double absoluteY, EventDispatcher eventDispatcher, NativeViewHierarchyOptimizer _nativeViewHierarchyOptimizer)
{
throw new NotImplementedException();
}

internal void MarkUpdateSeen()
{
throw new NotImplementedException();
}
}
}
Loading

0 comments on commit f918d51

Please sign in to comment.