react-native-nitro-modal 0.2.0 → 0.3.1-rc
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/README.md +52 -4
- package/android/src/main/java/com/margelo/nitro/nitromodal/BottomSheetPresenter.kt +399 -34
- package/android/src/main/java/com/margelo/nitro/nitromodal/HybridNitroModal.kt +67 -22
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalConfig.kt +35 -1
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalContentRoot.kt +48 -5
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalPresenter.kt +63 -4
- package/android/src/main/java/com/margelo/nitro/nitromodal/NitroModalHostView.kt +68 -8
- package/ios/HybridNitroModal.swift +115 -20
- package/ios/ModalConfig.swift +48 -2
- package/ios/NitroModalHostView.swift +73 -8
- package/ios/SheetView.swift +647 -0
- package/ios/SheetViewController.swift +19 -450
- package/lib/module/NitroModal.js +54 -6
- package/lib/module/NitroModal.js.map +1 -1
- package/lib/module/NitroModalView.web.js +86 -26
- package/lib/module/NitroModalView.web.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/web/AnimatedValue.js +3 -0
- package/lib/module/web/AnimatedValue.js.map +1 -1
- package/lib/module/web/ModalConfig.js +10 -4
- package/lib/module/web/ModalConfig.js.map +1 -1
- package/lib/module/web/ModalController.js +29 -2
- package/lib/module/web/ModalController.js.map +1 -1
- package/lib/module/web/ModalPresenter.js +47 -12
- package/lib/module/web/ModalPresenter.js.map +1 -1
- package/lib/module/web/SheetPresenter.js +118 -34
- package/lib/module/web/SheetPresenter.js.map +1 -1
- package/lib/module/web/dom.js +16 -0
- package/lib/module/web/dom.js.map +1 -1
- package/lib/typescript/src/NitroModal.d.ts +42 -2
- package/lib/typescript/src/NitroModal.d.ts.map +1 -1
- package/lib/typescript/src/NitroModal.nitro.d.ts +37 -2
- package/lib/typescript/src/NitroModal.nitro.d.ts.map +1 -1
- package/lib/typescript/src/NitroModalView.web.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/web/AnimatedValue.d.ts +1 -0
- package/lib/typescript/src/web/AnimatedValue.d.ts.map +1 -1
- package/lib/typescript/src/web/ModalConfig.d.ts +10 -0
- package/lib/typescript/src/web/ModalConfig.d.ts.map +1 -1
- package/lib/typescript/src/web/ModalController.d.ts +5 -0
- package/lib/typescript/src/web/ModalController.d.ts.map +1 -1
- package/lib/typescript/src/web/ModalPresenter.d.ts +13 -0
- package/lib/typescript/src/web/ModalPresenter.d.ts.map +1 -1
- package/lib/typescript/src/web/SheetPresenter.d.ts +13 -2
- package/lib/typescript/src/web/SheetPresenter.d.ts.map +1 -1
- package/lib/typescript/src/web/dom.d.ts +4 -0
- package/lib/typescript/src/web/dom.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridNitroModalSpec.cpp +78 -6
- package/nitrogen/generated/android/c++/JHybridNitroModalSpec.hpp +14 -2
- package/nitrogen/generated/android/c++/JNamedSheetDetent.hpp +64 -0
- package/nitrogen/generated/android/c++/JSheetDetent.cpp +26 -0
- package/nitrogen/generated/android/c++/JSheetDetent.hpp +42 -37
- package/nitrogen/generated/android/c++/views/JHybridNitroModalStateUpdater.cpp +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/HybridNitroModalSpec.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/NamedSheetDetent.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/SheetDetent.kt +47 -10
- package/nitrogen/generated/android/nitromodal+autolinking.cmake +1 -0
- package/nitrogen/generated/ios/NitroModal-Swift-Cxx-Bridge.hpp +68 -8
- package/nitrogen/generated/ios/NitroModal-Swift-Cxx-Umbrella.hpp +4 -3
- package/nitrogen/generated/ios/c++/HybridNitroModalSpecSwift.hpp +46 -5
- package/nitrogen/generated/ios/c++/views/HybridNitroModalComponent.mm +36 -0
- package/nitrogen/generated/ios/swift/HybridNitroModalSpec.swift +6 -0
- package/nitrogen/generated/ios/swift/HybridNitroModalSpec_cxx.swift +158 -5
- package/nitrogen/generated/ios/swift/NamedSheetDetent.swift +48 -0
- package/nitrogen/generated/ios/swift/SheetDetent.swift +15 -33
- package/nitrogen/generated/shared/c++/HybridNitroModalSpec.cpp +12 -0
- package/nitrogen/generated/shared/c++/HybridNitroModalSpec.hpp +18 -5
- package/nitrogen/generated/shared/c++/{SheetDetent.hpp → NamedSheetDetent.hpp} +17 -17
- package/nitrogen/generated/shared/c++/views/HybridNitroModalComponent.cpp +13 -1
- package/nitrogen/generated/shared/c++/views/HybridNitroModalComponent.hpp +21 -2
- package/nitrogen/generated/shared/json/NitroModalConfig.json +6 -0
- package/package.json +1 -1
- package/src/NitroModal.nitro.ts +38 -2
- package/src/NitroModal.tsx +93 -4
- package/src/NitroModalView.web.tsx +79 -12
- package/src/index.tsx +2 -0
- package/src/web/AnimatedValue.ts +4 -0
- package/src/web/ModalConfig.ts +19 -3
- package/src/web/ModalController.ts +35 -2
- package/src/web/ModalPresenter.ts +50 -11
- package/src/web/SheetPresenter.ts +169 -37
- package/src/web/dom.ts +20 -0
|
@@ -8,57 +8,62 @@
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
10
|
#include <fbjni/fbjni.h>
|
|
11
|
-
#include
|
|
11
|
+
#include <variant>
|
|
12
|
+
|
|
13
|
+
#include "NamedSheetDetent.hpp"
|
|
14
|
+
#include <variant>
|
|
15
|
+
#include "JNamedSheetDetent.hpp"
|
|
12
16
|
|
|
13
17
|
namespace margelo::nitro::nitromodal {
|
|
14
18
|
|
|
15
19
|
using namespace facebook;
|
|
16
20
|
|
|
17
21
|
/**
|
|
18
|
-
* The C++ JNI bridge between the C++
|
|
22
|
+
* The C++ JNI bridge between the C++ std::variant and the Java class "SheetDetent".
|
|
19
23
|
*/
|
|
20
|
-
|
|
24
|
+
class JSheetDetent: public jni::JavaClass<JSheetDetent> {
|
|
21
25
|
public:
|
|
22
26
|
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitromodal/SheetDetent;";
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
static const auto clazz = javaClassStatic();
|
|
32
|
-
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
-
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
-
return static_cast<SheetDetent>(ordinal);
|
|
28
|
+
static jni::local_ref<JSheetDetent> create_0(jni::alias_ref<JNamedSheetDetent> value) {
|
|
29
|
+
static const auto method = javaClassStatic()->getStaticMethod<JSheetDetent(jni::alias_ref<JNamedSheetDetent>)>("create");
|
|
30
|
+
return method(javaClassStatic(), value);
|
|
31
|
+
}
|
|
32
|
+
static jni::local_ref<JSheetDetent> create_1(double value) {
|
|
33
|
+
static const auto method = javaClassStatic()->getStaticMethod<JSheetDetent(double)>("create");
|
|
34
|
+
return method(javaClassStatic(), value);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
static jni::alias_ref<JSheetDetent> fromCpp(SheetDetent value) {
|
|
43
|
-
static const auto clazz = javaClassStatic();
|
|
44
|
-
switch (value) {
|
|
45
|
-
case SheetDetent::SMALL:
|
|
46
|
-
static const auto fieldSMALL = clazz->getStaticField<JSheetDetent>("SMALL");
|
|
47
|
-
return clazz->getStaticFieldValue(fieldSMALL);
|
|
48
|
-
case SheetDetent::MEDIUM:
|
|
49
|
-
static const auto fieldMEDIUM = clazz->getStaticField<JSheetDetent>("MEDIUM");
|
|
50
|
-
return clazz->getStaticFieldValue(fieldMEDIUM);
|
|
51
|
-
case SheetDetent::LARGE:
|
|
52
|
-
static const auto fieldLARGE = clazz->getStaticField<JSheetDetent>("LARGE");
|
|
53
|
-
return clazz->getStaticFieldValue(fieldLARGE);
|
|
54
|
-
case SheetDetent::FITCONTENT:
|
|
55
|
-
static const auto fieldFITCONTENT = clazz->getStaticField<JSheetDetent>("FITCONTENT");
|
|
56
|
-
return clazz->getStaticFieldValue(fieldFITCONTENT);
|
|
57
|
-
default:
|
|
58
|
-
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
59
|
-
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
37
|
+
static jni::local_ref<JSheetDetent> fromCpp(const std::variant<NamedSheetDetent, double>& variant) {
|
|
38
|
+
switch (variant.index()) {
|
|
39
|
+
case 0: return create_0(JNamedSheetDetent::fromCpp(std::get<0>(variant)));
|
|
40
|
+
case 1: return create_1(std::get<1>(variant));
|
|
41
|
+
default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")");
|
|
60
42
|
}
|
|
61
43
|
}
|
|
44
|
+
|
|
45
|
+
[[nodiscard]] std::variant<NamedSheetDetent, double> toCpp() const;
|
|
62
46
|
};
|
|
63
47
|
|
|
48
|
+
namespace JSheetDetent_impl {
|
|
49
|
+
class First final: public jni::JavaClass<First, JSheetDetent> {
|
|
50
|
+
public:
|
|
51
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitromodal/SheetDetent$First;";
|
|
52
|
+
|
|
53
|
+
[[nodiscard]] jni::local_ref<JNamedSheetDetent> getValue() const {
|
|
54
|
+
static const auto field = javaClassStatic()->getField<JNamedSheetDetent>("value");
|
|
55
|
+
return getFieldValue(field);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
class Second final: public jni::JavaClass<Second, JSheetDetent> {
|
|
60
|
+
public:
|
|
61
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitromodal/SheetDetent$Second;";
|
|
62
|
+
|
|
63
|
+
[[nodiscard]] double getValue() const {
|
|
64
|
+
static const auto field = javaClassStatic()->getField<double>("value");
|
|
65
|
+
return getFieldValue(field);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
} // namespace JSheetDetent_impl
|
|
64
69
|
} // namespace margelo::nitro::nitromodal
|
|
@@ -63,6 +63,11 @@ void JHybridNitroModalStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>
|
|
|
63
63
|
: !newProps->mode.hasSameValue(oldProps->mode)) {
|
|
64
64
|
hybridView->setMode(newProps->mode.get());
|
|
65
65
|
}
|
|
66
|
+
if (oldProps == nullptr
|
|
67
|
+
? newProps->isInline.isProvided()
|
|
68
|
+
: !newProps->isInline.hasSameValue(oldProps->isInline)) {
|
|
69
|
+
hybridView->setIsInline(newProps->isInline.get());
|
|
70
|
+
}
|
|
66
71
|
if (oldProps == nullptr
|
|
67
72
|
? newProps->detents.isProvided()
|
|
68
73
|
: !newProps->detents.hasSameValue(oldProps->detents)) {
|
|
@@ -128,6 +133,21 @@ void JHybridNitroModalStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>
|
|
|
128
133
|
: !newProps->popupAnimation.hasSameValue(oldProps->popupAnimation)) {
|
|
129
134
|
hybridView->setPopupAnimation(newProps->popupAnimation.get());
|
|
130
135
|
}
|
|
136
|
+
if (oldProps == nullptr
|
|
137
|
+
? newProps->pullToRefreshEnabled.isProvided()
|
|
138
|
+
: !newProps->pullToRefreshEnabled.hasSameValue(oldProps->pullToRefreshEnabled)) {
|
|
139
|
+
hybridView->setPullToRefreshEnabled(newProps->pullToRefreshEnabled.get());
|
|
140
|
+
}
|
|
141
|
+
if (oldProps == nullptr
|
|
142
|
+
? newProps->refreshing.isProvided()
|
|
143
|
+
: !newProps->refreshing.hasSameValue(oldProps->refreshing)) {
|
|
144
|
+
hybridView->setRefreshing(newProps->refreshing.get());
|
|
145
|
+
}
|
|
146
|
+
if (oldProps == nullptr
|
|
147
|
+
? newProps->refreshIndicatorColor.isProvided()
|
|
148
|
+
: !newProps->refreshIndicatorColor.hasSameValue(oldProps->refreshIndicatorColor)) {
|
|
149
|
+
hybridView->setRefreshIndicatorColor(newProps->refreshIndicatorColor.get());
|
|
150
|
+
}
|
|
131
151
|
if (oldProps == nullptr
|
|
132
152
|
? newProps->onPresent.isProvided()
|
|
133
153
|
: !newProps->onPresent.hasSameValue(oldProps->onPresent)) {
|
|
@@ -158,6 +178,16 @@ void JHybridNitroModalStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>
|
|
|
158
178
|
: !newProps->onContentAreaChange.hasSameValue(oldProps->onContentAreaChange)) {
|
|
159
179
|
hybridView->setOnContentAreaChange(newProps->onContentAreaChange.get());
|
|
160
180
|
}
|
|
181
|
+
if (oldProps == nullptr
|
|
182
|
+
? newProps->onPullToRefresh.isProvided()
|
|
183
|
+
: !newProps->onPullToRefresh.hasSameValue(oldProps->onPullToRefresh)) {
|
|
184
|
+
hybridView->setOnPullToRefresh(newProps->onPullToRefresh.get());
|
|
185
|
+
}
|
|
186
|
+
if (oldProps == nullptr
|
|
187
|
+
? newProps->onRestingTopChange.isProvided()
|
|
188
|
+
: !newProps->onRestingTopChange.hasSameValue(oldProps->onRestingTopChange)) {
|
|
189
|
+
hybridView->setOnRestingTopChange(newProps->onRestingTopChange.get());
|
|
190
|
+
}
|
|
161
191
|
|
|
162
192
|
// Update hybridRef if it changed
|
|
163
193
|
if (oldProps == nullptr
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/HybridNitroModalSpec.kt
CHANGED
|
@@ -39,6 +39,12 @@ abstract class HybridNitroModalSpec: HybridView() {
|
|
|
39
39
|
@set:Keep
|
|
40
40
|
abstract var mode: ModalMode
|
|
41
41
|
|
|
42
|
+
@get:DoNotStrip
|
|
43
|
+
@get:Keep
|
|
44
|
+
@set:DoNotStrip
|
|
45
|
+
@set:Keep
|
|
46
|
+
abstract var isInline: Boolean
|
|
47
|
+
|
|
42
48
|
@get:DoNotStrip
|
|
43
49
|
@get:Keep
|
|
44
50
|
@set:DoNotStrip
|
|
@@ -117,6 +123,24 @@ abstract class HybridNitroModalSpec: HybridView() {
|
|
|
117
123
|
@set:Keep
|
|
118
124
|
abstract var popupAnimation: PopupAnimation
|
|
119
125
|
|
|
126
|
+
@get:DoNotStrip
|
|
127
|
+
@get:Keep
|
|
128
|
+
@set:DoNotStrip
|
|
129
|
+
@set:Keep
|
|
130
|
+
abstract var pullToRefreshEnabled: Boolean
|
|
131
|
+
|
|
132
|
+
@get:DoNotStrip
|
|
133
|
+
@get:Keep
|
|
134
|
+
@set:DoNotStrip
|
|
135
|
+
@set:Keep
|
|
136
|
+
abstract var refreshing: Boolean?
|
|
137
|
+
|
|
138
|
+
@get:DoNotStrip
|
|
139
|
+
@get:Keep
|
|
140
|
+
@set:DoNotStrip
|
|
141
|
+
@set:Keep
|
|
142
|
+
abstract var refreshIndicatorColor: Double?
|
|
143
|
+
|
|
120
144
|
abstract var onPresent: (() -> Unit)?
|
|
121
145
|
|
|
122
146
|
private var onPresent_cxx: Func_void?
|
|
@@ -200,6 +224,34 @@ abstract class HybridNitroModalSpec: HybridView() {
|
|
|
200
224
|
set(value) {
|
|
201
225
|
onContentAreaChange = value?.let { it }
|
|
202
226
|
}
|
|
227
|
+
|
|
228
|
+
abstract var onPullToRefresh: (() -> Unit)?
|
|
229
|
+
|
|
230
|
+
private var onPullToRefresh_cxx: Func_void?
|
|
231
|
+
@Keep
|
|
232
|
+
@DoNotStrip
|
|
233
|
+
get() {
|
|
234
|
+
return onPullToRefresh?.let { Func_void_java(it) }
|
|
235
|
+
}
|
|
236
|
+
@Keep
|
|
237
|
+
@DoNotStrip
|
|
238
|
+
set(value) {
|
|
239
|
+
onPullToRefresh = value?.let { it }
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
abstract var onRestingTopChange: ((top: Double) -> Unit)?
|
|
243
|
+
|
|
244
|
+
private var onRestingTopChange_cxx: Func_void_double?
|
|
245
|
+
@Keep
|
|
246
|
+
@DoNotStrip
|
|
247
|
+
get() {
|
|
248
|
+
return onRestingTopChange?.let { Func_void_double_java(it) }
|
|
249
|
+
}
|
|
250
|
+
@Keep
|
|
251
|
+
@DoNotStrip
|
|
252
|
+
set(value) {
|
|
253
|
+
onRestingTopChange = value?.let { it }
|
|
254
|
+
}
|
|
203
255
|
|
|
204
256
|
// Methods
|
|
205
257
|
@DoNotStrip
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NamedSheetDetent.kt
|
|
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
|
+
package com.margelo.nitro.nitromodal
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "NamedSheetDetent".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class NamedSheetDetent(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
SMALL(0),
|
|
20
|
+
MEDIUM(1),
|
|
21
|
+
LARGE(2),
|
|
22
|
+
FITCONTENT(3);
|
|
23
|
+
|
|
24
|
+
companion object
|
|
25
|
+
}
|
|
@@ -7,19 +7,56 @@
|
|
|
7
7
|
|
|
8
8
|
package com.margelo.nitro.nitromodal
|
|
9
9
|
|
|
10
|
-
import androidx.annotation.Keep
|
|
11
10
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
11
|
|
|
12
|
+
|
|
13
13
|
/**
|
|
14
|
-
* Represents the
|
|
14
|
+
* Represents the TypeScript variant "NamedSheetDetent | Double".
|
|
15
15
|
*/
|
|
16
|
+
@Suppress("ClassName")
|
|
16
17
|
@DoNotStrip
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
sealed class SheetDetent {
|
|
19
|
+
@DoNotStrip
|
|
20
|
+
data class First(@DoNotStrip val value: NamedSheetDetent): SheetDetent()
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
data class Second(@DoNotStrip val value: Double): SheetDetent()
|
|
23
|
+
|
|
24
|
+
inline fun <reified T> asType(): T? {
|
|
25
|
+
return when (this) {
|
|
26
|
+
is First -> (value) as? T
|
|
27
|
+
is Second -> (value) as? T
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
inline fun <reified T> isType(): Boolean {
|
|
31
|
+
return asType<T>() != null
|
|
32
|
+
}
|
|
33
|
+
inline fun <R> match(first: (NamedSheetDetent) -> R, second: (Double) -> R): R {
|
|
34
|
+
return when (this) {
|
|
35
|
+
is First -> first(value)
|
|
36
|
+
is Second -> second(value)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
val isFirst: Boolean
|
|
41
|
+
get() = this is First
|
|
42
|
+
val isSecond: Boolean
|
|
43
|
+
get() = this is Second
|
|
44
|
+
|
|
45
|
+
fun asFirstOrNull(): NamedSheetDetent? {
|
|
46
|
+
val value = (this as? First)?.value ?: return null
|
|
47
|
+
return value
|
|
48
|
+
}
|
|
49
|
+
fun asSecondOrNull(): Double? {
|
|
50
|
+
val value = (this as? Second)?.value ?: return null
|
|
51
|
+
return value
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
companion object {
|
|
55
|
+
@JvmStatic
|
|
56
|
+
@DoNotStrip
|
|
57
|
+
fun create(value: NamedSheetDetent): SheetDetent = First(value)
|
|
58
|
+
@JvmStatic
|
|
59
|
+
@DoNotStrip
|
|
60
|
+
fun create(value: Double): SheetDetent = Second(value)
|
|
61
|
+
}
|
|
25
62
|
}
|
|
@@ -37,6 +37,7 @@ target_sources(
|
|
|
37
37
|
../nitrogen/generated/shared/c++/views/HybridNitroModalComponent.cpp
|
|
38
38
|
# Android-specific Nitrogen C++ sources
|
|
39
39
|
../nitrogen/generated/android/c++/JHybridNitroModalSpec.cpp
|
|
40
|
+
../nitrogen/generated/android/c++/JSheetDetent.cpp
|
|
40
41
|
../nitrogen/generated/android/c++/views/JHybridNitroModalStateUpdater.cpp
|
|
41
42
|
)
|
|
42
43
|
|
|
@@ -14,8 +14,8 @@ namespace margelo::nitro::nitromodal { enum class DismissReason; }
|
|
|
14
14
|
namespace margelo::nitro::nitromodal { class HybridNitroModalSpec; }
|
|
15
15
|
// Forward declaration of `ModalContentArea` to properly resolve imports.
|
|
16
16
|
namespace margelo::nitro::nitromodal { struct ModalContentArea; }
|
|
17
|
-
// Forward declaration of `
|
|
18
|
-
namespace margelo::nitro::nitromodal { enum class
|
|
17
|
+
// Forward declaration of `NamedSheetDetent` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::nitromodal { enum class NamedSheetDetent; }
|
|
19
19
|
|
|
20
20
|
// Forward declarations of Swift defined types
|
|
21
21
|
// Forward declaration of `HybridNitroModalSpec_cxx` to properly resolve imports.
|
|
@@ -25,12 +25,13 @@ namespace NitroModal { class HybridNitroModalSpec_cxx; }
|
|
|
25
25
|
#include "DismissReason.hpp"
|
|
26
26
|
#include "HybridNitroModalSpec.hpp"
|
|
27
27
|
#include "ModalContentArea.hpp"
|
|
28
|
-
#include "
|
|
28
|
+
#include "NamedSheetDetent.hpp"
|
|
29
29
|
#include <NitroModules/Result.hpp>
|
|
30
30
|
#include <exception>
|
|
31
31
|
#include <functional>
|
|
32
32
|
#include <memory>
|
|
33
33
|
#include <optional>
|
|
34
|
+
#include <variant>
|
|
34
35
|
#include <vector>
|
|
35
36
|
|
|
36
37
|
/**
|
|
@@ -39,13 +40,42 @@ namespace NitroModal { class HybridNitroModalSpec_cxx; }
|
|
|
39
40
|
*/
|
|
40
41
|
namespace margelo::nitro::nitromodal::bridge::swift {
|
|
41
42
|
|
|
42
|
-
// pragma MARK: std::
|
|
43
|
+
// pragma MARK: std::variant<NamedSheetDetent, double>
|
|
43
44
|
/**
|
|
44
|
-
*
|
|
45
|
+
* Wrapper struct for `std::variant<NamedSheetDetent, double>`.
|
|
46
|
+
* std::variant cannot be used in Swift because of a Swift bug.
|
|
47
|
+
* Not even specializing it works. So we create a wrapper struct.
|
|
45
48
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
std::
|
|
49
|
+
struct std__variant_NamedSheetDetent__double_ final {
|
|
50
|
+
std::variant<NamedSheetDetent, double> variant;
|
|
51
|
+
std__variant_NamedSheetDetent__double_(std::variant<NamedSheetDetent, double> variant): variant(variant) { }
|
|
52
|
+
operator std::variant<NamedSheetDetent, double>() const noexcept {
|
|
53
|
+
return variant;
|
|
54
|
+
}
|
|
55
|
+
inline size_t index() const noexcept {
|
|
56
|
+
return variant.index();
|
|
57
|
+
}
|
|
58
|
+
inline NamedSheetDetent get_0() const noexcept {
|
|
59
|
+
return std::get<0>(variant);
|
|
60
|
+
}
|
|
61
|
+
inline double get_1() const noexcept {
|
|
62
|
+
return std::get<1>(variant);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
inline std__variant_NamedSheetDetent__double_ create_std__variant_NamedSheetDetent__double_(NamedSheetDetent value) noexcept {
|
|
66
|
+
return std__variant_NamedSheetDetent__double_(value);
|
|
67
|
+
}
|
|
68
|
+
inline std__variant_NamedSheetDetent__double_ create_std__variant_NamedSheetDetent__double_(double value) noexcept {
|
|
69
|
+
return std__variant_NamedSheetDetent__double_(value);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// pragma MARK: std::vector<std::variant<NamedSheetDetent, double>>
|
|
73
|
+
/**
|
|
74
|
+
* Specialized version of `std::vector<std::variant<NamedSheetDetent, double>>`.
|
|
75
|
+
*/
|
|
76
|
+
using std__vector_std__variant_NamedSheetDetent__double__ = std::vector<std::variant<NamedSheetDetent, double>>;
|
|
77
|
+
inline std::vector<std::variant<NamedSheetDetent, double>> create_std__vector_std__variant_NamedSheetDetent__double__(size_t size) noexcept {
|
|
78
|
+
std::vector<std::variant<NamedSheetDetent, double>> vector;
|
|
49
79
|
vector.reserve(size);
|
|
50
80
|
return vector;
|
|
51
81
|
}
|
|
@@ -65,6 +95,21 @@ namespace margelo::nitro::nitromodal::bridge::swift {
|
|
|
65
95
|
return optional.value();
|
|
66
96
|
}
|
|
67
97
|
|
|
98
|
+
// pragma MARK: std::optional<bool>
|
|
99
|
+
/**
|
|
100
|
+
* Specialized version of `std::optional<bool>`.
|
|
101
|
+
*/
|
|
102
|
+
using std__optional_bool_ = std::optional<bool>;
|
|
103
|
+
inline std::optional<bool> create_std__optional_bool_(const bool& value) noexcept {
|
|
104
|
+
return std::optional<bool>(value);
|
|
105
|
+
}
|
|
106
|
+
inline bool has_value_std__optional_bool_(const std::optional<bool>& optional) noexcept {
|
|
107
|
+
return optional.has_value();
|
|
108
|
+
}
|
|
109
|
+
inline bool get_std__optional_bool_(const std::optional<bool>& optional) noexcept {
|
|
110
|
+
return optional.value();
|
|
111
|
+
}
|
|
112
|
+
|
|
68
113
|
// pragma MARK: std::function<void()>
|
|
69
114
|
/**
|
|
70
115
|
* Specialized version of `std::function<void()>`.
|
|
@@ -213,6 +258,21 @@ namespace margelo::nitro::nitromodal::bridge::swift {
|
|
|
213
258
|
return optional.value();
|
|
214
259
|
}
|
|
215
260
|
|
|
261
|
+
// pragma MARK: std::optional<std::function<void(double /* top */)>>
|
|
262
|
+
/**
|
|
263
|
+
* Specialized version of `std::optional<std::function<void(double / * top * /)>>`.
|
|
264
|
+
*/
|
|
265
|
+
using std__optional_std__function_void_double____top______ = std::optional<std::function<void(double /* top */)>>;
|
|
266
|
+
inline std::optional<std::function<void(double /* top */)>> create_std__optional_std__function_void_double____top______(const std::function<void(double /* top */)>& value) noexcept {
|
|
267
|
+
return std::optional<std::function<void(double /* top */)>>(value);
|
|
268
|
+
}
|
|
269
|
+
inline bool has_value_std__optional_std__function_void_double____top______(const std::optional<std::function<void(double /* top */)>>& optional) noexcept {
|
|
270
|
+
return optional.has_value();
|
|
271
|
+
}
|
|
272
|
+
inline std::function<void(double /* top */)> get_std__optional_std__function_void_double____top______(const std::optional<std::function<void(double /* top */)>>& optional) noexcept {
|
|
273
|
+
return optional.value();
|
|
274
|
+
}
|
|
275
|
+
|
|
216
276
|
// pragma MARK: std::shared_ptr<HybridNitroModalSpec>
|
|
217
277
|
/**
|
|
218
278
|
* Specialized version of `std::shared_ptr<HybridNitroModalSpec>`.
|
|
@@ -18,10 +18,10 @@ namespace margelo::nitro::nitromodal { enum class KeyboardBehavior; }
|
|
|
18
18
|
namespace margelo::nitro::nitromodal { struct ModalContentArea; }
|
|
19
19
|
// Forward declaration of `ModalMode` to properly resolve imports.
|
|
20
20
|
namespace margelo::nitro::nitromodal { enum class ModalMode; }
|
|
21
|
+
// Forward declaration of `NamedSheetDetent` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::nitromodal { enum class NamedSheetDetent; }
|
|
21
23
|
// Forward declaration of `PopupAnimation` to properly resolve imports.
|
|
22
24
|
namespace margelo::nitro::nitromodal { enum class PopupAnimation; }
|
|
23
|
-
// Forward declaration of `SheetDetent` to properly resolve imports.
|
|
24
|
-
namespace margelo::nitro::nitromodal { enum class SheetDetent; }
|
|
25
25
|
|
|
26
26
|
// Include C++ defined types
|
|
27
27
|
#include "DismissReason.hpp"
|
|
@@ -29,13 +29,14 @@ namespace margelo::nitro::nitromodal { enum class SheetDetent; }
|
|
|
29
29
|
#include "KeyboardBehavior.hpp"
|
|
30
30
|
#include "ModalContentArea.hpp"
|
|
31
31
|
#include "ModalMode.hpp"
|
|
32
|
+
#include "NamedSheetDetent.hpp"
|
|
32
33
|
#include "PopupAnimation.hpp"
|
|
33
|
-
#include "SheetDetent.hpp"
|
|
34
34
|
#include <NitroModules/Result.hpp>
|
|
35
35
|
#include <exception>
|
|
36
36
|
#include <functional>
|
|
37
37
|
#include <memory>
|
|
38
38
|
#include <optional>
|
|
39
|
+
#include <variant>
|
|
39
40
|
#include <vector>
|
|
40
41
|
|
|
41
42
|
// C++ helpers for Swift
|
|
@@ -14,8 +14,8 @@ namespace NitroModal { class HybridNitroModalSpec_cxx; }
|
|
|
14
14
|
|
|
15
15
|
// Forward declaration of `ModalMode` to properly resolve imports.
|
|
16
16
|
namespace margelo::nitro::nitromodal { enum class ModalMode; }
|
|
17
|
-
// Forward declaration of `
|
|
18
|
-
namespace margelo::nitro::nitromodal { enum class
|
|
17
|
+
// Forward declaration of `NamedSheetDetent` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::nitromodal { enum class NamedSheetDetent; }
|
|
19
19
|
// Forward declaration of `KeyboardBehavior` to properly resolve imports.
|
|
20
20
|
namespace margelo::nitro::nitromodal { enum class KeyboardBehavior; }
|
|
21
21
|
// Forward declaration of `PopupAnimation` to properly resolve imports.
|
|
@@ -26,7 +26,8 @@ namespace margelo::nitro::nitromodal { enum class DismissReason; }
|
|
|
26
26
|
namespace margelo::nitro::nitromodal { struct ModalContentArea; }
|
|
27
27
|
|
|
28
28
|
#include "ModalMode.hpp"
|
|
29
|
-
#include "
|
|
29
|
+
#include "NamedSheetDetent.hpp"
|
|
30
|
+
#include <variant>
|
|
30
31
|
#include <vector>
|
|
31
32
|
#include <optional>
|
|
32
33
|
#include "KeyboardBehavior.hpp"
|
|
@@ -94,11 +95,17 @@ namespace margelo::nitro::nitromodal {
|
|
|
94
95
|
inline void setMode(ModalMode mode) noexcept override {
|
|
95
96
|
_swiftPart.setMode(static_cast<int>(mode));
|
|
96
97
|
}
|
|
97
|
-
inline
|
|
98
|
+
inline bool getIsInline() noexcept override {
|
|
99
|
+
return _swiftPart.isInline();
|
|
100
|
+
}
|
|
101
|
+
inline void setIsInline(bool isInline) noexcept override {
|
|
102
|
+
_swiftPart.setIsInline(std::forward<decltype(isInline)>(isInline));
|
|
103
|
+
}
|
|
104
|
+
inline std::vector<std::variant<NamedSheetDetent, double>> getDetents() noexcept override {
|
|
98
105
|
auto __result = _swiftPart.getDetents();
|
|
99
106
|
return __result;
|
|
100
107
|
}
|
|
101
|
-
inline void setDetents(const std::vector<
|
|
108
|
+
inline void setDetents(const std::vector<std::variant<NamedSheetDetent, double>>& detents) noexcept override {
|
|
102
109
|
_swiftPart.setDetents(detents);
|
|
103
110
|
}
|
|
104
111
|
inline double getInitialDetentIndex() noexcept override {
|
|
@@ -176,6 +183,26 @@ namespace margelo::nitro::nitromodal {
|
|
|
176
183
|
inline void setPopupAnimation(PopupAnimation popupAnimation) noexcept override {
|
|
177
184
|
_swiftPart.setPopupAnimation(static_cast<int>(popupAnimation));
|
|
178
185
|
}
|
|
186
|
+
inline bool getPullToRefreshEnabled() noexcept override {
|
|
187
|
+
return _swiftPart.getPullToRefreshEnabled();
|
|
188
|
+
}
|
|
189
|
+
inline void setPullToRefreshEnabled(bool pullToRefreshEnabled) noexcept override {
|
|
190
|
+
_swiftPart.setPullToRefreshEnabled(std::forward<decltype(pullToRefreshEnabled)>(pullToRefreshEnabled));
|
|
191
|
+
}
|
|
192
|
+
inline std::optional<bool> getRefreshing() noexcept override {
|
|
193
|
+
auto __result = _swiftPart.getRefreshing();
|
|
194
|
+
return __result;
|
|
195
|
+
}
|
|
196
|
+
inline void setRefreshing(std::optional<bool> refreshing) noexcept override {
|
|
197
|
+
_swiftPart.setRefreshing(refreshing);
|
|
198
|
+
}
|
|
199
|
+
inline std::optional<double> getRefreshIndicatorColor() noexcept override {
|
|
200
|
+
auto __result = _swiftPart.getRefreshIndicatorColor();
|
|
201
|
+
return __result;
|
|
202
|
+
}
|
|
203
|
+
inline void setRefreshIndicatorColor(std::optional<double> refreshIndicatorColor) noexcept override {
|
|
204
|
+
_swiftPart.setRefreshIndicatorColor(refreshIndicatorColor);
|
|
205
|
+
}
|
|
179
206
|
inline std::optional<std::function<void()>> getOnPresent() noexcept override {
|
|
180
207
|
auto __result = _swiftPart.getOnPresent();
|
|
181
208
|
return __result;
|
|
@@ -218,6 +245,20 @@ namespace margelo::nitro::nitromodal {
|
|
|
218
245
|
inline void setOnContentAreaChange(const std::optional<std::function<void(const ModalContentArea& /* area */)>>& onContentAreaChange) noexcept override {
|
|
219
246
|
_swiftPart.setOnContentAreaChange(onContentAreaChange);
|
|
220
247
|
}
|
|
248
|
+
inline std::optional<std::function<void()>> getOnPullToRefresh() noexcept override {
|
|
249
|
+
auto __result = _swiftPart.getOnPullToRefresh();
|
|
250
|
+
return __result;
|
|
251
|
+
}
|
|
252
|
+
inline void setOnPullToRefresh(const std::optional<std::function<void()>>& onPullToRefresh) noexcept override {
|
|
253
|
+
_swiftPart.setOnPullToRefresh(onPullToRefresh);
|
|
254
|
+
}
|
|
255
|
+
inline std::optional<std::function<void(double /* top */)>> getOnRestingTopChange() noexcept override {
|
|
256
|
+
auto __result = _swiftPart.getOnRestingTopChange();
|
|
257
|
+
return __result;
|
|
258
|
+
}
|
|
259
|
+
inline void setOnRestingTopChange(const std::optional<std::function<void(double /* top */)>>& onRestingTopChange) noexcept override {
|
|
260
|
+
_swiftPart.setOnRestingTopChange(onRestingTopChange);
|
|
261
|
+
}
|
|
221
262
|
|
|
222
263
|
public:
|
|
223
264
|
// Methods
|
|
@@ -110,6 +110,12 @@ using namespace margelo::nitro::nitromodal::views;
|
|
|
110
110
|
: !newViewProps.mode.hasSameValue(oldViewProps->mode)) {
|
|
111
111
|
swiftPart.setMode(static_cast<int>(newViewProps.mode.get()));
|
|
112
112
|
}
|
|
113
|
+
// isInline: boolean
|
|
114
|
+
if (oldViewProps == nullptr
|
|
115
|
+
? newViewProps.isInline.isProvided()
|
|
116
|
+
: !newViewProps.isInline.hasSameValue(oldViewProps->isInline)) {
|
|
117
|
+
swiftPart.setIsInline(newViewProps.isInline.get());
|
|
118
|
+
}
|
|
113
119
|
// detents: array
|
|
114
120
|
if (oldViewProps == nullptr
|
|
115
121
|
? newViewProps.detents.isProvided()
|
|
@@ -188,6 +194,24 @@ using namespace margelo::nitro::nitromodal::views;
|
|
|
188
194
|
: !newViewProps.popupAnimation.hasSameValue(oldViewProps->popupAnimation)) {
|
|
189
195
|
swiftPart.setPopupAnimation(static_cast<int>(newViewProps.popupAnimation.get()));
|
|
190
196
|
}
|
|
197
|
+
// pullToRefreshEnabled: boolean
|
|
198
|
+
if (oldViewProps == nullptr
|
|
199
|
+
? newViewProps.pullToRefreshEnabled.isProvided()
|
|
200
|
+
: !newViewProps.pullToRefreshEnabled.hasSameValue(oldViewProps->pullToRefreshEnabled)) {
|
|
201
|
+
swiftPart.setPullToRefreshEnabled(newViewProps.pullToRefreshEnabled.get());
|
|
202
|
+
}
|
|
203
|
+
// refreshing: optional
|
|
204
|
+
if (oldViewProps == nullptr
|
|
205
|
+
? newViewProps.refreshing.isProvided()
|
|
206
|
+
: !newViewProps.refreshing.hasSameValue(oldViewProps->refreshing)) {
|
|
207
|
+
swiftPart.setRefreshing(newViewProps.refreshing.get());
|
|
208
|
+
}
|
|
209
|
+
// refreshIndicatorColor: optional
|
|
210
|
+
if (oldViewProps == nullptr
|
|
211
|
+
? newViewProps.refreshIndicatorColor.isProvided()
|
|
212
|
+
: !newViewProps.refreshIndicatorColor.hasSameValue(oldViewProps->refreshIndicatorColor)) {
|
|
213
|
+
swiftPart.setRefreshIndicatorColor(newViewProps.refreshIndicatorColor.get());
|
|
214
|
+
}
|
|
191
215
|
// onPresent: optional
|
|
192
216
|
if (oldViewProps == nullptr
|
|
193
217
|
? newViewProps.onPresent.isProvided()
|
|
@@ -224,6 +248,18 @@ using namespace margelo::nitro::nitromodal::views;
|
|
|
224
248
|
: !newViewProps.onContentAreaChange.hasSameValue(oldViewProps->onContentAreaChange)) {
|
|
225
249
|
swiftPart.setOnContentAreaChange(newViewProps.onContentAreaChange.get());
|
|
226
250
|
}
|
|
251
|
+
// onPullToRefresh: optional
|
|
252
|
+
if (oldViewProps == nullptr
|
|
253
|
+
? newViewProps.onPullToRefresh.isProvided()
|
|
254
|
+
: !newViewProps.onPullToRefresh.hasSameValue(oldViewProps->onPullToRefresh)) {
|
|
255
|
+
swiftPart.setOnPullToRefresh(newViewProps.onPullToRefresh.get());
|
|
256
|
+
}
|
|
257
|
+
// onRestingTopChange: optional
|
|
258
|
+
if (oldViewProps == nullptr
|
|
259
|
+
? newViewProps.onRestingTopChange.isProvided()
|
|
260
|
+
: !newViewProps.onRestingTopChange.hasSameValue(oldViewProps->onRestingTopChange)) {
|
|
261
|
+
swiftPart.setOnRestingTopChange(newViewProps.onRestingTopChange.get());
|
|
262
|
+
}
|
|
227
263
|
|
|
228
264
|
// Update hybridRef if it changed
|
|
229
265
|
if (oldViewProps == nullptr
|
|
@@ -12,6 +12,7 @@ public protocol HybridNitroModalSpec_protocol: HybridObject, HybridView {
|
|
|
12
12
|
// Properties
|
|
13
13
|
var isOpen: Bool { get set }
|
|
14
14
|
var mode: ModalMode { get set }
|
|
15
|
+
var isInline: Bool { get set }
|
|
15
16
|
var detents: [SheetDetent] { get set }
|
|
16
17
|
var initialDetentIndex: Double { get set }
|
|
17
18
|
var backdropColor: Double { get set }
|
|
@@ -25,12 +26,17 @@ public protocol HybridNitroModalSpec_protocol: HybridObject, HybridView {
|
|
|
25
26
|
var contentBackgroundColor: Double? { get set }
|
|
26
27
|
var keyboardBehavior: KeyboardBehavior { get set }
|
|
27
28
|
var popupAnimation: PopupAnimation { get set }
|
|
29
|
+
var pullToRefreshEnabled: Bool { get set }
|
|
30
|
+
var refreshing: Bool? { get set }
|
|
31
|
+
var refreshIndicatorColor: Double? { get set }
|
|
28
32
|
var onPresent: (() -> Void)? { get set }
|
|
29
33
|
var onDismiss: ((_ reason: DismissReason) -> Void)? { get set }
|
|
30
34
|
var onDetentChange: ((_ index: Double) -> Void)? { get set }
|
|
31
35
|
var onBackdropPress: (() -> Void)? { get set }
|
|
32
36
|
var onBackButtonPress: (() -> Void)? { get set }
|
|
33
37
|
var onContentAreaChange: ((_ area: ModalContentArea) -> Void)? { get set }
|
|
38
|
+
var onPullToRefresh: (() -> Void)? { get set }
|
|
39
|
+
var onRestingTopChange: ((_ top: Double) -> Void)? { get set }
|
|
34
40
|
|
|
35
41
|
// Methods
|
|
36
42
|
func present() throws -> Void
|