/// <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>
        /// <param name="reactInstanceManager">
        /// The React instance manager.
        /// </param>
        /// <param name="moduleName">The module name.</param>
        public void StartReactApplication(IReactInstanceManager reactInstanceManager, string moduleName)
        {
            DispatcherHelpers.AssertOnDispatcher();

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

            _reactInstanceManager = reactInstanceManager;
            _jsModuleName         = moduleName;

            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;
            }
        }
        /// <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>
        /// <param name="reactInstanceManager">
        /// The React instance manager.
        /// </param>
        /// <param name="moduleName">The module name.</param>
        public void StartReactApplication(IReactInstanceManager reactInstanceManager, string moduleName)
        {
            DispatcherHelpers.AssertOnDispatcher();

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

            _reactInstanceManager = reactInstanceManager;
            _jsModuleName = moduleName;

            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;
            }
        }
示例#3
0
 public CoreModulesPackage(
     IReactInstanceManager reactInstanceManager,
     Action hardwareBackButtonHandler,
     UIImplementationProvider uiImplementationProvider)
 {
     _reactInstanceManager      = reactInstanceManager;
     _hardwareBackButtonHandler = hardwareBackButtonHandler;
     _uiImplementationProvider  = uiImplementationProvider;
 }
 public CoreModulesPackage(
     IReactInstanceManager reactInstanceManager,
     Action hardwareBackButtonHandler,
     UIImplementationProvider uiImplementationProvider)
 {
     _reactInstanceManager = reactInstanceManager;
     _hardwareBackButtonHandler = hardwareBackButtonHandler;
     _uiImplementationProvider = uiImplementationProvider;
 }
        protected override void OnCreate()
        {
            //Log.Info(ReactConstants.Tag, "## ReactProgram ##  Enter Constructor ReactProgram()");
            try
            {
                _reactInstanceManager = CreateReactInstanceManager();
            }
            catch (Exception ex)
            {
                Log.Info(ReactConstants.Tag, "## ReactProgram ## CreateReactInstanceManager Ex:" + ex.ToString());
            }
            //Log.Info(ReactConstants.Tag, "## ReactProgram ##  Exit Constructor ReactProgram()");

            MainSynchronizationContext.Initialize(SynchronizationContext.Current, Exit);

            Elementary.Initialize();
            Elementary.ThemeOverlay();

            //Log.Info(ReactConstants.Tag, "## ReactProgram ##  Enter OnCreate()");

            ResourceDir = DirectoryInfo.Resource;

            // 1. Create root window
            ReactWindow rctWin = new ReactWindow("ElmSharp Window");

            RctWindow = rctWin;
            RctWindow.Show();
            RctWindow.BackButtonPressed += (object sender, EventArgs e) =>
            {
                Log.Debug(ReactConstants.Tag, "## Back button being Pressed ##");
                _reactInstanceManager.OnBackPressed();
            };

            RctWindow.RedButtonPressed += (object sender, EventArgs e) =>
            {
                Log.Debug(ReactConstants.Tag, "## Red button being Pressed ##");
                _reactInstanceManager.DevSupportManager.ShowDevOptionsDialog();
            };

            // 2. Create root view
            RootView = CreateRootView();
            //RootView.Show();


            // 3. Entry of 'JS' world
            RootView.StartReactApplication(_reactInstanceManager, MainComponentName);

            // 4. Set root view
            //RctWindow.Navigator.Push(RootView, "Instagram");
            RctWindow.SetMainPage(RootView);

            base.OnCreate();

            //Log.Info(ReactConstants.Tag, "## ReactProgram ##  Exit OnCreate()");
        }
 /// <summary>
 /// Instantiates the <see cref="ReactPage"/>.
 /// </summary>
 protected ReactPage()
 {
     _reactInstanceManager = CreateReactInstanceManager();
     RootView = CreateRootView();
     Content  = RootView;
 }
示例#7
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>
 /// <param name="reactInstanceManager">
 /// The React instance manager.
 /// </param>
 /// <param name="moduleName">The module name.</param>
 public void StartReactApplication(IReactInstanceManager reactInstanceManager, string moduleName)
 {
     StartReactApplication(reactInstanceManager, moduleName, default(JObject));
 }