react-native-screens 4.11.0-beta.0 → 4.11.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/RNScreens.podspec +3 -1
  2. package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +18 -12
  3. package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +48 -97
  4. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +4 -124
  5. package/android/src/main/java/com/swmansion/rnscreens/bottomsheet/SheetDelegate.kt +2 -2
  6. package/android/src/main/java/com/swmansion/rnscreens/bottomsheet/SheetUtils.kt +23 -0
  7. package/android/src/main/java/com/swmansion/rnscreens/stack/anim/ScreensAnimation.kt +18 -0
  8. package/android/src/main/java/com/swmansion/rnscreens/stack/views/ChildDrawingOrderStrategyImpl.kt +48 -0
  9. package/android/src/main/java/com/swmansion/rnscreens/stack/views/ChildrenDrawingOrderStrategy.kt +24 -0
  10. package/android/src/main/java/com/swmansion/rnscreens/stack/views/ScreensCoordinatorLayout.kt +99 -0
  11. package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp +1 -2
  12. package/ios/RNSConvert.mm +44 -47
  13. package/ios/RNSFullWindowOverlay.h +2 -0
  14. package/ios/RNSFullWindowOverlay.mm +32 -8
  15. package/ios/RNSScreen.mm +20 -34
  16. package/ios/RNSScreenStack.mm +6 -8
  17. package/ios/RNSScreenStackHeaderConfig.mm +120 -223
  18. package/ios/RNSScreenWindowTraits.mm +19 -37
  19. package/ios/RNSSearchBar.mm +15 -24
  20. package/lib/commonjs/components/FullWindowOverlay.js +2 -1
  21. package/lib/commonjs/components/FullWindowOverlay.js.map +1 -1
  22. package/lib/commonjs/components/ScreenContentWrapper.windows.js +10 -0
  23. package/lib/commonjs/components/ScreenContentWrapper.windows.js.map +1 -0
  24. package/lib/commonjs/components/ScreenFooter.windows.js +11 -0
  25. package/lib/commonjs/components/ScreenFooter.windows.js.map +1 -0
  26. package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js +1 -0
  27. package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js.map +1 -1
  28. package/lib/module/components/FullWindowOverlay.js +2 -1
  29. package/lib/module/components/FullWindowOverlay.js.map +1 -1
  30. package/lib/module/components/ScreenContentWrapper.windows.js +4 -0
  31. package/lib/module/components/ScreenContentWrapper.windows.js.map +1 -0
  32. package/lib/module/components/ScreenFooter.windows.js +6 -0
  33. package/lib/module/components/ScreenFooter.windows.js.map +1 -0
  34. package/lib/module/fabric/FullWindowOverlayNativeComponent.js +3 -0
  35. package/lib/module/fabric/FullWindowOverlayNativeComponent.js.map +1 -1
  36. package/lib/typescript/components/FullWindowOverlay.d.ts +4 -2
  37. package/lib/typescript/components/FullWindowOverlay.d.ts.map +1 -1
  38. package/lib/typescript/components/ScreenContentWrapper.windows.d.ts +4 -0
  39. package/lib/typescript/components/ScreenContentWrapper.windows.d.ts.map +1 -0
  40. package/lib/typescript/components/ScreenFooter.windows.d.ts +6 -0
  41. package/lib/typescript/components/ScreenFooter.windows.d.ts.map +1 -0
  42. package/lib/typescript/fabric/FullWindowOverlayNativeComponent.d.ts +3 -1
  43. package/lib/typescript/fabric/FullWindowOverlayNativeComponent.d.ts.map +1 -1
  44. package/lib/typescript/native-stack/types.d.ts +1 -1
  45. package/lib/typescript/types.d.ts +2 -2
  46. package/native-stack/README.md +2 -2
  47. package/package.json +1 -1
  48. package/src/components/FullWindowOverlay.tsx +14 -3
  49. package/src/components/ScreenContentWrapper.windows.tsx +5 -0
  50. package/src/components/ScreenFooter.windows.tsx +7 -0
  51. package/src/fabric/FullWindowOverlayNativeComponent.ts +5 -1
  52. package/src/native-stack/types.tsx +1 -1
  53. package/src/types.tsx +2 -2
  54. package/windows/RNScreens/ModalScreenViewManager.cpp +22 -0
  55. package/windows/RNScreens/ModalScreenViewManager.h +13 -0
  56. package/windows/RNScreens/RNScreens.vcxproj +11 -1
  57. package/windows/RNScreens/RNScreens.vcxproj.filters +10 -0
  58. package/windows/RNScreens/ReactPackageProvider.cpp +18 -0
  59. package/windows/RNScreens/Screen.cpp +128 -122
  60. package/windows/RNScreens/Screen.h +6 -2
  61. package/windows/RNScreens/ScreenStackHeaderConfig.cpp +25 -1
  62. package/windows/RNScreens/ScreenStackHeaderConfig.h +10 -1
  63. package/windows/RNScreens/ScreenStackHeaderConfigViewManager.cpp +42 -1
  64. package/windows/RNScreens/ScreenStackHeaderConfigViewManager.h +15 -0
  65. package/windows/RNScreens/ScreenStackHeaderSubview.cpp +43 -0
  66. package/windows/RNScreens/ScreenStackHeaderSubview.h +24 -0
  67. package/windows/RNScreens/ScreenStackHeaderSubviewViewManager.cpp +129 -0
  68. package/windows/RNScreens/ScreenStackHeaderSubviewViewManager.h +77 -0
  69. package/windows/RNScreens/ScreenViewManager.cpp +45 -16
  70. package/windows/RNScreens/ScreenViewManager.h +1 -1
  71. package/windows/RNScreens/SearchBar.cpp +19 -0
  72. package/windows/RNScreens/SearchBar.h +14 -0
  73. package/windows/RNScreens/SearchBarViewManager.cpp +88 -0
  74. package/windows/RNScreens/SearchBarViewManager.h +62 -0
