react-native-sheet2 1.2.6 → 6.1.18

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 (117) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +51 -32
  3. package/{react-native-sheet.podspec → Sheet.podspec} +7 -6
  4. package/android/build.gradle +43 -25
  5. package/android/generated/java/com/facebook/react/viewmanagers/SheetViewManagerDelegate.java +67 -0
  6. package/android/generated/java/com/facebook/react/viewmanagers/SheetViewManagerInterface.java +27 -0
  7. package/android/generated/java/com/sheet/NativeSheetSpec.java +78 -0
  8. package/android/generated/jni/CMakeLists.txt +36 -0
  9. package/android/generated/jni/RNSheetViewSpec-generated.cpp +50 -0
  10. package/android/generated/jni/RNSheetViewSpec.h +31 -0
  11. package/android/generated/jni/react/renderer/components/RNSheetViewSpec/ComponentDescriptors.cpp +22 -0
  12. package/android/generated/jni/react/renderer/components/RNSheetViewSpec/ComponentDescriptors.h +24 -0
  13. package/android/generated/jni/react/renderer/components/RNSheetViewSpec/EventEmitters.cpp +24 -0
  14. package/android/generated/jni/react/renderer/components/RNSheetViewSpec/EventEmitters.h +25 -0
  15. package/android/generated/jni/react/renderer/components/RNSheetViewSpec/Props.cpp +33 -0
  16. package/android/generated/jni/react/renderer/components/RNSheetViewSpec/Props.h +36 -0
  17. package/android/generated/jni/react/renderer/components/RNSheetViewSpec/RNSheetViewSpecJSI-generated.cpp +46 -0
  18. package/android/generated/jni/react/renderer/components/RNSheetViewSpec/RNSheetViewSpecJSI.h +98 -0
  19. package/android/generated/jni/react/renderer/components/RNSheetViewSpec/ShadowNodes.cpp +17 -0
  20. package/android/generated/jni/react/renderer/components/RNSheetViewSpec/ShadowNodes.h +32 -0
  21. package/android/generated/jni/react/renderer/components/RNSheetViewSpec/States.cpp +16 -0
  22. package/android/generated/jni/react/renderer/components/RNSheetViewSpec/States.h +29 -0
  23. package/android/gradle.properties +4 -5
  24. package/android/src/main/AndroidManifest.xml +0 -9
  25. package/android/src/main/AndroidManifestNew.xml +2 -0
  26. package/android/src/main/java/com/behavior/BottomSheetBehavior.java +10 -17
  27. package/android/src/main/java/com/sheet/AppFittedSheet.kt +107 -39
  28. package/android/src/main/java/com/sheet/BaseRNView.kt +81 -33
  29. package/android/src/main/java/com/sheet/CustomBottomSheetDialog.java +8 -0
  30. package/android/src/main/java/com/sheet/DialogRootViewGroup.kt +44 -33
  31. package/android/src/main/java/com/sheet/FragmentModalBottomSheet.kt +12 -2
  32. package/android/src/main/java/com/sheet/SafeAreaUtils.kt +90 -0
  33. package/android/src/main/java/com/sheet/SheetDismissEvent.kt +20 -0
  34. package/android/src/main/java/com/sheet/SheetModule.kt +37 -0
  35. package/android/src/main/java/com/sheet/SheetPackage.kt +32 -6
  36. package/android/src/main/java/com/sheet/SheetView.kt +5 -0
  37. package/android/src/main/java/com/sheet/SheetViewManager.kt +77 -56
  38. package/android/src/main/java/com/sheet/utils.kt +2 -10
  39. package/android/src/main/res/layout/dialog_bottom_sheet.xml +2 -2
  40. package/android/src/main/res/values/styles.xml +9 -0
  41. package/ios/FittedSheets/SheetContentViewController.swift +4 -4
  42. package/ios/FittedSheets/SheetViewController.swift +29 -100
  43. package/ios/HostFittedSheet.swift +271 -0
  44. package/ios/Sheet-Bridging-Header.h +1 -0
  45. package/ios/SheetModule.h +10 -0
  46. package/ios/SheetModule.mm +67 -0
  47. package/ios/SheetView.h +14 -0
  48. package/ios/SheetView.mm +129 -0
  49. package/ios/generated/RNSheetViewSpec/ComponentDescriptors.cpp +22 -0
  50. package/ios/generated/RNSheetViewSpec/ComponentDescriptors.h +24 -0
  51. package/ios/generated/RNSheetViewSpec/EventEmitters.cpp +24 -0
  52. package/ios/generated/RNSheetViewSpec/EventEmitters.h +25 -0
  53. package/ios/generated/RNSheetViewSpec/Props.cpp +33 -0
  54. package/ios/generated/RNSheetViewSpec/Props.h +36 -0
  55. package/ios/generated/RNSheetViewSpec/RCTComponentViewHelpers.h +44 -0
  56. package/ios/generated/RNSheetViewSpec/RNSheetViewSpec-generated.mm +60 -0
  57. package/ios/generated/RNSheetViewSpec/RNSheetViewSpec.h +100 -0
  58. package/ios/generated/RNSheetViewSpec/ShadowNodes.cpp +17 -0
  59. package/ios/generated/RNSheetViewSpec/ShadowNodes.h +32 -0
  60. package/ios/generated/RNSheetViewSpec/States.cpp +16 -0
  61. package/ios/generated/RNSheetViewSpec/States.h +29 -0
  62. package/ios/generated/RNSheetViewSpecJSI-generated.cpp +46 -0
  63. package/ios/generated/RNSheetViewSpecJSI.h +98 -0
  64. package/lib/module/FittedSheet.js +153 -0
  65. package/lib/module/FittedSheet.js.map +1 -0
  66. package/lib/module/NativeSheet.ts +17 -0
  67. package/lib/module/PublicSheetView.js +48 -0
  68. package/lib/module/PublicSheetView.js.map +1 -0
  69. package/lib/module/SheetViewNativeComponent.ts +31 -0
  70. package/lib/module/index.js +13 -0
  71. package/lib/module/index.js.map +1 -0
  72. package/lib/module/package.json +1 -0
  73. package/lib/typescript/package.json +1 -0
  74. package/lib/typescript/src/FittedSheet.d.ts +51 -0
  75. package/lib/typescript/src/FittedSheet.d.ts.map +1 -0
  76. package/lib/typescript/src/NativeSheet.d.ts +16 -0
  77. package/lib/typescript/src/NativeSheet.d.ts.map +1 -0
  78. package/lib/typescript/src/PublicSheetView.d.ts +12 -0
  79. package/lib/typescript/src/PublicSheetView.d.ts.map +1 -0
  80. package/lib/typescript/src/SheetViewNativeComponent.d.ts +22 -0
  81. package/lib/typescript/src/SheetViewNativeComponent.d.ts.map +1 -0
  82. package/lib/typescript/src/index.d.ts +8 -0
  83. package/lib/typescript/src/index.d.ts.map +1 -0
  84. package/package.json +109 -42
  85. package/react-native.config.js +12 -0
  86. package/src/FittedSheet.tsx +118 -95
  87. package/src/NativeSheet.ts +17 -0
  88. package/src/PublicSheetView.tsx +66 -0
  89. package/src/SheetViewNativeComponent.ts +31 -0
  90. package/src/index.tsx +26 -8
  91. package/android/src/main/java/com/modal/FullScreenDialog.kt +0 -100
  92. package/android/src/main/java/com/modal/TopModalView.kt +0 -77
  93. package/android/src/main/java/com/modal/TopModalViewManager.kt +0 -83
  94. package/android/src/main/java/com/modal/TopModalViewModule.kt +0 -40
  95. package/android/src/main/java/com/sheet/SheetViewModule.kt +0 -41
  96. package/ios/LBBottomSheet/BottomSheetConstant.swift +0 -48
  97. package/ios/LBBottomSheet/Model/BottomSheetController+Behavior.swift +0 -262
  98. package/ios/LBBottomSheet/Model/BottomSheetController+Theme.swift +0 -156
  99. package/ios/LBBottomSheet/Protocols/BottomSheetInteractionDelegate.swift +0 -29
  100. package/ios/LBBottomSheet/Protocols/BottomSheetPositionDelegate.swift +0 -31
  101. package/ios/LBBottomSheet/UI/BottomSheet.storyboard +0 -105
  102. package/ios/LBBottomSheet/UI/BottomSheetController.swift +0 -601
  103. package/ios/LBBottomSheet/Utils/Components/ForwardingEventsView.swift +0 -60
  104. package/ios/LBBottomSheet/Utils/Extensions/CACornerMask+Extension.swift +0 -33
  105. package/ios/LBBottomSheet/Utils/Extensions/Mirror+Extension.swift +0 -47
  106. package/ios/LBBottomSheet/Utils/Extensions/UIApplication+Extension.swift +0 -35
  107. package/ios/LBBottomSheet/Utils/Extensions/UIColor+Extension.swift +0 -61
  108. package/ios/LBBottomSheet/Utils/Extensions/UIGestureRecognizer+Extensions.swift +0 -28
  109. package/ios/LBBottomSheet/Utils/Extensions/UIScreen+Extension.swift +0 -28
  110. package/ios/LBBottomSheet/Utils/Extensions/UIScrollView+Extension.swift +0 -25
  111. package/ios/LBBottomSheet/Utils/Extensions/UIView+Extension.swift +0 -52
  112. package/ios/LBBottomSheet/Utils/Extensions/UIViewController+Extension.swift +0 -104
  113. package/ios/Sheet.xcodeproj/project.pbxproj +0 -377
  114. package/ios/SheetViewManager.m +0 -25
  115. package/ios/SheetViewManager.swift +0 -324
  116. package/ios/TopModalViewManager.swift +0 -196
  117. package/src/TopModal.tsx +0 -94
