Aucune description

ReactWebViewManager.h 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // Licensed under the MIT License.
  3. #pragma once
  4. #include "winrt/Microsoft.ReactNative.h"
  5. #include "NativeModules.h"
  6. #include "ReactWebView.h"
  7. namespace winrt::ReactNativeWebView::implementation {
  8. enum class WebViewCommands : int32_t { GoForward = 0, GoBack = 1, Reload = 2, StopLoading = 3, InjectJavaScript = 4 };
  9. class ReactWebViewManager : public winrt::implements<
  10. ReactWebViewManager,
  11. winrt::Microsoft::ReactNative::IViewManager,
  12. winrt::Microsoft::ReactNative::IViewManagerWithReactContext,
  13. winrt::Microsoft::ReactNative::IViewManagerWithNativeProperties,
  14. winrt::Microsoft::ReactNative::IViewManagerWithExportedEventTypeConstants,
  15. winrt::Microsoft::ReactNative::IViewManagerWithCommands> {
  16. public:
  17. ReactWebViewManager();
  18. // IViewManager
  19. winrt::hstring Name() noexcept;
  20. winrt::Windows::UI::Xaml::FrameworkElement CreateView() noexcept;
  21. // IViewManagerWithReactContext
  22. winrt::Microsoft::ReactNative::IReactContext ReactContext() noexcept;
  23. void ReactContext(winrt::Microsoft::ReactNative::IReactContext reactContext) noexcept;
  24. // IViewManagerWithNativeProperties
  25. winrt::Windows::Foundation::Collections::
  26. IMapView<winrt::hstring, winrt::Microsoft::ReactNative::ViewManagerPropertyType>
  27. NativeProps() noexcept;
  28. void UpdateProperties(
  29. winrt::Windows::UI::Xaml::FrameworkElement const& view,
  30. winrt::Microsoft::ReactNative::IJSValueReader const& propertyMapReader) noexcept;
  31. // IViewManagerWithExportedEventTypeConstants
  32. winrt::Microsoft::ReactNative::ConstantProviderDelegate ExportedCustomBubblingEventTypeConstants() noexcept;
  33. winrt::Microsoft::ReactNative::ConstantProviderDelegate ExportedCustomDirectEventTypeConstants() noexcept;
  34. // IViewManagerWithCommands
  35. winrt::Windows::Foundation::Collections::IMapView<winrt::hstring, int64_t> Commands() noexcept;
  36. void DispatchCommand(
  37. winrt::Windows::UI::Xaml::FrameworkElement const& view,
  38. int64_t commandId,
  39. winrt::Microsoft::ReactNative::IJSValueReader const& commandArgsReader) noexcept;
  40. private:
  41. winrt::ReactNativeWebView::ReactWebView m_reactWebView{ nullptr };
  42. winrt::Microsoft::ReactNative::IReactContext m_reactContext{ nullptr };
  43. };
  44. } // namespace winrt::ReactWebView::implementation