@@ -1,122 +1,128 @@
1
- #include "pch.h"
2
- #include "Screen.h"
3
- #include "JSValueXaml.h"
4
- #include "NativeModules.h"
5
-
6
-
7
- namespace winrt {
8
- using namespace Microsoft::ReactNative;
9
- using namespace Windows::Foundation;
10
- using namespace Windows::Foundation::Collections;
11
- using namespace Windows::UI;
12
- using namespace Windows::UI::Xaml;
13
- using namespace Windows::UI::Xaml::Controls;
14
- } // namespace winrt
15
-
16
- namespace winrt::RNScreens::implementation {
17
- Screen::Screen(winrt::Microsoft::ReactNative::IReactContext reactContext)
18
- : m_reactContext(reactContext) {
19
- onLoadingRevoker = Loading({this, &Screen::onLoading});
20
- onLoadedRevoker = Loaded({this, &Screen::onLoaded});
21
- onUnloadedRevoker = Unloaded({this, &Screen::onUnloaded});
22
- }
23
-
24
- Screen::~Screen() {
25
- Loading(onLoadingRevoker);
26
- Loaded(onLoadedRevoker);
27
- Unloaded(onUnloadedRevoker);
28
- }
29
-
30
- void Screen::addView(winrt::Windows::UI::Xaml::UIElement element) {
31
- Children().Append(element);
32
- }
33
-
34
- void Screen::removeAllChildren() {
35
- Children().Clear();
36
- }
37
-
38
- void Screen::removeChildAt(int64_t index) {
39
- Children().RemoveAt(static_cast<uint32_t>(index));
40
- }
41
-
42
- void Screen::replaceChild(
43
- winrt::Windows::UI::Xaml::UIElement oldChild,
44
- winrt::Windows::UI::Xaml::UIElement newChild) {
45
- uint32_t index;
46
- if (!Children().IndexOf(oldChild, index))
47
- return;
48
-
49
- Children().SetAt(index, newChild);
50
- }
51
-
52
- void Screen::onLoading(
53
- winrt::Windows::UI::Xaml::FrameworkElement const &sender,
54
- winrt::Windows::Foundation::IInspectable const &) {
55
- auto screen = sender.try_as<Screen>();
56
- if (!screen)
57
- return;
58
-
59
- screen->dispatchOnWillAppear();
60
- }
61
-
62
- void Screen::onLoaded(
63
- winrt::Windows::Foundation::IInspectable const &sender,
64
- winrt::Windows::UI::Xaml::RoutedEventArgs const &) {
65
- auto screen = sender.try_as<Screen>();
66
- if (!screen)
67
- return;
68
-
69
- screen->dispatchOnAppear();
70
- }
71
-
72
- void Screen::onUnloaded(
73
- winrt::Windows::Foundation::IInspectable const &sender,
74
- winrt::Windows::UI::Xaml::RoutedEventArgs const &) {
75
- auto screen = sender.try_as<Screen>();
76
- if (!screen)
77
- return;
78
-
79
- screen->dispatchOnWillDisappear();
80
- screen->dispatchOnDisappear();
81
- }
82
-
83
- void Screen::dispatchOnWillAppear() {
84
- m_reactContext.DispatchEvent(
85
- *this,
86
- L"topWillAppear",
87
- [&](winrt::IJSValueWriter const &eventDataWriter) noexcept {
88
- eventDataWriter.WriteObjectBegin();
89
- eventDataWriter.WriteObjectEnd();
90
- });
91
- }
92
-
93
- void Screen::dispatchOnWillDisappear() {
94
- m_reactContext.DispatchEvent(
95
- *this,
96
- L"topWillDisappear",
97
- [&](winrt::IJSValueWriter const &eventDataWriter) noexcept {
98
- eventDataWriter.WriteObjectBegin();
99
- eventDataWriter.WriteObjectEnd();
100
- });
101
- }
102
-
103
- void Screen::dispatchOnAppear() {
104
- m_reactContext.DispatchEvent(
105
- *this,
106
- L"topAppear",
107
- [&](winrt::IJSValueWriter const &eventDataWriter) noexcept {
108
- eventDataWriter.WriteObjectBegin();
109
- eventDataWriter.WriteObjectEnd();
110
- });
111
- }
112
-
113
- void Screen::dispatchOnDisappear() {
114
- m_reactContext.DispatchEvent(
115
- *this,
116
- L"topDisappear",
117
- [&](winrt::IJSValueWriter const &eventDataWriter) noexcept {
118
- eventDataWriter.WriteObjectBegin();
119
- eventDataWriter.WriteObjectEnd();
120
- });
121
- }
122
- } // namespace winrt::RNScreens::implementation
1
+ #include "pch.h"
2
+ #include "Screen.h"
3
+ #include "JSValueXaml.h"
4
+ #include "NativeModules.h"
5
+
6
+
7
+ namespace winrt {
8
+ using namespace Microsoft::ReactNative;
9
+ using namespace Windows::Foundation;
10
+ using namespace Windows::Foundation::Collections;
11
+ using namespace Windows::UI;
12
+ using namespace Windows::UI::Xaml;
13
+ using namespace Windows::UI::Xaml::Controls;
14
+ } // namespace winrt
15
+
16
+ namespace winrt::RNScreens::implementation {
17
+ Screen::Screen(winrt::Microsoft::ReactNative::IReactContext reactContext)
18
+ : m_reactContext(reactContext) {
19
+ onLoadingRevoker = Loading({this, &Screen::onLoading});
20
+ onLoadedRevoker = Loaded({this, &Screen::onLoaded});
21
+ onUnloadedRevoker = Unloaded({this, &Screen::onUnloaded});
22
+ }
23
+
24
+ Screen::~Screen() {
25
+ Loading(onLoadingRevoker);
26
+ Loaded(onLoadedRevoker);
27
+ Unloaded(onUnloadedRevoker);
28
+ }
29
+
30
+ void Screen::addView(winrt::Windows::UI::Xaml::UIElement element) {
31
+ Children().Append(element);
32
+ }
33
+
34
+ void Screen::removeAllChildren() {
35
+ Children().Clear();
36
+ }
37
+
38
+ void Screen::removeChildAt(int64_t index) {
39
+ Children().RemoveAt(static_cast<uint32_t>(index));
40
+ }
41
+
42
+ void Screen::replaceChild(
43
+ winrt::Windows::UI::Xaml::UIElement oldChild,
44
+ winrt::Windows::UI::Xaml::UIElement newChild) {
45
+ uint32_t index;
46
+ if (!Children().IndexOf(oldChild, index))
47
+ return;
48
+
49
+ Children().SetAt(index, newChild);
50
+ }
51
+
52
+ void Screen::onLoading(
53
+ winrt::Windows::UI::Xaml::FrameworkElement const &sender,
54
+ winrt::Windows::Foundation::IInspectable const &) {
55
+ auto screen = sender.try_as<Screen>();
56
+ if (!screen)
57
+ return;
58
+
59
+ screen->dispatchOnWillAppear();
60
+ }
61
+
62
+ void Screen::onLoaded(
63
+ winrt::Windows::Foundation::IInspectable const &sender,
64
+ winrt::Windows::UI::Xaml::RoutedEventArgs const &) {
65
+ auto screen = sender.try_as<Screen>();
66
+ if (!screen)
67
+ return;
68
+
69
+ screen->dispatchOnAppear();
70
+ }
71
+
72
+ void Screen::onUnloaded(
73
+ winrt::Windows::Foundation::IInspectable const &sender,
74
+ winrt::Windows::UI::Xaml::RoutedEventArgs const &) {
75
+ auto screen = sender.try_as<Screen>();
76
+ if (!screen)
77
+ return;
78
+
79
+ screen->dispatchOnWillDisappear();
80
+ screen->dispatchOnDisappear();
81
+ }
82
+
83
+ void Screen::dispatchOnWillAppear() {
84
+ m_reactContext.DispatchEvent(
85
+ *this,
86
+ L"topWillAppear",
87
+ [&](winrt::IJSValueWriter const &eventDataWriter) noexcept {
88
+ eventDataWriter.WriteObjectBegin();
89
+ eventDataWriter.WriteObjectEnd();
90
+ });
91
+ }
92
+
93
+ void Screen::dispatchOnWillDisappear() {
94
+ m_reactContext.DispatchEvent(
95
+ *this,
96
+ L"topWillDisappear",
97
+ [&](winrt::IJSValueWriter const &eventDataWriter) noexcept {
98
+ eventDataWriter.WriteObjectBegin();
99
+ eventDataWriter.WriteObjectEnd();
100
+ });
101
+ }
102
+
103
+ void Screen::dispatchOnAppear() {
104
+ m_reactContext.DispatchEvent(
105
+ *this,
106
+ L"topAppear",
107
+ [&](winrt::IJSValueWriter const &eventDataWriter) noexcept {
108
+ eventDataWriter.WriteObjectBegin();
109
+ eventDataWriter.WriteObjectEnd();
110
+ });
111
+ }
112
+
113
+ void Screen::dispatchOnDisappear() {
114
+ m_reactContext.DispatchEvent(
115
+ *this,
116
+ L"topDisappear",
117
+ [&](winrt::IJSValueWriter const &eventDataWriter) noexcept {
118
+ eventDataWriter.WriteObjectBegin();
119
+ eventDataWriter.WriteObjectEnd();
120
+ });
121
+ }
122
+ StackAnimation Screen::GetStackAnimation() const {
123
+ return stackAnimation;
124
+ }
125
+ void Screen::SetStackAnimation(StackAnimation const& animation) {
126
+ stackAnimation = animation;
127
+ }
128
+ } // namespace winrt::RNScreens::implementation
@@ -2,15 +2,16 @@
2
2
 
