react-native-ios-translate-sheet 0.0.1
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/IOSTranslateSheet.podspec +43 -0
- package/LICENSE +20 -0
- package/README.md +184 -0
- package/android/build.gradle +111 -0
- package/android/generated/java/com/facebook/react/viewmanagers/IOSTranslateSheetViewManagerDelegate.java +38 -0
- package/android/generated/java/com/facebook/react/viewmanagers/IOSTranslateSheetViewManagerInterface.java +20 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNIOSTranslateSheetViewSpec-generated.cpp +22 -0
- package/android/generated/jni/RNIOSTranslateSheetViewSpec.h +24 -0
- package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/ComponentDescriptors.h +24 -0
- package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/EventEmitters.cpp +24 -0
- package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/EventEmitters.h +25 -0
- package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/Props.cpp +27 -0
- package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/Props.h +29 -0
- package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/RNIOSTranslateSheetViewSpecJSI-generated.cpp +17 -0
- package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/RNIOSTranslateSheetViewSpecJSI.h +19 -0
- package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/ShadowNodes.cpp +17 -0
- package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/ShadowNodes.h +32 -0
- package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/States.h +29 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/iostranslatesheet/IOSTranslateSheetPackage.kt +19 -0
- package/android/src/main/java/com/iostranslatesheet/IOSTranslateSheetView.kt +15 -0
- package/android/src/main/java/com/iostranslatesheet/IOSTranslateSheetViewManager.kt +46 -0
- package/ios/IOSTranslateSheet.swift +26 -0
- package/ios/IOSTranslateSheetProvider.swift +72 -0
- package/ios/IOSTranslateSheetView.h +18 -0
- package/ios/IOSTranslateSheetView.mm +83 -0
- package/ios/IOSTranslateSheetViewManager.mm +25 -0
- package/ios/generated/RNIOSTranslateSheetViewSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/RNIOSTranslateSheetViewSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/RNIOSTranslateSheetViewSpec/EventEmitters.cpp +24 -0
- package/ios/generated/RNIOSTranslateSheetViewSpec/EventEmitters.h +25 -0
- package/ios/generated/RNIOSTranslateSheetViewSpec/Props.cpp +27 -0
- package/ios/generated/RNIOSTranslateSheetViewSpec/Props.h +29 -0
- package/ios/generated/RNIOSTranslateSheetViewSpec/RCTComponentViewHelpers.h +20 -0
- package/ios/generated/RNIOSTranslateSheetViewSpec/RNIOSTranslateSheetViewSpec-generated.mm +16 -0
- package/ios/generated/RNIOSTranslateSheetViewSpec/RNIOSTranslateSheetViewSpec.h +38 -0
- package/ios/generated/RNIOSTranslateSheetViewSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/RNIOSTranslateSheetViewSpec/ShadowNodes.h +32 -0
- package/ios/generated/RNIOSTranslateSheetViewSpec/States.cpp +16 -0
- package/ios/generated/RNIOSTranslateSheetViewSpec/States.h +29 -0
- package/ios/generated/RNIOSTranslateSheetViewSpecJSI-generated.cpp +17 -0
- package/ios/generated/RNIOSTranslateSheetViewSpecJSI.h +19 -0
- package/lib/commonjs/IOSTranslateSheetViewNativeComponent.js +10 -0
- package/lib/commonjs/IOSTranslateSheetViewNativeComponent.js.map +1 -0
- package/lib/commonjs/index.js +41 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/useTranslate.js +42 -0
- package/lib/commonjs/useTranslate.js.map +1 -0
- package/lib/module/IOSTranslateSheetViewNativeComponent.js +5 -0
- package/lib/module/IOSTranslateSheetViewNativeComponent.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/useTranslate.js +37 -0
- package/lib/module/useTranslate.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/IOSTranslateSheetViewNativeComponent.d.ts +11 -0
- package/lib/typescript/commonjs/src/IOSTranslateSheetViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +4 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useTranslate.d.ts +6 -0
- package/lib/typescript/commonjs/src/useTranslate.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/IOSTranslateSheetViewNativeComponent.d.ts +11 -0
- package/lib/typescript/module/src/IOSTranslateSheetViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +4 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/useTranslate.d.ts +6 -0
- package/lib/typescript/module/src/useTranslate.d.ts.map +1 -0
- package/package.json +172 -0
- package/react-native.config.js +12 -0
- package/src/IOSTranslateSheetViewNativeComponent.ts +15 -0
- package/src/index.tsx +3 -0
- package/src/useTranslate.tsx +40 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
} // namespace facebook::react
|
package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/ShadowNodes.cpp
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "ShadowNodes.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
extern const char IOSTranslateSheetViewComponentName[] = "IOSTranslateSheetView";
|
|
16
|
+
|
|
17
|
+
} // namespace facebook::react
|
package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/ShadowNodes.h
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include "EventEmitters.h"
|
|
14
|
+
#include "Props.h"
|
|
15
|
+
#include "States.h"
|
|
16
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
|
+
#include <jsi/jsi.h>
|
|
18
|
+
|
|
19
|
+
namespace facebook::react {
|
|
20
|
+
|
|
21
|
+
JSI_EXPORT extern const char IOSTranslateSheetViewComponentName[];
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* `ShadowNode` for <IOSTranslateSheetView> component.
|
|
25
|
+
*/
|
|
26
|
+
using IOSTranslateSheetViewShadowNode = ConcreteViewShadowNode<
|
|
27
|
+
IOSTranslateSheetViewComponentName,
|
|
28
|
+
IOSTranslateSheetViewProps,
|
|
29
|
+
IOSTranslateSheetViewEventEmitter,
|
|
30
|
+
IOSTranslateSheetViewState>;
|
|
31
|
+
|
|
32
|
+
} // namespace facebook::react
|
package/android/generated/jni/react/renderer/components/RNIOSTranslateSheetViewSpec/States.cpp
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateStateCpp.js
|
|
9
|
+
*/
|
|
10
|
+
#include "States.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateStateH.js
|
|
8
|
+
*/
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#ifdef ANDROID
|
|
12
|
+
#include <folly/dynamic.h>
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
class IOSTranslateSheetViewState {
|
|
18
|
+
public:
|
|
19
|
+
IOSTranslateSheetViewState() = default;
|
|
20
|
+
|
|
21
|
+
#ifdef ANDROID
|
|
22
|
+
IOSTranslateSheetViewState(IOSTranslateSheetViewState const &previousState, folly::dynamic data){};
|
|
23
|
+
folly::dynamic getDynamic() const {
|
|
24
|
+
return {};
|
|
25
|
+
};
|
|
26
|
+
#endif
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.iostranslatesheet
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
import java.util.ArrayList
|
|
8
|
+
|
|
9
|
+
class IOSTranslateSheetViewPackage : ReactPackage {
|
|
10
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
11
|
+
val viewManagers: MutableList<ViewManager<*, *>> = ArrayList()
|
|
12
|
+
viewManagers.add(IOSTranslateSheetViewManager())
|
|
13
|
+
return viewManagers
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
17
|
+
return emptyList()
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package com.iostranslatesheet
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.util.AttributeSet
|
|
5
|
+
import android.view.View
|
|
6
|
+
|
|
7
|
+
class IOSTranslateSheetView : View {
|
|
8
|
+
constructor(context: Context?) : super(context)
|
|
9
|
+
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
|
|
10
|
+
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
|
11
|
+
context,
|
|
12
|
+
attrs,
|
|
13
|
+
defStyleAttr
|
|
14
|
+
)
|
|
15
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
package com.iostranslatesheet
|
|
2
|
+
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
5
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
6
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
7
|
+
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
8
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
9
|
+
import com.facebook.react.viewmanagers.IOSTranslateSheetViewManagerInterface
|
|
10
|
+
import com.facebook.react.viewmanagers.IOSTranslateSheetViewManagerDelegate
|
|
11
|
+
|
|
12
|
+
@ReactModule(name = IOSTranslateSheetViewManager.NAME)
|
|
13
|
+
class IOSTranslateSheetViewManager : SimpleViewManager<IOSTranslateSheetView>(),
|
|
14
|
+
IOSTranslateSheetViewManagerInterface<IOSTranslateSheetView> {
|
|
15
|
+
private val mDelegate: ViewManagerDelegate<IOSTranslateSheetView>
|
|
16
|
+
|
|
17
|
+
init {
|
|
18
|
+
mDelegate = IOSTranslateSheetViewManagerDelegate(this)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override fun getDelegate(): ViewManagerDelegate<IOSTranslateSheetView>? {
|
|
22
|
+
return mDelegate
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override fun getName(): String {
|
|
26
|
+
return NAME
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public override fun createViewInstance(context: ThemedReactContext): IOSTranslateSheetView {
|
|
30
|
+
return IOSTranslateSheetView(context)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@ReactProp(name = "text")
|
|
34
|
+
override fun setText(view: IOSTranslateSheetView, text: String?) {
|
|
35
|
+
// No-op implementation since this is iOS-only
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@ReactProp(name = "isPresented")
|
|
39
|
+
override fun setIsPresented(view: IOSTranslateSheetView, isPresented: Boolean) {
|
|
40
|
+
// No-op implementation since this is iOS-only
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
companion object {
|
|
44
|
+
const val NAME = "IOSTranslateSheetView"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import SwiftUI
|
|
2
|
+
import Translation
|
|
3
|
+
|
|
4
|
+
class Props: ObservableObject {
|
|
5
|
+
@Published var text: String = ""
|
|
6
|
+
@Published var isPresented: Bool = false
|
|
7
|
+
@Published var onHide: () -> Void = {}
|
|
8
|
+
@Published var opacity: Double = 0.0
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
struct IOSTranslateSheet: View {
|
|
12
|
+
@ObservedObject var props: Props
|
|
13
|
+
|
|
14
|
+
var body: some View {
|
|
15
|
+
if #available(iOS 17.4, *) {
|
|
16
|
+
Color.clear
|
|
17
|
+
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
18
|
+
.translationPresentation(isPresented: $props.isPresented, text: props.text)
|
|
19
|
+
.onChange(of: props.isPresented) { oldValue, newValue in
|
|
20
|
+
if oldValue == true && newValue == false {
|
|
21
|
+
props.onHide()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
import React
|
|
3
|
+
import SwiftUI
|
|
4
|
+
|
|
5
|
+
@objc public class IOSTranslateSheetProvider: UIView {
|
|
6
|
+
private var props = Props()
|
|
7
|
+
private var hostingController: UIHostingController<IOSTranslateSheet>?
|
|
8
|
+
|
|
9
|
+
@objc public var text: String = "" {
|
|
10
|
+
didSet {
|
|
11
|
+
props.text = text
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@objc public var isPresented: Bool = false {
|
|
16
|
+
didSet {
|
|
17
|
+
props.isPresented = isPresented
|
|
18
|
+
hostingController?.view.isHidden = !isPresented
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@objc public var opacity: Double = 0.0 {
|
|
23
|
+
didSet {
|
|
24
|
+
props.opacity = opacity
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@objc public var onHideCallback: (() -> Void)?
|
|
29
|
+
|
|
30
|
+
public override func layoutSubviews() {
|
|
31
|
+
super.layoutSubviews()
|
|
32
|
+
setupView()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private func setupView() {
|
|
36
|
+
if self.hostingController != nil {
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
props.onHide = { [weak self] in
|
|
41
|
+
self?.onHideCallback?()
|
|
42
|
+
self?.hostingController?.view.isHidden = true
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
self.hostingController = UIHostingController(
|
|
46
|
+
rootView: IOSTranslateSheet(
|
|
47
|
+
props: props
|
|
48
|
+
)
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
if let hostingController = self.hostingController {
|
|
52
|
+
hostingController.view.isHidden = !isPresented
|
|
53
|
+
hostingController.view.backgroundColor = UIColor(white: 0.0, alpha: opacity)
|
|
54
|
+
|
|
55
|
+
addSubview(hostingController.view)
|
|
56
|
+
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
|
|
57
|
+
hostingController.view.pinEdges(to: self)
|
|
58
|
+
reactAddController(toClosestParent: hostingController)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
extension UIView {
|
|
64
|
+
func pinEdges(to other: UIView) {
|
|
65
|
+
NSLayoutConstraint.activate([
|
|
66
|
+
leadingAnchor.constraint(equalTo: other.leadingAnchor),
|
|
67
|
+
trailingAnchor.constraint(equalTo: other.trailingAnchor),
|
|
68
|
+
topAnchor.constraint(equalTo: other.topAnchor),
|
|
69
|
+
bottomAnchor.constraint(equalTo: other.bottomAnchor)
|
|
70
|
+
])
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#ifdef __cplusplus
|
|
2
|
+
|
|
3
|
+
#import <React/RCTViewComponentView.h>
|
|
4
|
+
#import <UIKit/UIKit.h>
|
|
5
|
+
|
|
6
|
+
#ifndef IOSTranslateSheetViewNativeComponent_h
|
|
7
|
+
#define IOSTranslateSheetViewNativeComponent_h
|
|
8
|
+
|
|
9
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
10
|
+
|
|
11
|
+
@interface IOSTranslateSheetView : RCTViewComponentView
|
|
12
|
+
@end
|
|
13
|
+
|
|
14
|
+
NS_ASSUME_NONNULL_END
|
|
15
|
+
|
|
16
|
+
#endif /* IOSTranslateSheetViewNativeComponent_h */
|
|
17
|
+
|
|
18
|
+
#endif /* __cplusplus */
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#import "IOSTranslateSheetView.h"
|
|
2
|
+
|
|
3
|
+
#import "generated/RNIOSTranslateSheetViewSpec/ComponentDescriptors.h"
|
|
4
|
+
#import "generated/RNIOSTranslateSheetViewSpec/EventEmitters.h"
|
|
5
|
+
#import "generated/RNIOSTranslateSheetViewSpec/Props.h"
|
|
6
|
+
#import "generated/RNIOSTranslateSheetViewSpec/RCTComponentViewHelpers.h"
|
|
7
|
+
|
|
8
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
9
|
+
|
|
10
|
+
#if __has_include("IOSTranslateSheet/IOSTranslateSheet-Swift.h")
|
|
11
|
+
#import "IOSTranslateSheet/IOSTranslateSheet-Swift.h"
|
|
12
|
+
#else
|
|
13
|
+
#import "IOSTranslateSheet-Swift.h"
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
using namespace facebook::react;
|
|
17
|
+
|
|
18
|
+
@interface IOSTranslateSheetView () <RCTIOSTranslateSheetViewViewProtocol>
|
|
19
|
+
|
|
20
|
+
@end
|
|
21
|
+
|
|
22
|
+
@implementation IOSTranslateSheetView {
|
|
23
|
+
IOSTranslateSheetProvider * _view;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
27
|
+
{
|
|
28
|
+
return concreteComponentDescriptorProvider<IOSTranslateSheetViewComponentDescriptor>();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
32
|
+
{
|
|
33
|
+
if (self = [super initWithFrame:frame]) {
|
|
34
|
+
static const auto defaultProps = std::make_shared<const IOSTranslateSheetViewProps>();
|
|
35
|
+
_props = defaultProps;
|
|
36
|
+
|
|
37
|
+
_view = [[IOSTranslateSheetProvider alloc] init];
|
|
38
|
+
|
|
39
|
+
__weak __typeof(self) weakSelf = self;
|
|
40
|
+
_view.onHideCallback = ^{
|
|
41
|
+
__strong __typeof(weakSelf) strongSelf = weakSelf;
|
|
42
|
+
if (strongSelf) {
|
|
43
|
+
// Emit the onHide event
|
|
44
|
+
if (strongSelf->_eventEmitter) {
|
|
45
|
+
std::dynamic_pointer_cast<const IOSTranslateSheetViewEventEmitter>(strongSelf->_eventEmitter)
|
|
46
|
+
->onHide({});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
self.contentView = _view;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return self;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
58
|
+
{
|
|
59
|
+
const auto &oldViewProps = *std::static_pointer_cast<IOSTranslateSheetViewProps const>(_props);
|
|
60
|
+
const auto &newViewProps = *std::static_pointer_cast<IOSTranslateSheetViewProps const>(props);
|
|
61
|
+
|
|
62
|
+
if (oldViewProps.text != newViewProps.text) {
|
|
63
|
+
NSString *text = [[NSString alloc] initWithUTF8String: newViewProps.text.c_str()];
|
|
64
|
+
[_view setText:text];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (oldViewProps.isPresented != newViewProps.isPresented) {
|
|
68
|
+
[_view setIsPresented:newViewProps.isPresented];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (oldViewProps.opacity != newViewProps.opacity) {
|
|
72
|
+
[_view setOpacity:newViewProps.opacity];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
[super updateProps:props oldProps:oldProps];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
Class<RCTComponentViewProtocol> IOSTranslateSheetViewCls(void)
|
|
79
|
+
{
|
|
80
|
+
return IOSTranslateSheetView.class;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#import <React/RCTViewManager.h>
|
|
2
|
+
#import <React/RCTUIManager.h>
|
|
3
|
+
#import "RCTBridge.h"
|
|
4
|
+
|
|
5
|
+
#if __has_include("IOSTranslateSheet/IOSTranslateSheet-Swift.h")
|
|
6
|
+
#import "IOSTranslateSheet/IOSTranslateSheet-Swift.h"
|
|
7
|
+
#else
|
|
8
|
+
#import "IOSTranslateSheet-Swift.h"
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
@interface IOSTranslateSheetViewManager : RCTViewManager
|
|
12
|
+
@end
|
|
13
|
+
|
|
14
|
+
@implementation IOSTranslateSheetViewManager
|
|
15
|
+
|
|
16
|
+
RCT_EXPORT_MODULE(IOSTranslateSheetView)
|
|
17
|
+
|
|
18
|
+
- (IOSTranslateSheetProvider *)view
|
|
19
|
+
{
|
|
20
|
+
return [[IOSTranslateSheetProvider alloc] init];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
RCT_EXPORT_VIEW_PROPERTY(color, NSString)
|
|
24
|
+
|
|
25
|
+
@end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateComponentDescriptorCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "ComponentDescriptors.h"
|
|
12
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
13
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
void RNIOSTranslateSheetViewSpec_registerComponentDescriptorsFromCodegen(
|
|
18
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
|
|
19
|
+
registry->add(concreteComponentDescriptorProvider<IOSTranslateSheetViewComponentDescriptor>());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateComponentDescriptorH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include "ShadowNodes.h"
|
|
14
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
using IOSTranslateSheetViewComponentDescriptor = ConcreteComponentDescriptor<IOSTranslateSheetViewShadowNode>;
|
|
20
|
+
|
|
21
|
+
void RNIOSTranslateSheetViewSpec_registerComponentDescriptorsFromCodegen(
|
|
22
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
|
|
23
|
+
|
|
24
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "EventEmitters.h"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
namespace facebook::react {
|
|
15
|
+
|
|
16
|
+
void IOSTranslateSheetViewEventEmitter::onHide(OnHide $event) const {
|
|
17
|
+
dispatchEvent("hide", [](jsi::Runtime &runtime) {
|
|
18
|
+
auto $payload = jsi::Object(runtime);
|
|
19
|
+
|
|
20
|
+
return $payload;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterH.js
|
|
9
|
+
*/
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
class IOSTranslateSheetViewEventEmitter : public ViewEventEmitter {
|
|
17
|
+
public:
|
|
18
|
+
using ViewEventEmitter::ViewEventEmitter;
|
|
19
|
+
|
|
20
|
+
struct OnHide {
|
|
21
|
+
|
|
22
|
+
};
|
|
23
|
+
void onHide(OnHide value) const;
|
|
24
|
+
};
|
|
25
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GeneratePropsCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "Props.h"
|
|
12
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
13
|
+
#include <react/renderer/core/propsConversions.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
IOSTranslateSheetViewProps::IOSTranslateSheetViewProps(
|
|
18
|
+
const PropsParserContext &context,
|
|
19
|
+
const IOSTranslateSheetViewProps &sourceProps,
|
|
20
|
+
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
|
|
21
|
+
|
|
22
|
+
text(convertRawProp(context, rawProps, "text", sourceProps.text, {})),
|
|
23
|
+
isPresented(convertRawProp(context, rawProps, "isPresented", sourceProps.isPresented, {false})),
|
|
24
|
+
opacity(convertRawProp(context, rawProps, "opacity", sourceProps.opacity, {0.0}))
|
|
25
|
+
{}
|
|
26
|
+
|
|
27
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GeneratePropsH.js
|
|
9
|
+
*/
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
13
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
class IOSTranslateSheetViewProps final : public ViewProps {
|
|
18
|
+
public:
|
|
19
|
+
IOSTranslateSheetViewProps() = default;
|
|
20
|
+
IOSTranslateSheetViewProps(const PropsParserContext& context, const IOSTranslateSheetViewProps &sourceProps, const RawProps &rawProps);
|
|
21
|
+
|
|
22
|
+
#pragma mark - Props
|
|
23
|
+
|
|
24
|
+
std::string text{};
|
|
25
|
+
bool isPresented{false};
|
|
26
|
+
Float opacity{0.0};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateComponentHObjCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#import <Foundation/Foundation.h>
|
|
11
|
+
#import <React/RCTDefines.h>
|
|
12
|
+
#import <React/RCTLog.h>
|
|
13
|
+
|
|
14
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
15
|
+
|
|
16
|
+
@protocol RCTIOSTranslateSheetViewViewProtocol <NSObject>
|
|
17
|
+
|
|
18
|
+
@end
|
|
19
|
+
|
|
20
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleObjCpp
|
|
8
|
+
*
|
|
9
|
+
* We create an umbrella header (and corresponding implementation) here since
|
|
10
|
+
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
|
|
11
|
+
* must have a single output. More files => more genrule()s => slower builds.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#import "RNIOSTranslateSheetViewSpec.h"
|
|
15
|
+
|
|
16
|
+
|