Ejemplo n.º 1
0
        public static void UT_DropView(object obj)
        {
            for (int i = 1; i <= 15; i++)
            {
                Log.Info(ReactConstants.Tag, "## UT_DropView ## thread is Waiting>>>>>>>>>>>>>>>[" + i + " sec]");
                Thread.Sleep(1000 * 1);
            }

            ReactInstanceManager RCTIntance = (ReactInstanceManager)obj;
            var currentReactContext         = RCTIntance._currentReactContext;

            Log.Info(ReactConstants.Tag, " ## UT_DropView-2 ## ThreadID=" + Thread.CurrentThread.ManagedThreadId.ToString()
                     + ", RCTIntance=" + RCTIntance);

            if (currentReactContext != null)
            {
                UIManagerModule uiMgrModule = currentReactContext.ReactInstance.GetNativeModule <UIManagerModule>();

                Log.Info(ReactConstants.Tag, "### [BGN-2] Destroy a button view ### ");
                int[] szTagDel     = { 0 };
                int[] szIndicesDel = { 0, };
                uiMgrModule.manageChildren(1, null, null, null, null, szTagDel);
                uiMgrModule.OnBatchComplete();
                Log.Info(ReactConstants.Tag, "### [END-2] Destroy a button view ### ");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Captures the all key downs and Ups.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnAcceleratorKeyActivated(object sender, KeyEventArgs e)
        {
            if (ReactInstanceManager.DevSupportManager.IsEnabled)
            {
                var isCtrlKeyDown = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;

                //Ctrl+D or Ctrl+M
                if (isCtrlKeyDown && (e.Key == Key.D || e.Key == Key.M))
                {
                    ReactInstanceManager.DevSupportManager.ShowDevOptionsDialog();
                }

                // Ctrl+R
                if (isCtrlKeyDown && e.Key == Key.R)
                {
                    ReactInstanceManager.DevSupportManager.HandleReloadJavaScript();
                }
            }

            // Back button
            if (e.Key == Key.Back || e.Key == Key.BrowserBack)
            {
                ReactInstanceManager.OnBackPressed();
            }
        }
        /// <summary>
        /// Schedule rendering of the React component rendered by the
        /// JavaScript application from the given JavaScript module
        /// <paramref name="moduleName"/> using the provided
        /// <paramref name="reactInstanceManager"/> to attach to the JavaScript context of that manager.
        /// Extra parameter
        /// <paramref name="initialProps"/> can be used to pass initial properties for the react component.
        /// </summary>
        /// <param name="reactInstanceManager">
        /// The React instance manager.
        /// </param>
        /// <param name="moduleName">The module name.</param>
        /// <param name="initialProps">The initialProps</param>
        public void StartReactApplication(ReactInstanceManager reactInstanceManager, string moduleName, JObject initialProps)
        {
            DispatcherHelpers.AssertOnDispatcher();

            if (_reactInstanceManager != null)
            {
                throw new InvalidOperationException("This root view has already been attached to an instance manager.");
            }

            _reactInstanceManager = reactInstanceManager;
            _jsModuleName         = moduleName;
            _initialProps         = initialProps;

            if (!_reactInstanceManager.HasStartedCreatingInitialContext)
            {
                _reactInstanceManager.CreateReactContextInBackground();
            }

            // We need to wait for the initial `Measure` call, if this view has
            // not yet been measured, we set the `_attachScheduled` flag, which
            // will enable deferred attachment of the root node.
            if (_wasMeasured)
            {
                _reactInstanceManager.AttachMeasuredRootView(this);
            }
            else
            {
                _attachScheduled = true;
            }
        }
Ejemplo n.º 4
0
        private async Task StartReactApplicationAsync(ReactInstanceManager reactInstanceManager, string moduleName, JObject initialProps)
        {
            // This is called under the dispatcher associated with the view.
            DispatcherHelpers.AssertOnDispatcher(this);

            if (_reactInstanceManager != null)
            {
                throw new InvalidOperationException("This root view has already been attached to an instance manager.");
            }

            _reactInstanceManager = reactInstanceManager;
            _jsModuleName         = moduleName;
            _initialProps         = initialProps;

            var getReactContextTaskTask =
                DispatcherHelpers.CallOnDispatcher(async() => await _reactInstanceManager.GetOrCreateReactContextAsync(CancellationToken.None), true);

            // We need to wait for the initial `Measure` call, if this view has
            // not yet been measured, we set the `_attachScheduled` flag, which
            // will enable deferred attachment of the root node.
            if (_wasMeasured)
            {
                await _reactInstanceManager.AttachMeasuredRootViewAsync(this);
            }
            else
            {
                _attachScheduled = true;
            }

            await getReactContextTaskTask.Unwrap();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Captures the all key downs and Ups.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void OnAcceleratorKeyActivated(object sender, KeyEventArgs e)
        {
            if (ReactInstanceManager.DevSupportManager.IsEnabled)
            {
                var isCtrlKeyDown = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;

                //Ctrl+D or Ctrl+M
                if (isCtrlKeyDown && (e.Key == Key.D || e.Key == Key.M))
                {
                    ReactInstanceManager.DevSupportManager.ShowDevOptionsDialog();
                }

                // Ctrl+R
                if (isCtrlKeyDown && e.Key == Key.R)
                {
                    await ReactInstanceManager.DevSupportManager.CreateReactContextFromPackagerAsync(CancellationToken.None);
                }
            }

            // Back button
            if (e.Key == Key.Back || e.Key == Key.BrowserBack)
            {
                ReactInstanceManager.OnBackPressed();
            }
        }
        /// <summary>
        /// Gets or creates the React context.
        /// </summary>
        /// <param name="manager">The React instance manager.</param>
        /// <param name="token">A token to cancel the request.</param>
        /// <returns>
        /// A task to await the React context.
        /// </returns>
        public static Task <ReactContext> GetOrCreateReactContextAsync(this ReactInstanceManager manager, CancellationToken token)
        {
            if (manager.HasStartedCreatingInitialContext)
            {
                return(manager.GetReactContextAsync(token));
            }

            return(manager.CreateReactContextAsync(token));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Called before the application shuts down.
        /// </summary>
        public async Task DisposeAsync()
        {
            RootView?.RemoveHandler(Keyboard.KeyDownEvent, (KeyEventHandler)OnAcceleratorKeyActivated);

            if (_reactInstanceManager.IsValueCreated)
            {
                await ReactInstanceManager.DisposeAsync().ConfigureAwait(false);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Dispose the current instance and release the reference to it.
        /// </summary>
        /// <returns>
        /// A task to await the dispose operation.
        /// </returns>
        public async Task DisposeAsync()
        {
            if (_reactInstanceManager != null)
            {
                await _reactInstanceManager.DisposeAsync();

                _reactInstanceManager = null;
            }
        }
Ejemplo n.º 9
0
 public CoreModulesPackage(
     ReactInstanceManager reactInstanceManager,
     Action hardwareBackButtonHandler,
     UIImplementationProvider uiImplementationProvider)
 {
     _reactInstanceManager      = reactInstanceManager;
     _hardwareBackButtonHandler = hardwareBackButtonHandler;
     _uiImplementationProvider  = uiImplementationProvider;
 }
 public CoreModulesPackage(
     ReactInstanceManager reactInstanceManager,
     Action hardwareBackButtonHandler,
     UIImplementationProvider uiImplementationProvider,
     bool lazyViewManagersEnabled)
 {
     _reactInstanceManager      = reactInstanceManager;
     _hardwareBackButtonHandler = hardwareBackButtonHandler;
     _uiImplementationProvider  = uiImplementationProvider;
     _lazyViewManagersEnabled   = lazyViewManagersEnabled;
 }
Ejemplo n.º 11
0
        public static void UT_CreateView(object obj)
        {
            ReactInstanceManager RCTIntance = (ReactInstanceManager)obj;
            var currentReactContext         = RCTIntance._currentReactContext;

            Log.Info(ReactConstants.Tag, " ## UT_CreateView-1 ## ThreadID=" + Thread.CurrentThread.ManagedThreadId.ToString()
                     + ", RCTIntance=" + RCTIntance);

            if (currentReactContext != null)
            {
                UIManagerModule uiMgrModule = currentReactContext.ReactInstance.GetNativeModule <UIManagerModule>();
                Log.Info(ReactConstants.Tag, "### [BGN-1] Create a button view ### ");
                var prop1 = default(JObject);
                uiMgrModule.createView(3, "RCTButton", 1, prop1);
                uiMgrModule.OnBatchComplete();

                int[] szTag1     = { 3, };
                int[] szIndices1 = { 0, };
                uiMgrModule.manageChildren(1, null, null, szTag1, szIndices1, null);
                uiMgrModule.OnBatchComplete();
                Log.Info(ReactConstants.Tag, "### [END-1] Create a button view ### ");
            }
        }
        /// <summary>
        /// Schedule rendering of the React component rendered by the
        /// JavaScript application from the given JavaScript module
        /// <paramref name="moduleName"/> using the provided
        /// <paramref name="reactInstanceManager"/> to attach to the JavaScript context of that manager.
        /// Extra parameter
        /// <paramref name="initialProps"/> can be used to pass initial properties for the react component.
        /// </summary>
        /// <param name="reactInstanceManager">
        /// The React instance manager.
        /// </param>
        /// <param name="moduleName">The module name.</param>
        /// <param name="initialProps">The initialProps</param>
        public async void StartReactApplication(ReactInstanceManager reactInstanceManager, string moduleName, JObject initialProps)
        {
            DispatcherHelpers.AssertOnDispatcher();

            if (_reactInstanceManager != null)
            {
                throw new InvalidOperationException("This root view has already been attached to an instance manager.");
            }

            _reactInstanceManager = reactInstanceManager;
            _jsModuleName         = moduleName;
            _initialProps         = initialProps;

            var getReactContextTask = default(Task);

            if (!_reactInstanceManager.HasStartedCreatingInitialContext)
            {
                getReactContextTask = _reactInstanceManager.GetOrCreateReactContextAsync(CancellationToken.None);
            }

            // We need to wait for the initial `Measure` call, if this view has
            // not yet been measured, we set the `_attachScheduled` flag, which
            // will enable deferred attachment of the root node.
            if (_wasMeasured)
            {
                _reactInstanceManager.AttachMeasuredRootView(this);
            }
            else
            {
                _attachScheduled = true;
            }

            if (getReactContextTask != null)
            {
                await getReactContextTask.ConfigureAwait(false);
            }
        }
 public ReactInstanceDevCommandsHandler(ReactInstanceManager parent)
 {
     _parent = parent;
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Schedule rendering of the React component rendered by the
 /// JavaScript application from the given JavaScript module
 /// <paramref name="moduleName"/> using the provided
 /// <paramref name="reactInstanceManager"/> to attach to the JavaScript
 /// context of that manager.
 /// </summary>
 /// <remarks>
 /// Has to be called under the dispatcher the view is associated to.
 /// </remarks>
 /// <param name="reactInstanceManager">
 /// The React instance manager.
 /// </param>
 /// <param name="moduleName">The module name.</param>
 public void StartReactApplication(ReactInstanceManager reactInstanceManager, string moduleName)
 {
     StartReactApplication(reactInstanceManager, moduleName, default(JObject));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Schedule rendering of the React component rendered by the
 /// JavaScript application from the given JavaScript module
 /// <paramref name="moduleName"/> using the provided
 /// <paramref name="reactInstanceManager"/> to attach to the JavaScript context of that manager.
 /// Extra parameter
 /// <paramref name="initialProps"/> can be used to pass initial properties for the react component.
 /// </summary>
 /// <remarks>
 /// Has to be called under the dispatcher associated with the view.
 /// </remarks>
 /// <param name="reactInstanceManager">
 /// The React instance manager.
 /// </param>
 /// <param name="moduleName">The module name.</param>
 /// <param name="initialProps">The initialProps</param>
 ///
 public void StartReactApplication(ReactInstanceManager reactInstanceManager, string moduleName, JObject initialProps)
 {
     // Fire and forget async
     Forget(StartReactApplicationAsync(reactInstanceManager, moduleName, initialProps));
 }
 public ReactInstanceDevCommandsHandler(ReactInstanceManager parent)
 {
     _parent = parent;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Called when the application is resumed.
 /// </summary>
 /// <param name="onBackPressed">
 /// Default action to take when back pressed.
 /// </param>
 public void OnResume(Action onBackPressed)
 {
     ReactInstanceManager.OnResume(onBackPressed);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Called before the application is suspended.
 /// </summary>
 public void OnSuspend()
 {
     ReactInstanceManager.OnSuspend();
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Instantiates the <see cref="ReactPage"/>.
 /// </summary>
 protected ReactPage()
 {
     _reactInstanceManager = CreateReactInstanceManager();
     RootView = CreateRootView();
     Content  = RootView;
 }