Ejemplo n.º 1
0
        public async Task UIManagerModule_CustomEvents_Constants()
        {
            var context          = new ReactContext();
            var viewManagers     = new List <IViewManager>();
            var uiImplementation = new UIImplementation(context, viewManagers);

            var module = await DispatcherHelpers.CallOnDispatcherAsync(
                () => new UIManagerModule(context, viewManagers, uiImplementation));

            var constants = module.Constants;

            Assert.AreEqual("onSelect", constants.GetMap("customBubblingEventTypes").GetMap("topSelect").GetMap("phasedRegistrationNames").GetValue("bubbled"));
            Assert.AreEqual("onSelectCapture", constants.GetMap("customBubblingEventTypes").GetMap("topSelect").GetMap("phasedRegistrationNames").GetValue("captured"));
            Assert.AreEqual("onChange", constants.GetMap("customBubblingEventTypes").GetMap("topChange").GetMap("phasedRegistrationNames").GetValue("bubbled"));
            Assert.AreEqual("onChangeCapture", constants.GetMap("customBubblingEventTypes").GetMap("topChange").GetMap("phasedRegistrationNames").GetValue("captured"));
            Assert.AreEqual("onTouchStart", constants.GetMap("customBubblingEventTypes").GetMap("topTouchStart").GetMap("phasedRegistrationNames").GetValue("bubbled"));
            Assert.AreEqual("onTouchStartCapture", constants.GetMap("customBubblingEventTypes").GetMap("topTouchStart").GetMap("phasedRegistrationNames").GetValue("captured"));
            Assert.AreEqual("onTouchMove", constants.GetMap("customBubblingEventTypes").GetMap("topTouchMove").GetMap("phasedRegistrationNames").GetValue("bubbled"));
            Assert.AreEqual("onTouchMoveCapture", constants.GetMap("customBubblingEventTypes").GetMap("topTouchMove").GetMap("phasedRegistrationNames").GetValue("captured"));
            Assert.AreEqual("onTouchEnd", constants.GetMap("customBubblingEventTypes").GetMap("topTouchEnd").GetMap("phasedRegistrationNames").GetValue("bubbled"));
            Assert.AreEqual("onTouchEndCapture", constants.GetMap("customBubblingEventTypes").GetMap("topTouchEnd").GetMap("phasedRegistrationNames").GetValue("captured"));

            Assert.AreEqual("onSelectionChange", constants.GetMap("customDirectEventTypes").GetMap("topSelectionChange").GetValue("registrationName"));
            Assert.AreEqual("onLoadingStart", constants.GetMap("customDirectEventTypes").GetMap("topLoadingStart").GetValue("registrationName"));
            Assert.AreEqual("onLoadingFinish", constants.GetMap("customDirectEventTypes").GetMap("topLoadingFinish").GetValue("registrationName"));
            Assert.AreEqual("onLoadingError", constants.GetMap("customDirectEventTypes").GetMap("topLoadingError").GetValue("registrationName"));
            Assert.AreEqual("onLayout", constants.GetMap("customDirectEventTypes").GetMap("topLayout").GetValue("registrationName"));
        }
Ejemplo n.º 2
0
        public void UIManagerModule_ArgumentChecks()
        {
            var context          = new ReactContext();
            var viewManagers     = new List <IViewManager>();
            var uiImplementation = new UIImplementation(context, viewManagers);

            AssertEx.Throws <ArgumentNullException>(
                () => new UIManagerModule(context, null, uiImplementation),
                ex => Assert.AreEqual("viewManagers", ex.ParamName));

            AssertEx.Throws <ArgumentNullException>(
                () => new UIManagerModule(context, viewManagers, null),
                ex => Assert.AreEqual("uiImplementation", ex.ParamName));
        }
Ejemplo n.º 3
0
        public PropsAnimatedNode(int tag, JObject config, NativeAnimatedNodesManager manager, UIImplementation uiImplementation)
            : base(tag)
        {
            var props = (JObject)config.GetValue("props", StringComparison.Ordinal);

            _propNodeMapping = new Dictionary <string, int>(props.Count);
            foreach (var entry in props)
            {
                _propNodeMapping.Add(entry.Key, entry.Value.Value <int>());
            }

            _propMap          = new JObject();
            _manager          = manager;
            _uiImplementation = uiImplementation;
        }
Ejemplo n.º 4
0
        public void UIManagerModule_ArgumentChecks()
        {
            var context          = new ReactContext();
            var viewManagers     = new List <IViewManager>();
            var uiImplementation = new UIImplementation(context, viewManagers);

            ArgumentNullException ex1 = Assert.Throws <ArgumentNullException>(
                () => new UIManagerModule(context, null, uiImplementation, new FrameworkElement()));

            Assert.AreEqual("viewManagers", ex1.ParamName);

            ArgumentNullException ex2 = Assert.Throws <ArgumentNullException>(
                () => new UIManagerModule(context, viewManagers, null, new FrameworkElement()));

            Assert.AreEqual("uiImplementation", ex2.ParamName);
        }
Ejemplo n.º 5
0
        public async Task UIManagerModule_Constants_ViewManagerOverrides()
        {
            var context      = new ReactContext();
            var viewManagers = new List <IViewManager> {
                new TestViewManager()
            };
            var uiImplementation = new UIImplementation(context, viewManagers);

            var module = await DispatcherHelpers.CallOnDispatcherAsync(
                () => new UIManagerModule(context, viewManagers, uiImplementation));

            var constants = module.Constants;

            Assert.AreEqual(42, constants.GetMap("customDirectEventTypes").GetValue("otherSelectionChange"));
            Assert.AreEqual(42, constants.GetMap("customDirectEventTypes").GetMap("topSelectionChange").GetValue("registrationName"));
            Assert.AreEqual(42, constants.GetMap("customDirectEventTypes").GetMap("topLoadingStart").GetValue("foo"));
            Assert.AreEqual(42, constants.GetMap("customDirectEventTypes").GetValue("topLoadingError"));
        }
        public void UpdateView(UIImplementation uiImplementation)
        {
            if (ConnectedViewTag == -1)
            {
                throw new InvalidOperationException("Node has not been attached to a view.");
            }

            var propsMap = new JObject();

            foreach (var entry in _propMapping)
            {
                var node      = _manager.GetNodeById(entry.Value);
                var styleNode = node as StyleAnimatedNode;
                var valueNode = default(ValueAnimatedNode);
                if (styleNode != null)
                {
                    styleNode.CollectViewUpdates(propsMap);
                }
                else if ((valueNode = node as ValueAnimatedNode) != null)
                {
                    propsMap.Add(entry.Key, valueNode.Value);
                }
                else
                {
                    throw new InvalidOperationException(
                              Invariant($"Unsupported type of node used in property node '{node.GetType()}'."));
                }
            }

            // TODO: Reuse propsMap and stylesDiffMap objects - note that in
            // subsequent animation steps for a given node most of the time
            // will be creating the same set of props (just with different
            // values). We can take advantage on that and optimize the way we
            // allocate property maps (we also know that updating view props
            // doesn't retain a reference to the styles object).
            var updated = uiImplementation.SynchronouslyUpdateViewOnDispatcherThread(
                ConnectedViewTag,
                new ReactStylesDiffMap(propsMap));

            if (!updated)
            {
                Tracer.Error(ReactConstants.Tag, "Native animation workaround, frame lost as result of race condition.", null);
            }
        }
 public NativeAnimatedNodesManager(UIImplementation uiImplementation)
 {
     this._uiImplementation = uiImplementation;
 }
 public NativeAnimatedNodesManager(UIManagerModule uiManager)
 {
     _uiImplementation = uiManager.UIImplementation;
     uiManager.EventDispatcher.AddListener(this);
     _customEventTypes = GetEventTypes(uiManager);
 }
Ejemplo n.º 9
0
 public NativeAnimatedNodesManager(UIManagerModule uiManager)
 {
     _uiImplementation = uiManager.UIImplementation;
     uiManager.EventDispatcher.AddListener(this);
     _customEventNamesResolver = uiManager.ResolveCustomEventName;
 }