@@ -0,0 +1,33 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GeneratePropsCpp.js
9
+ */
10
+
11
+ #include "Props.h"
12
+ #include <react/renderer/core/PropsParserContext.h>
13
+ #include <react/renderer/core/propsConversions.h>
14
+
15
+ namespace facebook::react {
16
+
17
+ SheetViewProps::SheetViewProps(
18
+ const PropsParserContext &context,
19
+ const SheetViewProps &sourceProps,
20
+ const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
21
+
22
+ dismissable(convertRawProp(context, rawProps, "dismissable", sourceProps.dismissable, {false})),
23
+ maxWidth(convertRawProp(context, rawProps, "maxWidth", sourceProps.maxWidth, {0.0})),
24
+ maxHeight(convertRawProp(context, rawProps, "maxHeight", sourceProps.maxHeight, {0.0})),
25
+ minHeight(convertRawProp(context, rawProps, "minHeight", sourceProps.minHeight, {0.0})),
26
+ calculatedHeight(convertRawProp(context, rawProps, "calculatedHeight", sourceProps.calculatedHeight, {0.0})),
27
+ topLeftRightCornerRadius(convertRawProp(context, rawProps, "topLeftRightCornerRadius", sourceProps.topLeftRightCornerRadius, {0.0})),
28
+ isSystemUILight(convertRawProp(context, rawProps, "isSystemUILight", sourceProps.isSystemUILight, {false})),
29
+ passScrollViewReactTag(convertRawProp(context, rawProps, "passScrollViewReactTag", sourceProps.passScrollViewReactTag, {})),
30
+ sheetBackgroundColor(convertRawProp(context, rawProps, "sheetBackgroundColor", sourceProps.sheetBackgroundColor, {}))
31
+ {}
32
+
33
+ } // namespace facebook::react
@@ -0,0 +1,36 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GeneratePropsH.js
9
+ */
10
+ #pragma once
11
+
12
+ #include <react/renderer/components/view/ViewProps.h>
13
+ #include <react/renderer/core/PropsParserContext.h>
14
+ #include <react/renderer/graphics/Color.h>
15
+
16
+ namespace facebook::react {
17
+
18
+ class SheetViewProps final : public ViewProps {
19
+ public:
20
+ SheetViewProps() = default;
21
+ SheetViewProps(const PropsParserContext& context, const SheetViewProps &sourceProps, const RawProps &rawProps);
22
+
23
+ #pragma mark - Props
24
+
25
+ bool dismissable{false};
26
+ double maxWidth{0.0};
27
+ double maxHeight{0.0};
28
+ double minHeight{0.0};
29
+ double calculatedHeight{0.0};
30
+ double topLeftRightCornerRadius{0.0};
31
+ bool isSystemUILight{false};
32
+ std::string passScrollViewReactTag{};
33
+ SharedColor sheetBackgroundColor{};
34
+ };
35
+
36
+ } // namespace facebook::react
@@ -0,0 +1,46 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleCpp.js
8
+ */
9
+
10
+ #include "RNSheetViewSpecJSI.h"
11
+
12
+ namespace facebook::react {
13
+
14
+ static jsi::Value __hostFunction_NativeSheetCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
15
+ return static_cast<NativeSheetCxxSpecJSI *>(&turboModule)->getConstants(
16
+ rt
17
+ );
18
+ }
19
+ static jsi::Value __hostFunction_NativeSheetCxxSpecJSI_viewportSize(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
20
+ return static_cast<NativeSheetCxxSpecJSI *>(&turboModule)->viewportSize(
21
+ rt
22
+ );
23
+ }
24
+ static jsi::Value __hostFunction_NativeSheetCxxSpecJSI_dismissAll(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
25
+ static_cast<NativeSheetCxxSpecJSI *>(&turboModule)->dismissAll(
26
+ rt
27
+ );
28
+ return jsi::Value::undefined();
29
+ }
30
+ static jsi::Value __hostFunction_NativeSheetCxxSpecJSI_dismissPresented(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
31
+ static_cast<NativeSheetCxxSpecJSI *>(&turboModule)->dismissPresented(
32
+ rt
33
+ );
34
+ return jsi::Value::undefined();
35
+ }
36
+
37
+ NativeSheetCxxSpecJSI::NativeSheetCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
38
+ : TurboModule("Sheet", jsInvoker) {
39
+ methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeSheetCxxSpecJSI_getConstants};
40
+ methodMap_["viewportSize"] = MethodMetadata {0, __hostFunction_NativeSheetCxxSpecJSI_viewportSize};
41
+ methodMap_["dismissAll"] = MethodMetadata {0, __hostFunction_NativeSheetCxxSpecJSI_dismissAll};
42
+ methodMap_["dismissPresented"] = MethodMetadata {0, __hostFunction_NativeSheetCxxSpecJSI_dismissPresented};
43
+ }
44
+
45
+
46
+ } // namespace facebook::react
@@ -0,0 +1,98 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleH.js
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include <ReactCommon/TurboModule.h>
13
+ #include <react/bridging/Bridging.h>
14
+
15
+ namespace facebook::react {
16
+
17
+
18
+ class JSI_EXPORT NativeSheetCxxSpecJSI : public TurboModule {
19
+ protected:
20
+ NativeSheetCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
21
+
22
+ public:
23
+ virtual jsi::Object getConstants(jsi::Runtime &rt) = 0;
24
+ virtual jsi::Object viewportSize(jsi::Runtime &rt) = 0;
25
+ virtual void dismissAll(jsi::Runtime &rt) = 0;
26
+ virtual void dismissPresented(jsi::Runtime &rt) = 0;
27
+
28
+ };
29
+
30
+ template <typename T>
31
+ class JSI_EXPORT NativeSheetCxxSpec : public TurboModule {
32
+ public:
33
+ jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
34
+ return delegate_.create(rt, propName);
35
+ }
36
+
37
+ std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
38
+ return delegate_.getPropertyNames(runtime);
39
+ }
40
+
41
+ static constexpr std::string_view kModuleName = "Sheet";
42
+
43
+ protected:
44
+ NativeSheetCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
45
+ : TurboModule(std::string{NativeSheetCxxSpec::kModuleName}, jsInvoker),
46
+ delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
47
+
48
+
49
+ private:
50
+ class Delegate : public NativeSheetCxxSpecJSI {
51
+ public:
52
+ Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
53
+ NativeSheetCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
54
+
55
+ }
56
+
57
+ jsi::Object getConstants(jsi::Runtime &rt) override {
58
+ static_assert(
59
+ bridging::getParameterCount(&T::getConstants) == 1,
60
+ "Expected getConstants(...) to have 1 parameters");
61
+
62
+ return bridging::callFromJs<jsi::Object>(
63
+ rt, &T::getConstants, jsInvoker_, instance_);
64
+ }
65
+ jsi::Object viewportSize(jsi::Runtime &rt) override {
66
+ static_assert(
67
+ bridging::getParameterCount(&T::viewportSize) == 1,
68
+ "Expected viewportSize(...) to have 1 parameters");
69
+
70
+ return bridging::callFromJs<jsi::Object>(
71
+ rt, &T::viewportSize, jsInvoker_, instance_);
72
+ }
73
+ void dismissAll(jsi::Runtime &rt) override {
74
+ static_assert(
75
+ bridging::getParameterCount(&T::dismissAll) == 1,
76
+ "Expected dismissAll(...) to have 1 parameters");
77
+
78
+ return bridging::callFromJs<void>(
79
+ rt, &T::dismissAll, jsInvoker_, instance_);
80
+ }
81
+ void dismissPresented(jsi::Runtime &rt) override {
82
+ static_assert(
83
+ bridging::getParameterCount(&T::dismissPresented) == 1,
84
+ "Expected dismissPresented(...) to have 1 parameters");
85
+
86
+ return bridging::callFromJs<void>(
87
+ rt, &T::dismissPresented, jsInvoker_, instance_);
88
+ }
89
+
90
+ private:
91
+ friend class NativeSheetCxxSpec;
92
+ T *instance_;
93
+ };
94
+
95
+ Delegate delegate_;
96
+ };
97
+
98
+ } // namespace facebook::react
@@ -0,0 +1,17 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateShadowNodeCpp.js
9
+ */
10
+
11
+ #include "ShadowNodes.h"
12
+
13
+ namespace facebook::react {
14
+
15
+ extern const char SheetViewComponentName[] = "SheetView";
16
+
17
+ } // namespace facebook::react
@@ -0,0 +1,32 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateShadowNodeH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include "EventEmitters.h"
14
+ #include "Props.h"
15
+ #include "States.h"
16
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
+ #include <jsi/jsi.h>
18
+
19
+ namespace facebook::react {
20
+
21
+ JSI_EXPORT extern const char SheetViewComponentName[];
22
+
23
+ /*
24
+ * `ShadowNode` for <SheetView> component.
25
+ */
26
+ using SheetViewShadowNode = ConcreteViewShadowNode<
27
+ SheetViewComponentName,
28
+ SheetViewProps,
29
+ SheetViewEventEmitter,
30
+ SheetViewState>;
31
+
32
+ } // namespace facebook::react
@@ -0,0 +1,16 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateStateCpp.js
9
+ */
10
+ #include "States.h"
11
+
12
+ namespace facebook::react {
13
+
14
+
15
+
16
+ } // namespace facebook::react
@@ -0,0 +1,29 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateStateH.js
8
+ */
9
+ #pragma once
10
+
11
+ #ifdef ANDROID
12
+ #include <folly/dynamic.h>
13
+ #endif
14
+
15
+ namespace facebook::react {
16
+
17
+ class SheetViewState {
18
+ public:
19
+ SheetViewState() = default;
20
+
21
+ #ifdef ANDROID
22
+ SheetViewState(SheetViewState const &previousState, folly::dynamic data){};
23
+ folly::dynamic getDynamic() const {
24
+ return {};
25
+ };
26
+ #endif
27
+ };
28
+
29
+ } // namespace facebook::react
@@ -1,6 +1,5 @@
1
- Sheet_kotlinVersion=1.7.0
1
+ Sheet_kotlinVersion=2.0.21
2
2
  Sheet_minSdkVersion=24
3
- Sheet_targetSdkVersion=33
4
- Sheet_compileSdkVersion=33
5
- Sheet_ndkversion=21.4.7075529
6
- Sheet_material=1.8.0
3
+ Sheet_targetSdkVersion=34
4
+ Sheet_compileSdkVersion=35
5
+ Sheet_ndkVersion=27.1.12297006
@@ -1,12 +1,3 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
2
  package="com.sheet">
3
-
4
- <application>
5
- <activity
6
- android:name="com.transparent.activity.TransparentActivity"
7
- android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
8
- android:windowSoftInputMode="adjustResize"
9
- android:exported="false"
10
- android:theme="@style/Theme.Transparent"/>
11
- </application>
12
3
  </manifest>
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -16,8 +16,6 @@
16
16
 
17
17
  package com.behavior;
18
18
 
19
- import com.google.android.material.R;
20
-
21
19
  import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;
22
20
  import static java.lang.Math.max;
23
21
  import static java.lang.Math.min;
@@ -27,7 +25,6 @@ import android.animation.ValueAnimator.AnimatorUpdateListener;
27
25
  import android.content.Context;
28
26
  import android.content.res.ColorStateList;
29
27
  import android.content.res.TypedArray;
30
- import android.os.Build;
31
28
  import android.os.Build.VERSION;
