react-native-nitro-modal 0.1.0
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.
- package/LICENSE +20 -0
- package/NitroModal.podspec +29 -0
- package/README.md +39 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +124 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +11 -0
- package/android/src/main/java/com/margelo/nitro/nitromodal/BottomSheetPresenter.kt +284 -0
- package/android/src/main/java/com/margelo/nitro/nitromodal/HybridNitroModal.kt +312 -0
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalConfig.kt +50 -0
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalContentRoot.kt +115 -0
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalPresenter.kt +253 -0
- package/android/src/main/java/com/margelo/nitro/nitromodal/NitroModalHostView.kt +52 -0
- package/android/src/main/java/com/margelo/nitro/nitromodal/NitroModalPackage.kt +28 -0
- package/android/src/main/java/com/margelo/nitro/nitromodal/NitroModalViewManager.kt +67 -0
- package/android/src/main/java/com/margelo/nitro/nitromodal/PopupPresenter.kt +156 -0
- package/android/src/main/res/values/styles.xml +17 -0
- package/ios/BackdropView.swift +64 -0
- package/ios/HybridNitroModal.swift +329 -0
- package/ios/HybridNitroModalComponent+Children.mm +77 -0
- package/ios/ModalConfig.swift +73 -0
- package/ios/NitroModalHostView.swift +91 -0
- package/ios/PopupViewController.swift +223 -0
- package/ios/SheetViewController.swift +244 -0
- package/lib/module/NitroModal.js +188 -0
- package/lib/module/NitroModal.js.map +1 -0
- package/lib/module/NitroModal.nitro.js +4 -0
- package/lib/module/NitroModal.nitro.js.map +1 -0
- package/lib/module/NitroModalView.js +17 -0
- package/lib/module/NitroModalView.js.map +1 -0
- package/lib/module/NitroModalView.native.js +6 -0
- package/lib/module/NitroModalView.native.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NitroModal.d.ts +59 -0
- package/lib/typescript/src/NitroModal.d.ts.map +1 -0
- package/lib/typescript/src/NitroModal.nitro.d.ts +78 -0
- package/lib/typescript/src/NitroModal.nitro.d.ts.map +1 -0
- package/lib/typescript/src/NitroModalView.d.ts +4 -0
- package/lib/typescript/src/NitroModalView.d.ts.map +1 -0
- package/lib/typescript/src/NitroModalView.native.d.ts +3 -0
- package/lib/typescript/src/NitroModalView.native.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/android/c++/JDismissReason.hpp +64 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_DismissReason.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_ModalContentArea.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JHybridNitroModalSpec.cpp +344 -0
- package/nitrogen/generated/android/c++/JHybridNitroModalSpec.hpp +106 -0
- package/nitrogen/generated/android/c++/JKeyboardBehavior.hpp +61 -0
- package/nitrogen/generated/android/c++/JModalContentArea.hpp +61 -0
- package/nitrogen/generated/android/c++/JModalMode.hpp +58 -0
- package/nitrogen/generated/android/c++/JPopupAnimation.hpp +61 -0
- package/nitrogen/generated/android/c++/JSheetDetent.hpp +64 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroModalStateUpdater.cpp +174 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroModalStateUpdater.hpp +54 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/DismissReason.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/Func_void.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/Func_void_DismissReason.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/Func_void_ModalContentArea.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/Func_void_double.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/HybridNitroModalSpec.kt +237 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/KeyboardBehavior.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/ModalContentArea.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/ModalMode.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/PopupAnimation.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/SheetDetent.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/nitromodalOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/views/HybridNitroModalManager.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/views/HybridNitroModalStateUpdater.kt +23 -0
- package/nitrogen/generated/android/nitromodal+autolinking.cmake +83 -0
- package/nitrogen/generated/android/nitromodal+autolinking.gradle +27 -0
- package/nitrogen/generated/android/nitromodalOnLoad.cpp +64 -0
- package/nitrogen/generated/android/nitromodalOnLoad.hpp +34 -0
- package/nitrogen/generated/ios/NitroModal+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NitroModal-Swift-Cxx-Bridge.cpp +65 -0
- package/nitrogen/generated/ios/NitroModal-Swift-Cxx-Bridge.hpp +237 -0
- package/nitrogen/generated/ios/NitroModal-Swift-Cxx-Umbrella.hpp +64 -0
- package/nitrogen/generated/ios/NitroModalAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroModalAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridNitroModalSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroModalSpecSwift.hpp +247 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroModalComponent.mm +264 -0
- package/nitrogen/generated/ios/swift/DismissReason.swift +48 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_DismissReason.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_ModalContentArea.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridNitroModalSpec.swift +77 -0
- package/nitrogen/generated/ios/swift/HybridNitroModalSpec_cxx.swift +554 -0
- package/nitrogen/generated/ios/swift/KeyboardBehavior.swift +44 -0
- package/nitrogen/generated/ios/swift/ModalContentArea.swift +34 -0
- package/nitrogen/generated/ios/swift/ModalMode.swift +40 -0
- package/nitrogen/generated/ios/swift/PopupAnimation.swift +44 -0
- package/nitrogen/generated/ios/swift/SheetDetent.swift +48 -0
- package/nitrogen/generated/shared/c++/DismissReason.hpp +84 -0
- package/nitrogen/generated/shared/c++/HybridNitroModalSpec.cpp +65 -0
- package/nitrogen/generated/shared/c++/HybridNitroModalSpec.hpp +124 -0
- package/nitrogen/generated/shared/c++/KeyboardBehavior.hpp +80 -0
- package/nitrogen/generated/shared/c++/ModalContentArea.hpp +87 -0
- package/nitrogen/generated/shared/c++/ModalMode.hpp +76 -0
- package/nitrogen/generated/shared/c++/PopupAnimation.hpp +80 -0
- package/nitrogen/generated/shared/c++/SheetDetent.hpp +84 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroModalComponent.cpp +74 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroModalComponent.hpp +151 -0
- package/nitrogen/generated/shared/json/NitroModalConfig.json +30 -0
- package/package.json +183 -0
- package/src/NitroModal.nitro.ts +92 -0
- package/src/NitroModal.tsx +292 -0
- package/src/NitroModalView.native.tsx +8 -0
- package/src/NitroModalView.tsx +24 -0
- package/src/index.tsx +12 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SheetDetent.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::nitromodal {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (SheetDetent).
|
|
30
|
+
*/
|
|
31
|
+
enum class SheetDetent {
|
|
32
|
+
SMALL SWIFT_NAME(small) = 0,
|
|
33
|
+
MEDIUM SWIFT_NAME(medium) = 1,
|
|
34
|
+
LARGE SWIFT_NAME(large) = 2,
|
|
35
|
+
FITCONTENT SWIFT_NAME(fitcontent) = 3,
|
|
36
|
+
} CLOSED_ENUM;
|
|
37
|
+
|
|
38
|
+
} // namespace margelo::nitro::nitromodal
|
|
39
|
+
|
|
40
|
+
namespace margelo::nitro {
|
|
41
|
+
|
|
42
|
+
// C++ SheetDetent <> JS SheetDetent (union)
|
|
43
|
+
template <>
|
|
44
|
+
struct JSIConverter<margelo::nitro::nitromodal::SheetDetent> final {
|
|
45
|
+
static inline margelo::nitro::nitromodal::SheetDetent fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
46
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
47
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
48
|
+
case hashString("small"): return margelo::nitro::nitromodal::SheetDetent::SMALL;
|
|
49
|
+
case hashString("medium"): return margelo::nitro::nitromodal::SheetDetent::MEDIUM;
|
|
50
|
+
case hashString("large"): return margelo::nitro::nitromodal::SheetDetent::LARGE;
|
|
51
|
+
case hashString("fitContent"): return margelo::nitro::nitromodal::SheetDetent::FITCONTENT;
|
|
52
|
+
default: [[unlikely]]
|
|
53
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum SheetDetent - invalid value!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitromodal::SheetDetent arg) {
|
|
57
|
+
switch (arg) {
|
|
58
|
+
case margelo::nitro::nitromodal::SheetDetent::SMALL: return JSIConverter<std::string>::toJSI(runtime, "small");
|
|
59
|
+
case margelo::nitro::nitromodal::SheetDetent::MEDIUM: return JSIConverter<std::string>::toJSI(runtime, "medium");
|
|
60
|
+
case margelo::nitro::nitromodal::SheetDetent::LARGE: return JSIConverter<std::string>::toJSI(runtime, "large");
|
|
61
|
+
case margelo::nitro::nitromodal::SheetDetent::FITCONTENT: return JSIConverter<std::string>::toJSI(runtime, "fitContent");
|
|
62
|
+
default: [[unlikely]]
|
|
63
|
+
throw std::invalid_argument("Cannot convert SheetDetent to JS - invalid value: "
|
|
64
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
68
|
+
if (!value.isString()) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
72
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
73
|
+
case hashString("small"):
|
|
74
|
+
case hashString("medium"):
|
|
75
|
+
case hashString("large"):
|
|
76
|
+
case hashString("fitContent"):
|
|
77
|
+
return true;
|
|
78
|
+
default:
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroModalComponent.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridNitroModalComponent.hpp"
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/NitroHash.hpp>
|
|
11
|
+
#include <NitroModules/ReactProp.hpp>
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nitromodal::views {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
extern const char HybridNitroModalComponentName[] = "NitroModal";
|
|
18
|
+
|
|
19
|
+
HybridNitroModalProps::HybridNitroModalProps(const react::PropsParserContext& context,
|
|
20
|
+
const HybridNitroModalProps& sourceProps,
|
|
21
|
+
const react::RawProps& rawProps):
|
|
22
|
+
react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
|
|
23
|
+
isOpen(nitro::ReactProp<bool>::fromRawValue("NitroModal", "isOpen", rawProps, sourceProps.isOpen)),
|
|
24
|
+
mode(nitro::ReactProp<ModalMode>::fromRawValue("NitroModal", "mode", rawProps, sourceProps.mode)),
|
|
25
|
+
detents(nitro::ReactProp<std::vector<SheetDetent>>::fromRawValue("NitroModal", "detents", rawProps, sourceProps.detents)),
|
|
26
|
+
initialDetentIndex(nitro::ReactProp<double>::fromRawValue("NitroModal", "initialDetentIndex", rawProps, sourceProps.initialDetentIndex)),
|
|
27
|
+
backdropColor(nitro::ReactProp<double>::fromRawValue("NitroModal", "backdropColor", rawProps, sourceProps.backdropColor)),
|
|
28
|
+
backdropOpacity(nitro::ReactProp<double>::fromRawValue("NitroModal", "backdropOpacity", rawProps, sourceProps.backdropOpacity)),
|
|
29
|
+
backdropBlurRadius(nitro::ReactProp<double>::fromRawValue("NitroModal", "backdropBlurRadius", rawProps, sourceProps.backdropBlurRadius)),
|
|
30
|
+
dismissOnBackdropPress(nitro::ReactProp<bool>::fromRawValue("NitroModal", "dismissOnBackdropPress", rawProps, sourceProps.dismissOnBackdropPress)),
|
|
31
|
+
dismissOnSwipe(nitro::ReactProp<bool>::fromRawValue("NitroModal", "dismissOnSwipe", rawProps, sourceProps.dismissOnSwipe)),
|
|
32
|
+
dismissOnBackButton(nitro::ReactProp<bool>::fromRawValue("NitroModal", "dismissOnBackButton", rawProps, sourceProps.dismissOnBackButton)),
|
|
33
|
+
grabberVisible(nitro::ReactProp<bool>::fromRawValue("NitroModal", "grabberVisible", rawProps, sourceProps.grabberVisible)),
|
|
34
|
+
cornerRadius(nitro::ReactProp<double>::fromRawValue("NitroModal", "cornerRadius", rawProps, sourceProps.cornerRadius)),
|
|
35
|
+
contentBackgroundColor(nitro::ReactProp<std::optional<double>>::fromRawValue("NitroModal", "contentBackgroundColor", rawProps, sourceProps.contentBackgroundColor)),
|
|
36
|
+
keyboardBehavior(nitro::ReactProp<KeyboardBehavior>::fromRawValue("NitroModal", "keyboardBehavior", rawProps, sourceProps.keyboardBehavior)),
|
|
37
|
+
popupAnimation(nitro::ReactProp<PopupAnimation>::fromRawValue("NitroModal", "popupAnimation", rawProps, sourceProps.popupAnimation)),
|
|
38
|
+
onPresent(nitro::ReactProp<std::optional<std::function<void()>>>::fromRawValue("NitroModal", "onPresent", rawProps, sourceProps.onPresent)),
|
|
39
|
+
onDismiss(nitro::ReactProp<std::optional<std::function<void(DismissReason /* reason */)>>>::fromRawValue("NitroModal", "onDismiss", rawProps, sourceProps.onDismiss)),
|
|
40
|
+
onDetentChange(nitro::ReactProp<std::optional<std::function<void(double /* index */)>>>::fromRawValue("NitroModal", "onDetentChange", rawProps, sourceProps.onDetentChange)),
|
|
41
|
+
onBackdropPress(nitro::ReactProp<std::optional<std::function<void()>>>::fromRawValue("NitroModal", "onBackdropPress", rawProps, sourceProps.onBackdropPress)),
|
|
42
|
+
onBackButtonPress(nitro::ReactProp<std::optional<std::function<void()>>>::fromRawValue("NitroModal", "onBackButtonPress", rawProps, sourceProps.onBackButtonPress)),
|
|
43
|
+
onContentAreaChange(nitro::ReactProp<std::optional<std::function<void(const ModalContentArea& /* area */)>>>::fromRawValue("NitroModal", "onContentAreaChange", rawProps, sourceProps.onContentAreaChange)),
|
|
44
|
+
hybridRef(nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridNitroModalSpec>& /* ref */)>>>::fromRawValue("NitroModal", "hybridRef", rawProps, sourceProps.hybridRef)) { }
|
|
45
|
+
|
|
46
|
+
bool HybridNitroModalProps::filterObjectKeys(const std::string& propName) {
|
|
47
|
+
switch (hashString(propName)) {
|
|
48
|
+
case hashString("isOpen"): return true;
|
|
49
|
+
case hashString("mode"): return true;
|
|
50
|
+
case hashString("detents"): return true;
|
|
51
|
+
case hashString("initialDetentIndex"): return true;
|
|
52
|
+
case hashString("backdropColor"): return true;
|
|
53
|
+
case hashString("backdropOpacity"): return true;
|
|
54
|
+
case hashString("backdropBlurRadius"): return true;
|
|
55
|
+
case hashString("dismissOnBackdropPress"): return true;
|
|
56
|
+
case hashString("dismissOnSwipe"): return true;
|
|
57
|
+
case hashString("dismissOnBackButton"): return true;
|
|
58
|
+
case hashString("grabberVisible"): return true;
|
|
59
|
+
case hashString("cornerRadius"): return true;
|
|
60
|
+
case hashString("contentBackgroundColor"): return true;
|
|
61
|
+
case hashString("keyboardBehavior"): return true;
|
|
62
|
+
case hashString("popupAnimation"): return true;
|
|
63
|
+
case hashString("onPresent"): return true;
|
|
64
|
+
case hashString("onDismiss"): return true;
|
|
65
|
+
case hashString("onDetentChange"): return true;
|
|
66
|
+
case hashString("onBackdropPress"): return true;
|
|
67
|
+
case hashString("onBackButtonPress"): return true;
|
|
68
|
+
case hashString("onContentAreaChange"): return true;
|
|
69
|
+
case hashString("hybridRef"): return true;
|
|
70
|
+
default: return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
} // namespace margelo::nitro::nitromodal::views
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroModalComponent.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/ReactProp.hpp>
|
|
11
|
+
#include <NitroModules/ViewComponentDescriptor.hpp>
|
|
12
|
+
#include <NitroModules/ViewPropsHolderState.hpp>
|
|
13
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
14
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
15
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
16
|
+
#include <react/renderer/core/RawProps.h>
|
|
17
|
+
|
|
18
|
+
#include <string>
|
|
19
|
+
|
|
20
|
+
#include "ModalMode.hpp"
|
|
21
|
+
#include "SheetDetent.hpp"
|
|
22
|
+
#include <vector>
|
|
23
|
+
#include <optional>
|
|
24
|
+
#include "KeyboardBehavior.hpp"
|
|
25
|
+
#include "PopupAnimation.hpp"
|
|
26
|
+
#include <functional>
|
|
27
|
+
#include "DismissReason.hpp"
|
|
28
|
+
#include "ModalContentArea.hpp"
|
|
29
|
+
#include <memory>
|
|
30
|
+
#include "HybridNitroModalSpec.hpp"
|
|
31
|
+
|
|
32
|
+
namespace margelo::nitro::nitromodal::views {
|
|
33
|
+
|
|
34
|
+
using namespace facebook;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The name of the actual native View.
|
|
38
|
+
*/
|
|
39
|
+
extern const char HybridNitroModalComponentName[];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Props for the "NitroModal" View.
|
|
43
|
+
*/
|
|
44
|
+
class HybridNitroModalProps final: public react::ViewProps {
|
|
45
|
+
public:
|
|
46
|
+
HybridNitroModalProps() = default;
|
|
47
|
+
HybridNitroModalProps(const react::PropsParserContext& context,
|
|
48
|
+
const HybridNitroModalProps& sourceProps,
|
|
49
|
+
const react::RawProps& rawProps);
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
nitro::ReactProp<bool> isOpen;
|
|
53
|
+
nitro::ReactProp<ModalMode> mode;
|
|
54
|
+
nitro::ReactProp<std::vector<SheetDetent>> detents;
|
|
55
|
+
nitro::ReactProp<double> initialDetentIndex;
|
|
56
|
+
nitro::ReactProp<double> backdropColor;
|
|
57
|
+
nitro::ReactProp<double> backdropOpacity;
|
|
58
|
+
nitro::ReactProp<double> backdropBlurRadius;
|
|
59
|
+
nitro::ReactProp<bool> dismissOnBackdropPress;
|
|
60
|
+
nitro::ReactProp<bool> dismissOnSwipe;
|
|
61
|
+
nitro::ReactProp<bool> dismissOnBackButton;
|
|
62
|
+
nitro::ReactProp<bool> grabberVisible;
|
|
63
|
+
nitro::ReactProp<double> cornerRadius;
|
|
64
|
+
nitro::ReactProp<std::optional<double>> contentBackgroundColor;
|
|
65
|
+
nitro::ReactProp<KeyboardBehavior> keyboardBehavior;
|
|
66
|
+
nitro::ReactProp<PopupAnimation> popupAnimation;
|
|
67
|
+
nitro::ReactProp<std::optional<std::function<void()>>> onPresent;
|
|
68
|
+
nitro::ReactProp<std::optional<std::function<void(DismissReason /* reason */)>>> onDismiss;
|
|
69
|
+
nitro::ReactProp<std::optional<std::function<void(double /* index */)>>> onDetentChange;
|
|
70
|
+
nitro::ReactProp<std::optional<std::function<void()>>> onBackdropPress;
|
|
71
|
+
nitro::ReactProp<std::optional<std::function<void()>>> onBackButtonPress;
|
|
72
|
+
nitro::ReactProp<std::optional<std::function<void(const ModalContentArea& /* area */)>>> onContentAreaChange;
|
|
73
|
+
nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridNitroModalSpec>& /* ref */)>>> hybridRef;
|
|
74
|
+
|
|
75
|
+
[[nodiscard]]
|
|
76
|
+
bool hasSameProps(const HybridNitroModalProps& other) const noexcept {
|
|
77
|
+
return isOpen.hasSameValue(other.isOpen) &&
|
|
78
|
+
mode.hasSameValue(other.mode) &&
|
|
79
|
+
detents.hasSameValue(other.detents) &&
|
|
80
|
+
initialDetentIndex.hasSameValue(other.initialDetentIndex) &&
|
|
81
|
+
backdropColor.hasSameValue(other.backdropColor) &&
|
|
82
|
+
backdropOpacity.hasSameValue(other.backdropOpacity) &&
|
|
83
|
+
backdropBlurRadius.hasSameValue(other.backdropBlurRadius) &&
|
|
84
|
+
dismissOnBackdropPress.hasSameValue(other.dismissOnBackdropPress) &&
|
|
85
|
+
dismissOnSwipe.hasSameValue(other.dismissOnSwipe) &&
|
|
86
|
+
dismissOnBackButton.hasSameValue(other.dismissOnBackButton) &&
|
|
87
|
+
grabberVisible.hasSameValue(other.grabberVisible) &&
|
|
88
|
+
cornerRadius.hasSameValue(other.cornerRadius) &&
|
|
89
|
+
contentBackgroundColor.hasSameValue(other.contentBackgroundColor) &&
|
|
90
|
+
keyboardBehavior.hasSameValue(other.keyboardBehavior) &&
|
|
91
|
+
popupAnimation.hasSameValue(other.popupAnimation) &&
|
|
92
|
+
onPresent.hasSameValue(other.onPresent) &&
|
|
93
|
+
onDismiss.hasSameValue(other.onDismiss) &&
|
|
94
|
+
onDetentChange.hasSameValue(other.onDetentChange) &&
|
|
95
|
+
onBackdropPress.hasSameValue(other.onBackdropPress) &&
|
|
96
|
+
onBackButtonPress.hasSameValue(other.onBackButtonPress) &&
|
|
97
|
+
onContentAreaChange.hasSameValue(other.onContentAreaChange) &&
|
|
98
|
+
hybridRef.hasSameValue(other.hybridRef);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
[[nodiscard]]
|
|
102
|
+
bool hasAnyProvidedProps() const noexcept {
|
|
103
|
+
return isOpen.isProvided() ||
|
|
104
|
+
mode.isProvided() ||
|
|
105
|
+
detents.isProvided() ||
|
|
106
|
+
initialDetentIndex.isProvided() ||
|
|
107
|
+
backdropColor.isProvided() ||
|
|
108
|
+
backdropOpacity.isProvided() ||
|
|
109
|
+
backdropBlurRadius.isProvided() ||
|
|
110
|
+
dismissOnBackdropPress.isProvided() ||
|
|
111
|
+
dismissOnSwipe.isProvided() ||
|
|
112
|
+
dismissOnBackButton.isProvided() ||
|
|
113
|
+
grabberVisible.isProvided() ||
|
|
114
|
+
cornerRadius.isProvided() ||
|
|
115
|
+
contentBackgroundColor.isProvided() ||
|
|
116
|
+
keyboardBehavior.isProvided() ||
|
|
117
|
+
popupAnimation.isProvided() ||
|
|
118
|
+
onPresent.isProvided() ||
|
|
119
|
+
onDismiss.isProvided() ||
|
|
120
|
+
onDetentChange.isProvided() ||
|
|
121
|
+
onBackdropPress.isProvided() ||
|
|
122
|
+
onBackButtonPress.isProvided() ||
|
|
123
|
+
onContentAreaChange.isProvided() ||
|
|
124
|
+
hybridRef.isProvided();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private:
|
|
128
|
+
static bool filterObjectKeys(const std::string& propName);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* State for the "NitroModal" View.
|
|
133
|
+
*/
|
|
134
|
+
using HybridNitroModalState = nitro::ViewPropsHolderState<HybridNitroModalProps>;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The Shadow Node for the "NitroModal" View.
|
|
138
|
+
*/
|
|
139
|
+
using HybridNitroModalShadowNode = react::ConcreteViewShadowNode<HybridNitroModalComponentName /* "HybridNitroModal" */,
|
|
140
|
+
HybridNitroModalProps /* custom props */,
|
|
141
|
+
react::ViewEventEmitter /* default */,
|
|
142
|
+
HybridNitroModalState /* custom state */>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The Component Descriptor for the "NitroModal" View.
|
|
146
|
+
*/
|
|
147
|
+
using HybridNitroModalComponentDescriptor = nitro::ViewComponentDescriptor<HybridNitroModalShadowNode>;
|
|
148
|
+
|
|
149
|
+
/* The actual view for "NitroModal" needs to be implemented in platform-specific code. */
|
|
150
|
+
|
|
151
|
+
} // namespace margelo::nitro::nitromodal::views
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"uiViewClassName": "NitroModal",
|
|
3
|
+
"supportsRawText": false,
|
|
4
|
+
"bubblingEventTypes": {},
|
|
5
|
+
"directEventTypes": {},
|
|
6
|
+
"validAttributes": {
|
|
7
|
+
"isOpen": true,
|
|
8
|
+
"mode": true,
|
|
9
|
+
"detents": true,
|
|
10
|
+
"initialDetentIndex": true,
|
|
11
|
+
"backdropColor": true,
|
|
12
|
+
"backdropOpacity": true,
|
|
13
|
+
"backdropBlurRadius": true,
|
|
14
|
+
"dismissOnBackdropPress": true,
|
|
15
|
+
"dismissOnSwipe": true,
|
|
16
|
+
"dismissOnBackButton": true,
|
|
17
|
+
"grabberVisible": true,
|
|
18
|
+
"cornerRadius": true,
|
|
19
|
+
"contentBackgroundColor": true,
|
|
20
|
+
"keyboardBehavior": true,
|
|
21
|
+
"popupAnimation": true,
|
|
22
|
+
"onPresent": true,
|
|
23
|
+
"onDismiss": true,
|
|
24
|
+
"onDetentChange": true,
|
|
25
|
+
"onBackdropPress": true,
|
|
26
|
+
"onBackButtonPress": true,
|
|
27
|
+
"onContentAreaChange": true,
|
|
28
|
+
"hybridRef": true
|
|
29
|
+
}
|
|
30
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-nitro-modal",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "react native native modal",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"react-native-nitro-modal-source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"nitrogen",
|
|
22
|
+
"nitro.json",
|
|
23
|
+
"*.podspec",
|
|
24
|
+
"react-native.config.js",
|
|
25
|
+
"!ios/build",
|
|
26
|
+
"!android/build",
|
|
27
|
+
"!android/gradle",
|
|
28
|
+
"!android/gradlew",
|
|
29
|
+
"!android/gradlew.bat",
|
|
30
|
+
"!android/local.properties",
|
|
31
|
+
"!**/__tests__",
|
|
32
|
+
"!**/__fixtures__",
|
|
33
|
+
"!**/__mocks__",
|
|
34
|
+
"!**/.*"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"example": "yarn workspace react-native-nitro-modal-example",
|
|
38
|
+
"clean": "del-cli lib",
|
|
39
|
+
"prepare": "bob build",
|
|
40
|
+
"nitrogen": "nitrogen",
|
|
41
|
+
"typecheck": "tsc",
|
|
42
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
43
|
+
"test": "jest",
|
|
44
|
+
"release": "release-it --only-version"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"react-native",
|
|
48
|
+
"ios",
|
|
49
|
+
"android"
|
|
50
|
+
],
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/mohamadnavabi/react-native-nitro-modal.git"
|
|
54
|
+
},
|
|
55
|
+
"author": "Mohammad Navabi <7navabi@gmail.com> (https://github.com/mohamadnavabi)",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/mohamadnavabi/react-native-nitro-modal/issues"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://github.com/mohamadnavabi/react-native-nitro-modal#readme",
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"registry": "https://registry.npmjs.org/"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@commitlint/config-conventional": "^21.2.0",
|
|
66
|
+
"@eslint/compat": "^2.1.0",
|
|
67
|
+
"@eslint/eslintrc": "^3.3.6",
|
|
68
|
+
"@eslint/js": "^9.39.5",
|
|
69
|
+
"@jest/globals": "^29.7.0",
|
|
70
|
+
"@react-native/babel-preset": "0.86.2",
|
|
71
|
+
"@react-native/eslint-config": "0.86.2",
|
|
72
|
+
"@react-native/jest-preset": "0.86.2",
|
|
73
|
+
"@release-it/conventional-changelog": "^12.0.0",
|
|
74
|
+
"@types/react": "^19.2.0",
|
|
75
|
+
"commitlint": "^21.2.1",
|
|
76
|
+
"del-cli": "^7.0.0",
|
|
77
|
+
"eslint": "^9.39.5",
|
|
78
|
+
"eslint-config-prettier": "^10.1.8",
|
|
79
|
+
"eslint-plugin-ft-flow": "^3.0.11",
|
|
80
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
81
|
+
"jest": "^29.7.0",
|
|
82
|
+
"lefthook": "^2.1.10",
|
|
83
|
+
"nitrogen": "^0.37.1",
|
|
84
|
+
"prettier": "^3.9.6",
|
|
85
|
+
"react": "19.2.3",
|
|
86
|
+
"react-native": "0.86.3",
|
|
87
|
+
"react-native-builder-bob": "^0.43.1",
|
|
88
|
+
"react-native-nitro-modules": "^0.37.1",
|
|
89
|
+
"release-it": "^21.0.1",
|
|
90
|
+
"turbo": "^2.10.8",
|
|
91
|
+
"typescript": "^6.0.3"
|
|
92
|
+
},
|
|
93
|
+
"peerDependencies": {
|
|
94
|
+
"react": "*",
|
|
95
|
+
"react-native": "*",
|
|
96
|
+
"react-native-nitro-modules": "^0.37.1"
|
|
97
|
+
},
|
|
98
|
+
"workspaces": [
|
|
99
|
+
"example"
|
|
100
|
+
],
|
|
101
|
+
"packageManager": "yarn@4.11.0",
|
|
102
|
+
"react-native-builder-bob": {
|
|
103
|
+
"source": "src",
|
|
104
|
+
"output": "lib",
|
|
105
|
+
"targets": [
|
|
106
|
+
[
|
|
107
|
+
"custom",
|
|
108
|
+
{
|
|
109
|
+
"script": "nitrogen",
|
|
110
|
+
"clean": "nitrogen/"
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
[
|
|
114
|
+
"module",
|
|
115
|
+
{
|
|
116
|
+
"esm": true
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
[
|
|
120
|
+
"typescript",
|
|
121
|
+
{
|
|
122
|
+
"project": "tsconfig.build.json"
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
"prettier": {
|
|
128
|
+
"quoteProps": "consistent",
|
|
129
|
+
"singleQuote": true,
|
|
130
|
+
"tabWidth": 2,
|
|
131
|
+
"trailingComma": "es5",
|
|
132
|
+
"useTabs": false
|
|
133
|
+
},
|
|
134
|
+
"jest": {
|
|
135
|
+
"preset": "@react-native/jest-preset",
|
|
136
|
+
"testEnvironmentOptions": {
|
|
137
|
+
"customExportConditions": [
|
|
138
|
+
"require",
|
|
139
|
+
"react-native",
|
|
140
|
+
"<%- project.sourceCondition -%>"
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
"modulePathIgnorePatterns": [
|
|
144
|
+
"<rootDir>/example/node_modules",
|
|
145
|
+
"<rootDir>/lib/"
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
"commitlint": {
|
|
149
|
+
"extends": [
|
|
150
|
+
"@commitlint/config-conventional"
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
"release-it": {
|
|
154
|
+
"git": {
|
|
155
|
+
"commitMessage": "chore: release ${version}",
|
|
156
|
+
"tagName": "v${version}"
|
|
157
|
+
},
|
|
158
|
+
"npm": {
|
|
159
|
+
"publish": true
|
|
160
|
+
},
|
|
161
|
+
"github": {
|
|
162
|
+
"release": true
|
|
163
|
+
},
|
|
164
|
+
"plugins": {
|
|
165
|
+
"@release-it/conventional-changelog": {
|
|
166
|
+
"preset": {
|
|
167
|
+
"name": "angular"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"create-react-native-library": {
|
|
173
|
+
"type": "nitro-view",
|
|
174
|
+
"languages": "kotlin-swift",
|
|
175
|
+
"tools": [
|
|
176
|
+
"eslint",
|
|
177
|
+
"jest",
|
|
178
|
+
"lefthook",
|
|
179
|
+
"release-it"
|
|
180
|
+
],
|
|
181
|
+
"version": "0.63.1"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HybridView,
|
|
3
|
+
HybridViewMethods,
|
|
4
|
+
HybridViewProps,
|
|
5
|
+
} from 'react-native-nitro-modules';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* How the modal is presented.
|
|
9
|
+
* - `bottomSheet`: native sheet (iOS `UISheetPresentationController`,
|
|
10
|
+
* Android `BottomSheetBehavior`) with detents and swipe-to-dismiss.
|
|
11
|
+
* - `popup`: centered dialog with a native fade/scale transition.
|
|
12
|
+
*/
|
|
13
|
+
export type ModalMode = 'bottomSheet' | 'popup';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Resting heights of a `bottomSheet`.
|
|
17
|
+
* - `small`: ~25% of the available height.
|
|
18
|
+
* - `medium`: ~50% of the available height.
|
|
19
|
+
* - `large`: the full available height.
|
|
20
|
+
* - `fitContent`: the measured height of the React content.
|
|
21
|
+
*/
|
|
22
|
+
export type SheetDetent = 'small' | 'medium' | 'large' | 'fitContent';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* How the modal reacts to the software keyboard.
|
|
26
|
+
* - `pan`: the sheet/card is translated above the keyboard, in sync with the
|
|
27
|
+
* keyboard animation. The content keeps its size.
|
|
28
|
+
* - `resize`: like `pan`, and the area reported to the content shrinks so
|
|
29
|
+
* scrollable content can fit above the keyboard.
|
|
30
|
+
* - `none`: the keyboard is ignored.
|
|
31
|
+
*/
|
|
32
|
+
export type KeyboardBehavior = 'pan' | 'resize' | 'none';
|
|
33
|
+
|
|
34
|
+
/** Enter/exit transition of a `popup`. */
|
|
35
|
+
export type PopupAnimation = 'scale' | 'fade' | 'none';
|
|
36
|
+
|
|
37
|
+
/** What caused the modal to close. */
|
|
38
|
+
export type DismissReason =
|
|
39
|
+
'programmatic' | 'swipe' | 'backdrop' | 'backButton';
|
|
40
|
+
|
|
41
|
+
/** Size (dp/pt) available to the React content inside the presented modal. */
|
|
42
|
+
export interface ModalContentArea {
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface NitroModalProps extends HybridViewProps {
|
|
48
|
+
/** Whether the modal should be presented. */
|
|
49
|
+
isOpen: boolean;
|
|
50
|
+
mode: ModalMode;
|
|
51
|
+
/** Detents of a `bottomSheet`, smallest first. At most 3 are used on Android. */
|
|
52
|
+
detents: SheetDetent[];
|
|
53
|
+
/** Index into `detents` that the sheet opens at. */
|
|
54
|
+
initialDetentIndex: number;
|
|
55
|
+
/** Backdrop color as a processed ARGB color (see `processColor`). */
|
|
56
|
+
backdropColor: number;
|
|
57
|
+
/** Opacity of the backdrop color, 0-1. */
|
|
58
|
+
backdropOpacity: number;
|
|
59
|
+
/** Blur radius (dp/pt) applied behind the modal. 0 disables the blur. */
|
|
60
|
+
backdropBlurRadius: number;
|
|
61
|
+
dismissOnBackdropPress: boolean;
|
|
62
|
+
dismissOnSwipe: boolean;
|
|
63
|
+
dismissOnBackButton: boolean;
|
|
64
|
+
grabberVisible: boolean;
|
|
65
|
+
/** Corner radius of the sheet/card. A negative value uses the platform default. */
|
|
66
|
+
cornerRadius: number;
|
|
67
|
+
/** Sheet/card background as a processed ARGB color. Omit for the system background. */
|
|
68
|
+
contentBackgroundColor?: number;
|
|
69
|
+
keyboardBehavior: KeyboardBehavior;
|
|
70
|
+
popupAnimation: PopupAnimation;
|
|
71
|
+
|
|
72
|
+
/** The present transition finished. */
|
|
73
|
+
onPresent?: () => void;
|
|
74
|
+
/** The modal is fully gone. Fired exactly once for every presentation request. */
|
|
75
|
+
onDismiss?: (reason: DismissReason) => void;
|
|
76
|
+
/** A `bottomSheet` settled on a different detent. */
|
|
77
|
+
onDetentChange?: (index: number) => void;
|
|
78
|
+
onBackdropPress?: () => void;
|
|
79
|
+
/** Android hardware/gesture back. */
|
|
80
|
+
onBackButtonPress?: () => void;
|
|
81
|
+
/** The area available to the content changed (rotation, keyboard, sheet sizing). */
|
|
82
|
+
onContentAreaChange?: (area: ModalContentArea) => void;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface NitroModalMethods extends HybridViewMethods {
|
|
86
|
+
present(): void;
|
|
87
|
+
dismiss(): void;
|
|
88
|
+
/** Animates a `bottomSheet` to `detents[index]`. */
|
|
89
|
+
snapToDetent(index: number): void;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type NitroModal = HybridView<NitroModalProps, NitroModalMethods>;
|