3
3
  namespace winrt::RNScreens::implementation {
4
4
 
5
- enum class StackPresentation { PUSH, MODAL, TRANSPARENT_MODAL };
5
+ enum class StackPresentation { PUSH, MODAL, TRANSPARENT_MODAL, FORM_SHEET };
6
6
 
7
7
  enum class StackAnimation {
8
8
  DEFAULT,
9
9
  NONE,
10
10
  FADE,
11
- SIMPLE_FROM_BOTTOM,
11
+ SLIDE_FROM_BOTTOM,
12
12
  SLIDE_FROM_RIGHT,
13
13
  SLIDE_FROM_LEFT,
14
+ FADE_FROM_BOTTOM,
14
15
  IOS_FROM_RIGHT,
15
16
  IOS_FROM_LEFT
16
17
  };
@@ -59,8 +60,11 @@ class Screen : public winrt::Windows::UI::Xaml::Controls::StackPanelT<Screen> {
59
60
  void dispatchOnDisappear();
60
61
  void dispatchOnWillAppear();
61
62
  void dispatchOnWillDisappear();
63
+ StackAnimation GetStackAnimation() const;
64
+ void SetStackAnimation(StackAnimation const& animation);
62
65
 
63
66
  private:
64
67
  winrt::Microsoft::ReactNative::IReactContext m_reactContext{nullptr};
68
+ StackAnimation stackAnimation;
65
69
  };
66
70
  } // namespace winrt::RNScreens::implementation
