Native translation expo module (#4098)
* translation expo module * add `onClose` and `onReplacementAction` * rm onReplacementAction * make all props published * make translation api available globally w/o wrapper (#4110) * conditionally import the translation module * only use native translation if language is probably supported * open native translation via dropdown menu --------- Co-authored-by: Hailey <me@haileyok.com> Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
This commit is contained in:
parent
a60f9933d8
commit
b59c8e22af
14 changed files with 232 additions and 8 deletions
31
modules/expo-bluesky-translate/ios/TranslateView.swift
Normal file
31
modules/expo-bluesky-translate/ios/TranslateView.swift
Normal file
|
@ -0,0 +1,31 @@
|
|||
import SwiftUI
|
||||
// conditionally import the Translation module
|
||||
#if canImport(Translation)
|
||||
import Translation
|
||||
#endif
|
||||
|
||||
struct TranslateView: View {
|
||||
@ObservedObject var state = TranslateViewState.shared
|
||||
|
||||
var body: some View {
|
||||
if #available(iOS 17.4, *) {
|
||||
VStack {
|
||||
UIViewRepresentableWrapper(view: UIView(frame: .zero))
|
||||
}
|
||||
.translationPresentation(
|
||||
isPresented: $state.isPresented,
|
||||
text: state.text
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct UIViewRepresentableWrapper: UIViewRepresentable {
|
||||
let view: UIView
|
||||
|
||||
func makeUIView(context: Context) -> UIView {
|
||||
return view
|
||||
}
|
||||
|
||||
func updateUIView(_ uiView: UIView, context: Context) {}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue