コード例 #1
0
        private void CreateReactView()
        {
            if (RendererManager.Debug && !Settings.CanDrawOverlays(RendererManager.Activity))
            {
                // Debug mode without overlay permissions not supported.
                System.Console.WriteLine("[ReactNative.Forms] Debug mode without overlay permissions not supported.");
                return;
            }

            _rootView        = new ReactRootView(Context);
            _instanceManager = ReactInstanceManager.Builder()
                               .SetApplication(RendererManager.Activity.Application)
                               .SetBundleAssetName(Element.BundleName)
                               .SetJSMainModulePath(Element.ModulePath)
                               .AddPackage(new MainReactPackage())
                               .SetUseDeveloperSupport(RendererManager.Debug)
                               .SetInitialLifecycleState(LifecycleState.Resumed)
                               .Build();

            _instanceManager.AddReactInstanceEventListener(this);

            // convert dictionary to bundle
            var props = new Bundle();

            foreach (KeyValuePair <string, object> entry in Element.Properties)
            {
                props.PutString(entry.Key, (string)entry.Value);
            }

            _rootView.StartReactApplication(_instanceManager, Element.ModuleName, props);
        }