@@ -15,5 +15,29 @@ using namespace Windows::UI::Xaml::Controls;
15
15
  namespace winrt::RNScreens::implementation {
16
16
  ScreenStackHeaderConfig::ScreenStackHeaderConfig(
17
17
  winrt::Microsoft::ReactNative::IReactContext reactContext)
18
- : m_reactContext(reactContext) {}
18
+ : m_reactContext(reactContext),
19
+ m_children(
20
+ {winrt::single_threaded_vector<Windows::UI::Xaml::UIElement>()}) {}
21
+
22
+ void ScreenStackHeaderConfig::addView(winrt::Windows::UI::Xaml::UIElement element) {
23
+ Children().Append(element);
24
+ }
25
+
26
+ void ScreenStackHeaderConfig::removeAllChildren() {
27
+ Children().Clear();
28
+ }
29
+
30
+ void ScreenStackHeaderConfig::removeChildAt(int64_t index) {
31
+ Children().RemoveAt(static_cast<uint32_t>(index));
32
+ }
33
+
34
+ void ScreenStackHeaderConfig::replaceChild(
35
+ winrt::Windows::UI::Xaml::UIElement oldChild,
36
+ winrt::Windows::UI::Xaml::UIElement newChild) {
37
+ uint32_t index;
38
+ if (!Children().IndexOf(oldChild, index))
39
+ return;
40
+
41
+ Children().SetAt(index, newChild);
42
+ }
19
43
  } // namespace winrt::RNScreens::implementation
