Answer the question
In order to leave comments, you need to log in
What type will the function have?
Hello! Can you please tell me how to put these two essentially identical closures into a separate function? What type will this function have?
import Combine
import SwiftUI
struct TransitionRow: View {
@Binding var transition: Transition
var body: some View {
HStack {
TextField("Symbol", text: $transition.currentSymbol)
.onReceive(Just(transition.currentSymbol)) {
var newValue = ""
if let char = $0.last {
newValue = String(char)
}
if self.transition.currentSymbol != newValue {
self.transition.currentSymbol = newValue
}
}
Text("->")
TextField("Symbol", text: self.$transition.writeSymbol)
.onReceive(Just(transition.writeSymbol)) {
var newValue = ""
if let last = $0.last {
newValue = String(last)
}
if self.transition.writeSymbol != newValue {
self.transition.writeSymbol = newValue
}
}
}
.textFieldStyle(RoundedBorderTextFieldStyle())
.multilineTextAlignment(.center)
}
}
Answer the question
In order to leave comments, you need to log in
This is a structure, type "TransitionRow", the successor of "View" is not a function and not a class, it will return only its value.
Personally, I would recommend Wordpress. Although you have to finish it here, but it’s not difficult, you just need to install a couple of plugins (I won’t tell you which ones, but I used to look for them myself, there are a lot of them), I can name an abundant number of free templates from the pluses, and the ease of creating your own, expandable functionality due to plugins .
And I would advise LiveStreet CMC. This is a free engine, built on the principle of the MVC model, it helps to easily change the appearance.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question