[iOS] Create public space #143

- Update after design review
This commit is contained in:
Gil Eluard
2021-12-13 14:43:05 +01:00
parent 61790052a9
commit 812f589543
8 changed files with 151 additions and 84 deletions
@@ -20,22 +20,37 @@ import SwiftUI
@available(iOS 14.0, *)
struct ThemableTextEditor: UIViewRepresentable {
@Environment(\.theme) private var theme: ThemeSwiftUI
// MARK: Properties
@Binding var text: String
@State var configuration: UIKitTextInputConfiguration = UIKitTextInputConfiguration()
var onEditingChanged: ((_ edit: Bool) -> Void)?
private let textView: UITextView = UITextView()
private let nextButton: UIButton = UIButton(type: .custom)
private let internalParams = InternalParams()
// MARK: Private
@Environment(\.theme) private var theme: ThemeSwiftUI
private let textView: UITextView = UITextView()
private let internalParams = InternalParams()
// MARK: Setup
init(text: Binding<String>,
configuration: UIKitTextInputConfiguration = UIKitTextInputConfiguration(),
onEditingChanged: ((_ edit: Bool) -> Void)? = nil) {
self._text = text
self._configuration = State(initialValue: configuration)
self.onEditingChanged = onEditingChanged
ResponderManager.register(view: textView)
}
// MARK: UIViewRepresentable
func makeUIView(context: Context) -> UITextView {
textView.delegate = context.coordinator
textView.text = text
ResponderManager.register(view: textView)
if internalParams.isFirstResponder {
textView.becomeFirstResponder()
}