react-native-nitro-simple-toast 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/NitroSimpleToast.podspec +30 -0
- package/README.md +81 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +118 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/nitrosimpletoast/NitroSimpleToast.kt +66 -0
- package/android/src/main/java/com/margelo/nitro/nitrosimpletoast/NitroSimpleToastPackage.kt +26 -0
- package/ios/NitroSimpleToast.swift +60 -0
- package/lib/module/NitroSimpleToast.nitro.js +4 -0
- package/lib/module/NitroSimpleToast.nitro.js.map +1 -0
- package/lib/module/index.js +8 -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/NitroSimpleToast.nitro.d.ts +33 -0
- package/lib/typescript/src/NitroSimpleToast.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/android/c++/JHybridNitroSimpleToastSpec.cpp +68 -0
- package/nitrogen/generated/android/c++/JHybridNitroSimpleToastSpec.hpp +63 -0
- package/nitrogen/generated/android/c++/JToastFrom.hpp +58 -0
- package/nitrogen/generated/android/c++/JToastHaptic.hpp +64 -0
- package/nitrogen/generated/android/c++/JToastOptions.hpp +88 -0
- package/nitrogen/generated/android/c++/JToastPreset.hpp +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosimpletoast/HybridNitroSimpleToastSpec.kt +54 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosimpletoast/ToastFrom.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosimpletoast/ToastHaptic.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosimpletoast/ToastOptions.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosimpletoast/ToastPreset.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosimpletoast/nitrosimpletoastOnLoad.kt +35 -0
- package/nitrogen/generated/android/nitrosimpletoast+autolinking.cmake +81 -0
- package/nitrogen/generated/android/nitrosimpletoast+autolinking.gradle +27 -0
- package/nitrogen/generated/android/nitrosimpletoastOnLoad.cpp +54 -0
- package/nitrogen/generated/android/nitrosimpletoastOnLoad.hpp +34 -0
- package/nitrogen/generated/ios/NitroSimpleToast+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroSimpleToast-Swift-Cxx-Bridge.cpp +33 -0
- package/nitrogen/generated/ios/NitroSimpleToast-Swift-Cxx-Bridge.hpp +152 -0
- package/nitrogen/generated/ios/NitroSimpleToast-Swift-Cxx-Umbrella.hpp +57 -0
- package/nitrogen/generated/ios/NitroSimpleToastAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroSimpleToastAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridNitroSimpleToastSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroSimpleToastSpecSwift.hpp +92 -0
- package/nitrogen/generated/ios/swift/HybridNitroSimpleToastSpec.swift +55 -0
- package/nitrogen/generated/ios/swift/HybridNitroSimpleToastSpec_cxx.swift +137 -0
- package/nitrogen/generated/ios/swift/ToastFrom.swift +40 -0
- package/nitrogen/generated/ios/swift/ToastHaptic.swift +48 -0
- package/nitrogen/generated/ios/swift/ToastOptions.swift +116 -0
- package/nitrogen/generated/ios/swift/ToastPreset.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridNitroSimpleToastSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridNitroSimpleToastSpec.hpp +63 -0
- package/nitrogen/generated/shared/c++/ToastFrom.hpp +76 -0
- package/nitrogen/generated/shared/c++/ToastHaptic.hpp +84 -0
- package/nitrogen/generated/shared/c++/ToastOptions.hpp +116 -0
- package/nitrogen/generated/shared/c++/ToastPreset.hpp +80 -0
- package/package.json +174 -0
- package/src/NitroSimpleToast.nitro.ts +35 -0
- package/src/index.tsx +16 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JToastFrom.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 <fbjni/fbjni.h>
|
|
11
|
+
#include "ToastFrom.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nitrosimpletoast {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "ToastFrom" and the the Kotlin enum "ToastFrom".
|
|
19
|
+
*/
|
|
20
|
+
struct JToastFrom final: public jni::JavaClass<JToastFrom> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrosimpletoast/ToastFrom;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum ToastFrom.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
ToastFrom toCpp() const {
|
|
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<ToastFrom>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JToastFrom> fromCpp(ToastFrom value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case ToastFrom::TOP:
|
|
46
|
+
static const auto fieldTOP = clazz->getStaticField<JToastFrom>("TOP");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldTOP);
|
|
48
|
+
case ToastFrom::BOTTOM:
|
|
49
|
+
static const auto fieldBOTTOM = clazz->getStaticField<JToastFrom>("BOTTOM");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldBOTTOM);
|
|
51
|
+
default:
|
|
52
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
53
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::nitrosimpletoast
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JToastHaptic.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 <fbjni/fbjni.h>
|
|
11
|
+
#include "ToastHaptic.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nitrosimpletoast {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "ToastHaptic" and the the Kotlin enum "ToastHaptic".
|
|
19
|
+
*/
|
|
20
|
+
struct JToastHaptic final: public jni::JavaClass<JToastHaptic> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrosimpletoast/ToastHaptic;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum ToastHaptic.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
ToastHaptic toCpp() const {
|
|
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<ToastHaptic>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JToastHaptic> fromCpp(ToastHaptic value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case ToastHaptic::ERROR:
|
|
46
|
+
static const auto fieldERROR = clazz->getStaticField<JToastHaptic>("ERROR");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldERROR);
|
|
48
|
+
case ToastHaptic::NONE:
|
|
49
|
+
static const auto fieldNONE = clazz->getStaticField<JToastHaptic>("NONE");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldNONE);
|
|
51
|
+
case ToastHaptic::SUCCESS:
|
|
52
|
+
static const auto fieldSUCCESS = clazz->getStaticField<JToastHaptic>("SUCCESS");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldSUCCESS);
|
|
54
|
+
case ToastHaptic::WARNING:
|
|
55
|
+
static const auto fieldWARNING = clazz->getStaticField<JToastHaptic>("WARNING");
|
|
56
|
+
return clazz->getStaticFieldValue(fieldWARNING);
|
|
57
|
+
default:
|
|
58
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
59
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
} // namespace margelo::nitro::nitrosimpletoast
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JToastOptions.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 <fbjni/fbjni.h>
|
|
11
|
+
#include "ToastOptions.hpp"
|
|
12
|
+
|
|
13
|
+
#include "JToastFrom.hpp"
|
|
14
|
+
#include "JToastHaptic.hpp"
|
|
15
|
+
#include "JToastPreset.hpp"
|
|
16
|
+
#include "ToastFrom.hpp"
|
|
17
|
+
#include "ToastHaptic.hpp"
|
|
18
|
+
#include "ToastPreset.hpp"
|
|
19
|
+
#include <optional>
|
|
20
|
+
#include <string>
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::nitrosimpletoast {
|
|
23
|
+
|
|
24
|
+
using namespace facebook;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The C++ JNI bridge between the C++ struct "ToastOptions" and the the Kotlin data class "ToastOptions".
|
|
28
|
+
*/
|
|
29
|
+
struct JToastOptions final: public jni::JavaClass<JToastOptions> {
|
|
30
|
+
public:
|
|
31
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrosimpletoast/ToastOptions;";
|
|
32
|
+
|
|
33
|
+
public:
|
|
34
|
+
/**
|
|
35
|
+
* Convert this Java/Kotlin-based struct to the C++ struct ToastOptions by copying all values to C++.
|
|
36
|
+
*/
|
|
37
|
+
[[maybe_unused]]
|
|
38
|
+
[[nodiscard]]
|
|
39
|
+
ToastOptions toCpp() const {
|
|
40
|
+
static const auto clazz = javaClassStatic();
|
|
41
|
+
static const auto fieldTitle = clazz->getField<jni::JString>("title");
|
|
42
|
+
jni::local_ref<jni::JString> title = this->getFieldValue(fieldTitle);
|
|
43
|
+
static const auto fieldMessage = clazz->getField<jni::JString>("message");
|
|
44
|
+
jni::local_ref<jni::JString> message = this->getFieldValue(fieldMessage);
|
|
45
|
+
static const auto fieldPreset = clazz->getField<JToastPreset>("preset");
|
|
46
|
+
jni::local_ref<JToastPreset> preset = this->getFieldValue(fieldPreset);
|
|
47
|
+
static const auto fieldDuration = clazz->getField<jni::JDouble>("duration");
|
|
48
|
+
jni::local_ref<jni::JDouble> duration = this->getFieldValue(fieldDuration);
|
|
49
|
+
static const auto fieldHaptic = clazz->getField<JToastHaptic>("haptic");
|
|
50
|
+
jni::local_ref<JToastHaptic> haptic = this->getFieldValue(fieldHaptic);
|
|
51
|
+
static const auto fieldShouldDismissByDrag = clazz->getField<jni::JBoolean>("shouldDismissByDrag");
|
|
52
|
+
jni::local_ref<jni::JBoolean> shouldDismissByDrag = this->getFieldValue(fieldShouldDismissByDrag);
|
|
53
|
+
static const auto fieldFrom = clazz->getField<JToastFrom>("from");
|
|
54
|
+
jni::local_ref<JToastFrom> from = this->getFieldValue(fieldFrom);
|
|
55
|
+
return ToastOptions(
|
|
56
|
+
title->toStdString(),
|
|
57
|
+
message != nullptr ? std::make_optional(message->toStdString()) : std::nullopt,
|
|
58
|
+
preset != nullptr ? std::make_optional(preset->toCpp()) : std::nullopt,
|
|
59
|
+
duration != nullptr ? std::make_optional(duration->value()) : std::nullopt,
|
|
60
|
+
haptic != nullptr ? std::make_optional(haptic->toCpp()) : std::nullopt,
|
|
61
|
+
shouldDismissByDrag != nullptr ? std::make_optional(static_cast<bool>(shouldDismissByDrag->value())) : std::nullopt,
|
|
62
|
+
from != nullptr ? std::make_optional(from->toCpp()) : std::nullopt
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public:
|
|
67
|
+
/**
|
|
68
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
69
|
+
*/
|
|
70
|
+
[[maybe_unused]]
|
|
71
|
+
static jni::local_ref<JToastOptions::javaobject> fromCpp(const ToastOptions& value) {
|
|
72
|
+
using JSignature = JToastOptions(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<JToastPreset>, jni::alias_ref<jni::JDouble>, jni::alias_ref<JToastHaptic>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<JToastFrom>);
|
|
73
|
+
static const auto clazz = javaClassStatic();
|
|
74
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
75
|
+
return create(
|
|
76
|
+
clazz,
|
|
77
|
+
jni::make_jstring(value.title),
|
|
78
|
+
value.message.has_value() ? jni::make_jstring(value.message.value()) : nullptr,
|
|
79
|
+
value.preset.has_value() ? JToastPreset::fromCpp(value.preset.value()) : nullptr,
|
|
80
|
+
value.duration.has_value() ? jni::JDouble::valueOf(value.duration.value()) : nullptr,
|
|
81
|
+
value.haptic.has_value() ? JToastHaptic::fromCpp(value.haptic.value()) : nullptr,
|
|
82
|
+
value.shouldDismissByDrag.has_value() ? jni::JBoolean::valueOf(value.shouldDismissByDrag.value()) : nullptr,
|
|
83
|
+
value.from.has_value() ? JToastFrom::fromCpp(value.from.value()) : nullptr
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
} // namespace margelo::nitro::nitrosimpletoast
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JToastPreset.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 <fbjni/fbjni.h>
|
|
11
|
+
#include "ToastPreset.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nitrosimpletoast {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "ToastPreset" and the the Kotlin enum "ToastPreset".
|
|
19
|
+
*/
|
|
20
|
+
struct JToastPreset final: public jni::JavaClass<JToastPreset> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrosimpletoast/ToastPreset;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum ToastPreset.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
ToastPreset toCpp() const {
|
|
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<ToastPreset>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JToastPreset> fromCpp(ToastPreset value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case ToastPreset::DONE:
|
|
46
|
+
static const auto fieldDONE = clazz->getStaticField<JToastPreset>("DONE");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldDONE);
|
|
48
|
+
case ToastPreset::ERROR:
|
|
49
|
+
static const auto fieldERROR = clazz->getStaticField<JToastPreset>("ERROR");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldERROR);
|
|
51
|
+
case ToastPreset::NONE:
|
|
52
|
+
static const auto fieldNONE = clazz->getStaticField<JToastPreset>("NONE");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldNONE);
|
|
54
|
+
default:
|
|
55
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
56
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::nitrosimpletoast
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroSimpleToastSpec.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.nitrosimpletoast
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.core.HybridObject
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A Kotlin class representing the NitroSimpleToast HybridObject.
|
|
17
|
+
* Implement this abstract class to create Kotlin-based instances of NitroSimpleToast.
|
|
18
|
+
*/
|
|
19
|
+
@DoNotStrip
|
|
20
|
+
@Keep
|
|
21
|
+
@Suppress(
|
|
22
|
+
"KotlinJniMissingFunction", "unused",
|
|
23
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
24
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
25
|
+
)
|
|
26
|
+
abstract class HybridNitroSimpleToastSpec: HybridObject() {
|
|
27
|
+
// Properties
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// Methods
|
|
31
|
+
@DoNotStrip
|
|
32
|
+
@Keep
|
|
33
|
+
abstract fun show(options: ToastOptions): Unit
|
|
34
|
+
|
|
35
|
+
// Default implementation of `HybridObject.toString()`
|
|
36
|
+
override fun toString(): String {
|
|
37
|
+
return "[HybridObject NitroSimpleToast]"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// C++ backing class
|
|
41
|
+
@DoNotStrip
|
|
42
|
+
@Keep
|
|
43
|
+
protected open class CxxPart(javaPart: HybridNitroSimpleToastSpec): HybridObject.CxxPart(javaPart) {
|
|
44
|
+
// C++ JHybridNitroSimpleToastSpec::CxxPart::initHybrid(...)
|
|
45
|
+
external override fun initHybrid(): HybridData
|
|
46
|
+
}
|
|
47
|
+
override fun createCxxPart(): CxxPart {
|
|
48
|
+
return CxxPart(this)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
companion object {
|
|
52
|
+
protected const val TAG = "HybridNitroSimpleToastSpec"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ToastFrom.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.nitrosimpletoast
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "ToastFrom".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class ToastFrom(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
TOP(0),
|
|
20
|
+
BOTTOM(1);
|
|
21
|
+
|
|
22
|
+
companion object
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ToastHaptic.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.nitrosimpletoast
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "ToastHaptic".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class ToastHaptic(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
ERROR(0),
|
|
20
|
+
NONE(1),
|
|
21
|
+
SUCCESS(2),
|
|
22
|
+
WARNING(3);
|
|
23
|
+
|
|
24
|
+
companion object
|
|
25
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ToastOptions.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.nitrosimpletoast
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "ToastOptions".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class ToastOptions(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val title: String,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val message: String?,
|
|
26
|
+
@DoNotStrip
|
|
27
|
+
@Keep
|
|
28
|
+
val preset: ToastPreset?,
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
val duration: Double?,
|
|
32
|
+
@DoNotStrip
|
|
33
|
+
@Keep
|
|
34
|
+
val haptic: ToastHaptic?,
|
|
35
|
+
@DoNotStrip
|
|
36
|
+
@Keep
|
|
37
|
+
val shouldDismissByDrag: Boolean?,
|
|
38
|
+
@DoNotStrip
|
|
39
|
+
@Keep
|
|
40
|
+
val from: ToastFrom?
|
|
41
|
+
) {
|
|
42
|
+
/* primary constructor */
|
|
43
|
+
|
|
44
|
+
companion object {
|
|
45
|
+
/**
|
|
46
|
+
* Constructor called from C++
|
|
47
|
+
*/
|
|
48
|
+
@DoNotStrip
|
|
49
|
+
@Keep
|
|
50
|
+
@Suppress("unused")
|
|
51
|
+
@JvmStatic
|
|
52
|
+
private fun fromCpp(title: String, message: String?, preset: ToastPreset?, duration: Double?, haptic: ToastHaptic?, shouldDismissByDrag: Boolean?, from: ToastFrom?): ToastOptions {
|
|
53
|
+
return ToastOptions(title, message, preset, duration, haptic, shouldDismissByDrag, from)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ToastPreset.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.nitrosimpletoast
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "ToastPreset".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class ToastPreset(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
DONE(0),
|
|
20
|
+
ERROR(1),
|
|
21
|
+
NONE(2);
|
|
22
|
+
|
|
23
|
+
companion object
|
|
24
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// nitrosimpletoastOnLoad.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.nitrosimpletoast
|
|
9
|
+
|
|
10
|
+
import android.util.Log
|
|
11
|
+
|
|
12
|
+
internal class nitrosimpletoastOnLoad {
|
|
13
|
+
companion object {
|
|
14
|
+
private const val TAG = "nitrosimpletoastOnLoad"
|
|
15
|
+
private var didLoad = false
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the native part of "nitrosimpletoast".
|
|
18
|
+
* This method is idempotent and can be called more than once.
|
|
19
|
+
*/
|
|
20
|
+
@JvmStatic
|
|
21
|
+
fun initializeNative() {
|
|
22
|
+
if (didLoad) return
|
|
23
|
+
try {
|
|
24
|
+
Log.i(TAG, "Loading nitrosimpletoast C++ library...")
|
|
25
|
+
System.loadLibrary("nitrosimpletoast")
|
|
26
|
+
Log.i(TAG, "Successfully loaded nitrosimpletoast C++ library!")
|
|
27
|
+
didLoad = true
|
|
28
|
+
} catch (e: Error) {
|
|
29
|
+
Log.e(TAG, "Failed to load nitrosimpletoast C++ library! Is it properly installed and linked? " +
|
|
30
|
+
"Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
|
|
31
|
+
throw e
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#
|
|
2
|
+
# nitrosimpletoast+autolinking.cmake
|
|
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
|
+
# This is a CMake file that adds all files generated by Nitrogen
|
|
9
|
+
# to the current CMake project.
|
|
10
|
+
#
|
|
11
|
+
# To use it, add this to your CMakeLists.txt:
|
|
12
|
+
# ```cmake
|
|
13
|
+
# include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/nitrosimpletoast+autolinking.cmake)
|
|
14
|
+
# ```
|
|
15
|
+
|
|
16
|
+
# Define a flag to check if we are building properly
|
|
17
|
+
add_definitions(-DBUILDING_NITROSIMPLETOAST_WITH_GENERATED_CMAKE_PROJECT)
|
|
18
|
+
|
|
19
|
+
# Enable Raw Props parsing in react-native (for Nitro Views)
|
|
20
|
+
add_definitions(-DRN_SERIALIZABLE_STATE)
|
|
21
|
+
|
|
22
|
+
# Add all headers that were generated by Nitrogen
|
|
23
|
+
include_directories(
|
|
24
|
+
"../nitrogen/generated/shared/c++"
|
|
25
|
+
"../nitrogen/generated/android/c++"
|
|
26
|
+
"../nitrogen/generated/android/"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Add all .cpp sources that were generated by Nitrogen
|
|
30
|
+
target_sources(
|
|
31
|
+
# CMake project name (Android C++ library name)
|
|
32
|
+
nitrosimpletoast PRIVATE
|
|
33
|
+
# Autolinking Setup
|
|
34
|
+
../nitrogen/generated/android/nitrosimpletoastOnLoad.cpp
|
|
35
|
+
# Shared Nitrogen C++ sources
|
|
36
|
+
../nitrogen/generated/shared/c++/HybridNitroSimpleToastSpec.cpp
|
|
37
|
+
# Android-specific Nitrogen C++ sources
|
|
38
|
+
../nitrogen/generated/android/c++/JHybridNitroSimpleToastSpec.cpp
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
42
|
+
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
|
|
43
|
+
target_compile_definitions(
|
|
44
|
+
nitrosimpletoast PRIVATE
|
|
45
|
+
-DFOLLY_NO_CONFIG=1
|
|
46
|
+
-DFOLLY_HAVE_CLOCK_GETTIME=1
|
|
47
|
+
-DFOLLY_USE_LIBCPP=1
|
|
48
|
+
-DFOLLY_CFG_NO_COROUTINES=1
|
|
49
|
+
-DFOLLY_MOBILE=1
|
|
50
|
+
-DFOLLY_HAVE_RECVMMSG=1
|
|
51
|
+
-DFOLLY_HAVE_PTHREAD=1
|
|
52
|
+
# Once we target android-23 above, we can comment
|
|
53
|
+
# the following line. NDK uses GNU style stderror_r() after API 23.
|
|
54
|
+
-DFOLLY_HAVE_XSI_STRERROR_R=1
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Add all libraries required by the generated specs
|
|
58
|
+
find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
|
|
59
|
+
find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
|
|
60
|
+
find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
|
|
61
|
+
|
|
62
|
+
# Link all libraries together
|
|
63
|
+
target_link_libraries(
|
|
64
|
+
nitrosimpletoast
|
|
65
|
+
fbjni::fbjni # <-- Facebook C++ JNI helpers
|
|
66
|
+
ReactAndroid::jsi # <-- RN: JSI
|
|
67
|
+
react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# Link react-native (different prefab between RN 0.75 and RN 0.76)
|
|
71
|
+
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
72
|
+
target_link_libraries(
|
|
73
|
+
nitrosimpletoast
|
|
74
|
+
ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
|
|
75
|
+
)
|
|
76
|
+
else()
|
|
77
|
+
target_link_libraries(
|
|
78
|
+
nitrosimpletoast
|
|
79
|
+
ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
|
|
80
|
+
)
|
|
81
|
+
endif()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// nitrosimpletoast+autolinking.gradle
|
|
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
|
+
/// This is a Gradle file that adds all files generated by Nitrogen
|
|
9
|
+
/// to the current Gradle project.
|
|
10
|
+
///
|
|
11
|
+
/// To use it, add this to your build.gradle:
|
|
12
|
+
/// ```gradle
|
|
13
|
+
/// apply from: '../nitrogen/generated/android/nitrosimpletoast+autolinking.gradle'
|
|
14
|
+
/// ```
|
|
15
|
+
|
|
16
|
+
logger.warn("[NitroModules] 🔥 nitrosimpletoast is boosted by nitro!")
|
|
17
|
+
|
|
18
|
+
android {
|
|
19
|
+
sourceSets {
|
|
20
|
+
main {
|
|
21
|
+
java.srcDirs += [
|
|
22
|
+
// Nitrogen files
|
|
23
|
+
"${project.projectDir}/../nitrogen/generated/android/kotlin"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// nitrosimpletoastOnLoad.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
|
+
#ifndef BUILDING_NITROSIMPLETOAST_WITH_GENERATED_CMAKE_PROJECT
|
|
9
|
+
#error nitrosimpletoastOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#include "nitrosimpletoastOnLoad.hpp"
|
|
13
|
+
|
|
14
|
+
#include <jni.h>
|
|
15
|
+
#include <fbjni/fbjni.h>
|
|
16
|
+
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
|
+
|
|
18
|
+
#include "JHybridNitroSimpleToastSpec.hpp"
|
|
19
|
+
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
20
|
+
|
|
21
|
+
namespace margelo::nitro::nitrosimpletoast {
|
|
22
|
+
|
|
23
|
+
int initialize(JavaVM* vm) {
|
|
24
|
+
return facebook::jni::initialize(vm, []() {
|
|
25
|
+
::margelo::nitro::nitrosimpletoast::registerAllNatives();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
struct JHybridNitroSimpleToastSpecImpl: public jni::JavaClass<JHybridNitroSimpleToastSpecImpl, JHybridNitroSimpleToastSpec::JavaPart> {
|
|
30
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrosimpletoast/NitroSimpleToast;";
|
|
31
|
+
static std::shared_ptr<JHybridNitroSimpleToastSpec> create() {
|
|
32
|
+
static const auto constructorFn = javaClassStatic()->getConstructor<JHybridNitroSimpleToastSpecImpl::javaobject()>();
|
|
33
|
+
jni::local_ref<JHybridNitroSimpleToastSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
34
|
+
return javaPart->getJHybridNitroSimpleToastSpec();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
void registerAllNatives() {
|
|
39
|
+
using namespace margelo::nitro;
|
|
40
|
+
using namespace margelo::nitro::nitrosimpletoast;
|
|
41
|
+
|
|
42
|
+
// Register native JNI methods
|
|
43
|
+
margelo::nitro::nitrosimpletoast::JHybridNitroSimpleToastSpec::CxxPart::registerNatives();
|
|
44
|
+
|
|
45
|
+
// Register Nitro Hybrid Objects
|
|
46
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
47
|
+
"NitroSimpleToast",
|
|
48
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
49
|
+
return JHybridNitroSimpleToastSpecImpl::create();
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
} // namespace margelo::nitro::nitrosimpletoast
|