32
29
  import android.os.Build.VERSION_CODES;
33
30
  import android.os.Parcel;
@@ -45,6 +42,7 @@ import android.view.ViewGroup;
45
42
  import android.view.ViewGroup.MarginLayoutParams;
46
43
  import android.view.ViewParent;
47
44
  import android.view.accessibility.AccessibilityEvent;
45
+ import android.widget.ScrollView;
48
46
 
49
47
  import androidx.annotation.FloatRange;
50
48
  import androidx.annotation.IntDef;
@@ -65,11 +63,14 @@ import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.Accessibilit
65
63
  import androidx.core.view.accessibility.AccessibilityViewCommand;
66
64
  import androidx.customview.view.AbsSavedState;
67
65
  import androidx.customview.widget.ViewDragHelper;
66
+
67
+ import com.google.android.material.R;
68
68
  import com.google.android.material.internal.ViewUtils;
69
69
  import com.google.android.material.internal.ViewUtils.RelativePadding;
70
70
  import com.google.android.material.resources.MaterialResources;
71
71
  import com.google.android.material.shape.MaterialShapeDrawable;
72
72
  import com.google.android.material.shape.ShapeAppearanceModel;
73
+
73
74
  import java.lang.annotation.Retention;
74
75
  import java.lang.annotation.RetentionPolicy;
75
76
  import java.lang.ref.WeakReference;
@@ -1527,7 +1528,7 @@ public class BottomSheetBehavior<V extends View> extends CoordinatorLayout.Behav
1527
1528
  @Nullable
1528
1529
  @VisibleForTesting
1529
1530
  View findScrollingChild(View view) {
1530
- View fittedSheetScrollView = findView(view, "fittedSheetScrollView");
1531
+ View fittedSheetScrollView = findView(view);
1531
1532
  if (fittedSheetScrollView == null) return null;
1532
1533
  fittedSheetScrollView.setNestedScrollingEnabled(true);
1533
1534
  return fittedSheetScrollView;
@@ -2148,7 +2149,7 @@ public class BottomSheetBehavior<V extends View> extends CoordinatorLayout.Behav
2148
2149
 
2149
2150
  CoordinatorLayout parent = (CoordinatorLayout) viewParent;
2150
2151
  final int childCount = parent.getChildCount();
2151
- if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) && expanded) {
2152
+ if ((VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) && expanded) {
2152
2153
  if (importantForAccessibilityMap == null) {
2153
2154
  importantForAccessibilityMap = new HashMap<>(childCount);
2154
2155
  } else {
@@ -2165,7 +2166,7 @@ public class BottomSheetBehavior<V extends View> extends CoordinatorLayout.Behav
2165
2166
 
2166
2167
  if (expanded) {
2167
2168
  // Saves the important for accessibility value of the child view.
2168
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
2169
+ if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
2169
2170
  importantForAccessibilityMap.put(child, child.getImportantForAccessibility());
2170
2171
  }
2171
2172
  if (updateImportantForAccessibilityOnSiblings) {
@@ -2299,24 +2300,16 @@ public class BottomSheetBehavior<V extends View> extends CoordinatorLayout.Behav
2299
2300
  };
2300
2301
  }
2301
2302
 
2302
-
2303
- @Nullable
2304
- private static String getNativeId(View view) {
2305
- Object tag = view.getTag(com.facebook.react.R.id.view_tag_native_id);
2306
- return tag instanceof String ? (String)tag : null;
2307
- }
2308
-
2309
2303
  @Nullable
2310
- public static View findView(View root, String nativeId) {
2311
- String tag = getNativeId(root);
2312
- if (tag != null && tag.contains(nativeId)) {
2304
+ public static View findView(View root) {
2305
+ if (root instanceof ScrollView) {
2313
2306
  return root;
2314
2307
  } else {
2315
2308
  if (root instanceof ViewGroup) {
2316
2309
  ViewGroup viewGroup = (ViewGroup)root;
2317
2310
 
2318
2311
  for(int i = 0; i < viewGroup.getChildCount(); ++i) {
2319
- View view = findView(viewGroup.getChildAt(i), nativeId);
2312
+ View view = findView(viewGroup.getChildAt(i));
2320
2313
  if (view != null) {
2321
2314
  return view;
2322
2315
  }
@@ -2,58 +2,78 @@ package com.sheet
2
2
 
3
3
  import android.content.Context
4
4
  import android.graphics.Color
5
- import android.os.Build
6
5
  import android.view.View
7
6
  import android.view.ViewGroup
8
7
  import android.view.ViewStructure
9
8
  import android.view.accessibility.AccessibilityEvent
10
- import androidx.annotation.RequiresApi
11
9
  import androidx.appcompat.app.AppCompatActivity
12
- import com.facebook.react.bridge.Arguments
10
+ import androidx.fragment.app.Fragment
11
+ import androidx.fragment.app.FragmentManager
13
12
  import com.facebook.react.bridge.LifecycleEventListener
14
13
  import com.facebook.react.bridge.ReactContext
15
- import com.facebook.react.bridge.ReadableMap
16
14
  import com.facebook.react.bridge.UiThreadUtil
17
15
  import com.facebook.react.uimanager.UIManagerHelper
18
- import com.facebook.react.uimanager.UIManagerModule
19
- import com.facebook.react.uimanager.common.UIManagerType
20
- import com.facebook.react.uimanager.events.RCTEventEmitter
21
- import com.modal.safeShow
22
-
16
+ import com.facebook.react.uimanager.events.EventDispatcher
17
+
18
+ fun Fragment.safeShow(
19
+ manager: FragmentManager,
20
+ tag: String?
21
+ ) {
22
+ val ft = manager.beginTransaction()
23
+ ft.add(this, tag)
24
+ ft.commitNowAllowingStateLoss()
25
+ }
23
26
 
24
27
  internal fun AppFittedSheet.onSheetDismiss() {
25
- (context as ReactContext).getJSModule(RCTEventEmitter::class.java)
26
- .receiveEvent(id, "onSheetDismiss", Arguments.createMap())
28
+ val reactEventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(context as ReactContext, id)
29
+ val surfaceId = UIManagerHelper.getSurfaceId(context)
30
+ reactEventDispatcher?.dispatchEvent(SheetDismissEvent(surfaceId, id))
27
31
  }
28
32
 
29
- class AppFittedSheet(context: Context) : ViewGroup(context), LifecycleEventListener {
33
+ private var presentedSheets: MutableList<String> = mutableListOf()
34
+
35
+ open class AppFittedSheet(context: Context) : ViewGroup(context), LifecycleEventListener {
36
+ private var stacked = true
30
37
  private val fragmentTag = "CCBottomSheet-${System.currentTimeMillis()}"
31
38
  var mHostView = DialogRootViewGroup(context)
32
39
 
33
- var params: ReadableMap? = null
34
- set(value) {
35
- mHostView.sheetMaxHeightSize = value.double("maxHeight", -1.0).toPxD()
36
- mHostView.sheetMaxWidthSize = value.double("maxWidth", -1.0).toPxD()
37
- mHostView.sheetMinHeightSize = value.double("minHeight", -1.0).toPxD()
38
40
 
41
+ var dismissable = true
42
+ var topLeftRightCornerRadius: Float = 0F
43
+ var _backgroundColor: Int = Color.TRANSPARENT
44
+ var isSystemUILight: Boolean = false
45
+
46
+ var maxWidth: Float = 0F
47
+ set(value) {
39
48
  field = value
49
+ mHostView.sheetMaxWidthSize = value
50
+ if (this.sheet == null) return
51
+ mHostView.updateMaxWidth(mHostView.sheetMaxWidthSize)
40
52
  }
41
53
 
42
- private val dismissable: Boolean
43
- get() = params.bool("dismissable", true)
44
- private val topLeftRightCornerRadius: Float
45
- get() = params.float("topLeftRightCornerRadius", 0f)
46
- private val backgroundColor: Int
47
- get() = params?.color("backgroundColor", context) ?: Color.TRANSPARENT
48
- private val isSystemUILight: Boolean
49
- get() = params?.bool("isSystemUILight", false) ?: false
54
+ var eventDispatcher: EventDispatcher?
55
+ get() = mHostView.eventDispatcher
56
+ set(eventDispatcher) {
57
+ mHostView.eventDispatcher = eventDispatcher
58
+ }
50
59
 
51
60
  private fun getCurrentActivity(): AppCompatActivity? {
52
- return (context as ReactContext)?.currentActivity as? AppCompatActivity
61
+ return (context as? ReactContext)?.currentActivity as? AppCompatActivity
62
+ }
63
+
64
+ private fun findSheet(name: String): FragmentModalBottomSheet? {
65
+ return getCurrentActivity()?.supportFragmentManager?.findFragmentByTag(name) as? FragmentModalBottomSheet
53
66
  }
54
67
 
55
68
  private val sheet: FragmentModalBottomSheet?
56
- get() = getCurrentActivity()?.supportFragmentManager?.findFragmentByTag(fragmentTag) as FragmentModalBottomSheet?
69
+ get() = findSheet(fragmentTag)
70
+
71
+ override fun setId(id: Int) {
72
+ super.setId(id)
73
+ println("👀 setId $id")
74
+ // Forward the ID to our content view, so event dispatching behaves correctly
75
+ mHostView.id = id
76
+ }
57
77
 
58
78
  fun showOrUpdate() {
59
79
  println("🥲 showOrUpdate")
@@ -61,20 +81,53 @@ class AppFittedSheet(context: Context) : ViewGroup(context), LifecycleEventListe
61
81
 
62
82
  val sheet = this.sheet
63
83
  mHostView.setCornerRadius(topLeftRightCornerRadius)
64
- mHostView.setBackgroundColor(backgroundColor)
84
+ mHostView.setBackgroundColor(_backgroundColor)
65
85
  if (sheet == null) {
86
+ if (stacked) {
87
+ presentedSheets.lastOrNull()?.let {
88
+ findSheet(it)?.collapse()
89
+ }
90
+ }
91
+
66
92
  val fragment = FragmentModalBottomSheet(
67
93
  modalView = mHostView,
68
94
  dismissable = dismissable,
69
95
  isSystemUILight = isSystemUILight
70
- ) {
96
+ ) { dismissAll ->
71
97
  println("😀 onDismiss")
72
98
  val parent = mHostView.parent as? ViewGroup
73
99
  parent?.removeViewAt(0)
74
100
  onSheetDismiss()
101
+ if (dismissAll) {
102
+ println("😁 dismissingSilently ${presentedSheets.size}")
103
+ if (stacked) {
104
+ var lastName = presentedSheets.removeLastOrNull()
105
+ if (lastName == fragmentTag) lastName = presentedSheets.lastOrNull()
106
+ if (lastName != null) {
107
+ findSheet(lastName)?.let {
108
+ it.dismissAll = true
109
+ it.dismissAllowingStateLoss()
110
+ }
111
+ }
112
+ }
113
+ return@FragmentModalBottomSheet
114
+ }
115
+ if (stacked) {
116
+ var lastName = presentedSheets.removeLastOrNull()
117
+ if (lastName == fragmentTag) {
118
+ lastName = presentedSheets.lastOrNull()
119
+ }
120
+ lastName?.let { findSheet(it)?.expand() }
121
+ println("👀 Dismiss ${presentedSheets.size}")
122
+ }
75
123
  }
76
124
  getCurrentActivity()?.supportFragmentManager?.let {
77
125
  fragment.safeShow(it, fragmentTag)
126
+ if (stacked) {
127
+ println("👀 Show ${presentedSheets.size} name: $fragmentTag")
128
+ if (presentedSheets.contains(fragmentTag)) return
129
+ presentedSheets.add(fragmentTag)
130
+ }
78
131
  }
79
132
  }
80
133
  }
@@ -83,8 +136,7 @@ class AppFittedSheet(context: Context) : ViewGroup(context), LifecycleEventListe
83
136
  sheet?.setNewNestedScrollView(view)
84
137
  }
85
138
 
86
- @RequiresApi(Build.VERSION_CODES.M)
87
- override fun dispatchProvideStructure(structure: ViewStructure?) {
139
+ override fun dispatchProvideStructure(structure: ViewStructure) {
88
140
  mHostView.dispatchProvideStructure(structure)
89
141
  }
90
142
 
@@ -92,13 +144,13 @@ class AppFittedSheet(context: Context) : ViewGroup(context), LifecycleEventListe
92
144
  println("🥲 addView parentId: $id id: ${child.id}")
93
145
  UiThreadUtil.assertOnUiThread()
94
146
  mHostView.addView(child, index)
95
- val ctx = context as ReactContext? ?: return
96
- val module = UIManagerHelper.getUIManager(ctx, UIManagerType.DEFAULT) as? UIManagerModule ?: return
97
- ctx.runOnNativeModulesQueueThread {
98
- val resolveShadowNode = module?.uiImplementation?.resolveShadowNode(child.id) ?: return@runOnNativeModulesQueueThread
99
- val height = resolveShadowNode.layoutHeight
100
- if (height > 0) mHostView.setVirtualHeight(height)
101
- }
147
+ // val ctx = context as ReactContext? ?: return
148
+ // val module = UIManagerHelper.getUIManager(ctx, UIManagerType.DEFAULT) as? UIManagerModule ?: return
149
+ // ctx.runOnNativeModulesQueueThread {
150
+ // val resolveShadowNode = module?.uiImplementation?.resolveShadowNode(child.id) ?: return@runOnNativeModulesQueueThread
151
+ // val height = resolveShadowNode.layoutHeight
152
+ // if (height > 0) mHostView.setVirtualHeight(height)
153
+ // }
102
154
  }
103
155
 
104
156
  override fun getChildCount(): Int = mHostView.childCount
@@ -114,7 +166,6 @@ class AppFittedSheet(context: Context) : ViewGroup(context), LifecycleEventListe
114
166
  override fun onDetachedFromWindow() {
115
167
  super.onDetachedFromWindow()
116
168
  println("🥲 onDetachedFromWindow: $id")
117
- ModalHostShadowNode.attachedViews.remove(id)
118
169
  }
119
170
 
120
171
  override fun removeViewAt(index: Int) {
@@ -143,4 +194,21 @@ class AppFittedSheet(context: Context) : ViewGroup(context), LifecycleEventListe
143
194
  override fun onHostDestroy() { onDropInstance() }
144
195
 
145
196
  override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {}
197
+
198
+ companion object {
199
+ fun dismissAll(activity: AppCompatActivity) {
200
+ val fragment = activity.supportFragmentManager.fragments.lastOrNull()
201
+ if (fragment is FragmentModalBottomSheet) {
202
+ fragment.dismissAll = true
203
+ fragment.dismissAllowingStateLoss()
204
+ }
205
+ }
206
+
207
+ fun dismissPresented(activity: AppCompatActivity) {
208
+ val fragment = activity.supportFragmentManager.fragments.lastOrNull()
209
+ if (fragment is FragmentModalBottomSheet) {
210
+ fragment.dismissAllowingStateLoss()
211
+ }
212
+ }
213
+ }
146
214
  }