@@ -6,8 +6,17 @@ class ScreenStackHeaderConfig
6
6
  ScreenStackHeaderConfig> {
7
7
  public:
8
8
  ScreenStackHeaderConfig(
9
- winrt::Microsoft::ReactNative::IReactContext m_reactContext);
9
+ winrt::Microsoft::ReactNative::IReactContext reactContext);
10
10
 
11
+ void addView(winrt::Windows::UI::Xaml::UIElement element);
12
+ void removeAllChildren();
13
+ void removeChildAt(int64_t index);
14
+ void replaceChild(
15
+ winrt::Windows::UI::Xaml::UIElement oldChild,
16
+ winrt::Windows::UI::Xaml::UIElement newChild);
17
+
18
+ winrt::Windows::Foundation::Collections::IVector<Windows::UI::Xaml::UIElement>
19
+ m_children;
11
20
  private:
12
21
  winrt::Microsoft::ReactNative::IReactContext m_reactContext{nullptr};
13
22
  };
@@ -26,7 +26,48 @@ ScreenStackHeaderConfigViewManager::CreateView() noexcept {
26
26
 
27
27
  // IViewManagerRequiresNativeLayout
28
28
  bool ScreenStackHeaderConfigViewManager::RequiresNativeLayout() {
29
- return true;
29
+ return false;
30
+ }
31
+
32
+ // IViewManagerWithChildren
33
+ void ScreenStackHeaderConfigViewManager::AddView(
34
+ FrameworkElement parent,
35
+ UIElement child,
36
+ int64_t index) {
37
+ auto screenStackHeaderConfig = parent.as<ScreenStackHeaderConfig>();
38
+ if (!screenStackHeaderConfig)
39
+ return;
40
+
41
+ screenStackHeaderConfig->addView(child);
42
+ }
43
+
44
+ void ScreenStackHeaderConfigViewManager::RemoveAllChildren(FrameworkElement parent) {
45
+ auto screenStackHeaderConfig = parent.as<ScreenStackHeaderConfig>();
46
+ if (!screenStackHeaderConfig)
47
+ return;
48
+
49
+ screenStackHeaderConfig->removeAllChildren();
50
+ }
51
+
52
+ void ScreenStackHeaderConfigViewManager::RemoveChildAt(
53
+ FrameworkElement parent,
54
+ int64_t index) {
55
+ auto screenStackHeaderConfig = parent.as<ScreenStackHeaderConfig>();
56
+ if (!screenStackHeaderConfig)
57
+ return;
58
+
59
+ screenStackHeaderConfig->removeChildAt(index);
60
+ }
61
+
62
+ void ScreenStackHeaderConfigViewManager::ReplaceChild(
63
+ FrameworkElement parent,
64
+ UIElement oldChild,
65
+ UIElement newChild) {
66
+ auto screenStackHeaderConfig = parent.as<ScreenStackHeaderConfig>();
67
+ if (!screenStackHeaderConfig)
68
+ return;
69
+
70
+ screenStackHeaderConfig->replaceChild(oldChild, newChild);
30
71
  }
31
72
 
32
73
  // IViewManagerWithReactContext
@@ -10,6 +10,7 @@ class ScreenStackHeaderConfigViewManager
10
10
  winrt::Microsoft::ReactNative::IViewManager,
11
11
  winrt::Microsoft::ReactNative::IViewManagerRequiresNativeLayout,
12
12
  winrt::Microsoft::ReactNative::IViewManagerWithReactContext,
13
+ winrt::Microsoft::ReactNative::IViewManagerWithChildren,
13
14
  winrt::Microsoft::ReactNative::IViewManagerWithNativeProperties,
14
15
  winrt::Microsoft::ReactNative::
15
16
  IViewManagerWithExportedEventTypeConstants,
@@ -24,6 +25,20 @@ class ScreenStackHeaderConfigViewManager
24
25
  // IViewManagerRequiresNativeLayout
25
26
  bool RequiresNativeLayout();
26
27
 
28
+ // IViewManagerWithChildren
29
+ void AddView(
30
+ winrt::Windows::UI::Xaml::FrameworkElement parent,
31
+ winrt::Windows::UI::Xaml::UIElement child,
32
+ int64_t index);
33
+ void RemoveAllChildren(winrt::Windows::UI::Xaml::FrameworkElement parent);
34
+ void RemoveChildAt(
35
+ winrt::Windows::UI::Xaml::FrameworkElement parent,
36
+ int64_t index);
37
+ void ReplaceChild(
38
+ winrt::Windows::UI::Xaml::FrameworkElement parent,
39
+ winrt::Windows::UI::Xaml::UIElement oldChild,
40
+ winrt::Windows::UI::Xaml::UIElement newChild);
41
+
27
42
  // IViewManagerWithReactContext
28
43
  winrt::Microsoft::ReactNative::IReactContext ReactContext() noexcept;
29
44
  void ReactContext(
@@ -0,0 +1,43 @@
1
+ #include "pch.h"
2
+ #include "ScreenStackHeaderSubview.h"
3
+ #include "JSValueXaml.h"
4
+ #include "NativeModules.h"
5
+
6
+ namespace winrt {
7
+ using namespace Microsoft::ReactNative;
8
+ using namespace Windows::Foundation;
9
+ using namespace Windows::Foundation::Collections;
10
+ using namespace Windows::UI;
11
+ using namespace Windows::UI::Xaml;
12
+ using namespace Windows::UI::Xaml::Controls;
13
+ } // namespace winrt
14
+
15
+ namespace winrt::RNScreens::implementation {
16
+ ScreenStackHeaderSubview::ScreenStackHeaderSubview(
17
+ winrt::Microsoft::ReactNative::IReactContext reactContext)
18
+ : m_reactContext(reactContext),
19
+ m_children(
20
+ {winrt::single_threaded_vector<Windows::UI::Xaml::UIElement>()}) {}
21
+
22
+ void ScreenStackHeaderSubview::addView(winrt::Windows::UI::Xaml::UIElement element) {
23
+ Children().Append(element);
24
+ }
25
+
26
+ void ScreenStackHeaderSubview::removeAllChildren() {
27
+ Children().Clear();
28
+ }
29
+
30
+ void ScreenStackHeaderSubview::removeChildAt(int64_t index) {
31
+ Children().RemoveAt(static_cast<uint32_t>(index));
32
+ }
33
+
34
+ void ScreenStackHeaderSubview::replaceChild(
35
+ winrt::Windows::UI::Xaml::UIElement oldChild,
36
+ winrt::Windows::UI::Xaml::UIElement newChild) {
37
+ uint32_t index;
38
+ if (!Children().IndexOf(oldChild, index))
39
+ return;
40
+
41
+ Children().SetAt(index, newChild);
42
+ }
43
+ } // namespace winrt::RNScreens::implementation
@@ -0,0 +1,24 @@
1
+ #pragma once
2
+
3
+ namespace winrt::RNScreens::implementation {
4
+ class ScreenStackHeaderSubview
5
+ : public winrt::Windows::UI::Xaml::Controls::StackPanelT<
6
+ ScreenStackHeaderSubview> {
7
+ public:
8
+ ScreenStackHeaderSubview(
9
+ winrt::Microsoft::ReactNative::IReactContext reactContext);
10
+
11
+ void addView(winrt::Windows::UI::Xaml::UIElement element);
12
+ void removeAllChildren();
13
+ void removeChildAt(int64_t index);
14
+ void replaceChild(
15
+ winrt::Windows::UI::Xaml::UIElement oldChild,
16
+ winrt::Windows::UI::Xaml::UIElement newChild);
17
+
18
+ winrt::Windows::Foundation::Collections::IVector<Windows::UI::Xaml::UIElement>
19
+ m_children;
20
+
21
+ private:
22
+ winrt::Microsoft::ReactNative::IReactContext m_reactContext{nullptr};
23
+ };
24
+ } // namespace winrt::RNScreens::implementation
@@ -0,0 +1,129 @@
1
+ #include "pch.h"
2
+ #include "ScreenStackHeaderSubviewViewManager.h"
3
+ #include "ScreenStackHeaderSubview.h"
4
+ #include "JSValueXaml.h"
5
+ #include "NativeModules.h"
6
+
7
+ namespace winrt {
8
+ using namespace Microsoft::ReactNative;
9
+ using namespace Windows::Foundation;
10
+ using namespace Windows::Foundation::Collections;
11
+ using namespace Windows::UI;
12
+ using namespace Windows::UI::Xaml;
13
+ using namespace Windows::UI::Xaml::Controls;
14
+ } // namespace winrt
15
+
16
+ namespace winrt::RNScreens::implementation {
17
+ // IViewManager
18
+ winrt::hstring ScreenStackHeaderSubviewViewManager::Name() noexcept {
19
+ return L"RNSScreenStackHeaderSubview";
20
+ }
21
+
22
+ winrt::FrameworkElement ScreenStackHeaderSubviewViewManager::CreateView() noexcept {
23
+ return winrt::make<winrt::RNScreens::implementation::ScreenStackHeaderSubview>(m_reactContext);
24
+ }
25
+
26
+ // IViewManagerRequiresNativeLayout
27
+ bool ScreenStackHeaderSubviewViewManager::RequiresNativeLayout() {
28
+ return false;
29
+ }
30
+
31
+ // IViewManagerWithChildren
32
+ void ScreenStackHeaderSubviewViewManager::AddView(
33
+ FrameworkElement parent,
34
+ UIElement child,
35
+ int64_t index) {
36
+ auto screenStackHeaderSubview = parent.as<ScreenStackHeaderSubview>();
37
+ if (!screenStackHeaderSubview)
38
+ return;
39
+
40
+ screenStackHeaderSubview->addView(child);
41
+ }
42
+
43
+ void ScreenStackHeaderSubviewViewManager::RemoveAllChildren(FrameworkElement parent) {
44
+ auto screenStackHeaderSubview = parent.as<ScreenStackHeaderSubview>();
45
+ if (!screenStackHeaderSubview)
46
+ return;
47
+
48
+ screenStackHeaderSubview->removeAllChildren();
49
+ }
50
+
51
+ void ScreenStackHeaderSubviewViewManager::RemoveChildAt(
52
+ FrameworkElement parent,
53
+ int64_t index) {
54
+ auto screenStackHeaderSubview = parent.as<ScreenStackHeaderSubview>();
55
+ if (!screenStackHeaderSubview)
56
+ return;
57
+
58
+ screenStackHeaderSubview->removeChildAt(index);
59
+ }
60
+
61
+ void ScreenStackHeaderSubviewViewManager::ReplaceChild(
62
+ FrameworkElement parent,
63
+ UIElement oldChild,
64
+ UIElement newChild) {
65
+ auto screenStackHeaderSubview = parent.as<ScreenStackHeaderSubview>();
66
+ if (!screenStackHeaderSubview)
67
+ return;
68
+
69
+ screenStackHeaderSubview->replaceChild(oldChild, newChild);
70
+ }
71
+
72
+ // IViewManagerWithNativeProperties
73
+ IMapView<hstring, ViewManagerPropertyType>
74
+ ScreenStackHeaderSubviewViewManager::NativeProps() noexcept {
75
+ auto nativeProps =
76
+ winrt::single_threaded_map<hstring, ViewManagerPropertyType>();
77
+ return nativeProps.GetView();
78
+ }
79
+
80
+ void ScreenStackHeaderSubviewViewManager::UpdateProperties(
81
+ FrameworkElement const &view,
82
+ IJSValueReader const &propertyMapReader) noexcept {
83
+ (void)view;
84
+ const JSValueObject &propertyMap = JSValue::ReadObjectFrom(propertyMapReader);
85
+ for (auto const &pair : propertyMap) {
86
+ auto const &propertyName = pair.first;
87
+ auto const &propertyValue = pair.second;
88
+ (void)propertyName;
89
+ (void)propertyValue;
90
+ }
91
+ }
92
+
93
+ // IViewManagerWithCommands
94
+ IVectorView<hstring> ScreenStackHeaderSubviewViewManager::Commands() noexcept {
95
+ auto commands = winrt::single_threaded_vector<hstring>();
96
+ return commands.GetView();
97
+ }
98
+
99
+ void ScreenStackHeaderSubviewViewManager::DispatchCommand(
100
+ FrameworkElement const &view,
101
+ winrt::hstring const &commandId,
102
+ winrt::IJSValueReader const &commandArgsReader) noexcept {
103
+ (void)view;
104
+ (void)commandId;
105
+ (void)commandArgsReader;
106
+ }
107
+
108
+
109
+ // IViewManagerWithExportedEventTypeConstants
110
+ ConstantProviderDelegate ScreenStackHeaderSubviewViewManager::
111
+ ExportedCustomBubblingEventTypeConstants() noexcept {
112
+ return nullptr;
113
+ }
114
+
115
+ ConstantProviderDelegate ScreenStackHeaderSubviewViewManager::
116
+ ExportedCustomDirectEventTypeConstants() noexcept {
117
+ return nullptr;
118
+ }
119
+
120
+ // IViewManagerWithReactContext
121
+ winrt::IReactContext ScreenStackHeaderSubviewViewManager::ReactContext() noexcept {
122
+ return m_reactContext;
123
+ }
124
+
125
+ void ScreenStackHeaderSubviewViewManager::ReactContext(IReactContext reactContext) noexcept {
126
+ m_reactContext = reactContext;
127
+ }
128
+
129
+ } // namespace winrt::RNScreens::implementation
@@ -0,0 +1,77 @@
1
+ #pragma once
2
+
3
+ #include "NativeModules.h"
4
+ #include "winrt/Microsoft.ReactNative.h"
5
+
6
+ namespace winrt::RNScreens::implementation {
7
+ class ScreenStackHeaderSubviewViewManager
8
+ : public winrt::implements<
9
+ ScreenStackHeaderSubviewViewManager,
10
+ winrt::Microsoft::ReactNative::IViewManager,
11
+ winrt::Microsoft::ReactNative::IViewManagerWithNativeProperties,
12
+ winrt::Microsoft::ReactNative::IViewManagerWithCommands,
13
+ winrt::Microsoft::ReactNative::IViewManagerWithChildren,
14
+ winrt::Microsoft::ReactNative::IViewManagerWithExportedEventTypeConstants,
15
+ winrt::Microsoft::ReactNative::IViewManagerRequiresNativeLayout,
16
+ winrt::Microsoft::ReactNative::IViewManagerWithReactContext> {
17
+ public:
18
+ ScreenStackHeaderSubviewViewManager() = default;
19
+
20
+ // IViewManager
21
+ winrt::hstring Name() noexcept;
22
+ winrt::Windows::UI::Xaml::FrameworkElement CreateView() noexcept;
23
+
24
+ // IViewManagerRequiresNativeLayout
25
+ bool RequiresNativeLayout();
26
+
27
+ // IViewManagerWithChildren
28
+ void AddView(
29
+ winrt::Windows::UI::Xaml::FrameworkElement parent,
30
+ winrt::Windows::UI::Xaml::UIElement child,
31
+ int64_t index);
32
+ void RemoveAllChildren(winrt::Windows::UI::Xaml::FrameworkElement parent);
33
+ void RemoveChildAt(
34
+ winrt::Windows::UI::Xaml::FrameworkElement parent,
35
+ int64_t index);
36
+ void ReplaceChild(
37
+ winrt::Windows::UI::Xaml::FrameworkElement parent,
38
+ winrt::Windows::UI::Xaml::UIElement oldChild,
39
+ winrt::Windows::UI::Xaml::UIElement newChild);
40
+
41
+ // IViewManagerWithNativeProperties
42
+ winrt::Windows::Foundation::Collections::IMapView<
43
+ winrt::hstring,
44
+ winrt::Microsoft::ReactNative::ViewManagerPropertyType>
45
+ NativeProps() noexcept;
46
+
47
+ void UpdateProperties(
48
+ winrt::Windows::UI::Xaml::FrameworkElement const &view,
49
+ winrt::Microsoft::ReactNative::IJSValueReader const
50
+ &propertyMapReader) noexcept;
51
+
52
+ // IViewManagerWithExportedEventTypeConstants
53
+ winrt::Microsoft::ReactNative::ConstantProviderDelegate
54
+ ExportedCustomBubblingEventTypeConstants() noexcept;
55
+ winrt::Microsoft::ReactNative::ConstantProviderDelegate
56
+ ExportedCustomDirectEventTypeConstants() noexcept;
57
+
58
+
59
+ // IViewManagerWithCommands
60
+ winrt::Windows::Foundation::Collections::IVectorView<winrt::hstring>
61
+ Commands() noexcept;
62
+
63
+ void DispatchCommand(
64
+ winrt::Windows::UI::Xaml::FrameworkElement const &view,
65
+ winrt::hstring const &commandId,
66
+ winrt::Microsoft::ReactNative::IJSValueReader const
67
+ &commandArgsReader) noexcept;
68
+
69
+ // IViewManagerWithReactContext
70
+ winrt::Microsoft::ReactNative::IReactContext ReactContext() noexcept;
71
+ void ReactContext(
72
+ winrt::Microsoft::ReactNative::IReactContext reactContext) noexcept;
73
+
74
+ private:
75
+ winrt::Microsoft::ReactNative::IReactContext m_reactContext{nullptr};
76
+ };
77
+ } // namespace winrt::RNScreens::implementation