[ad_1]
This can be a view which comprises ‘knowledge’ variable which is handed to trignext AppIntent.
Kindly assist me move it to AppIntent and replace its worth with the info coming from methodology channel.
import SwiftUI
struct widget_testEntryView: View {
@State var knowledge: String = "Leja Re"
var entry: Supplier.Entry
var physique: some View {
ZStack {
Coloration(UIColor(pink: 0x73, inexperienced: 0x46, blue: 0x56))
VStack(alignment: .main) {
Spacer().body(top: 40)
HStack {
Spacer().body(width: 20)
Picture("Picture")
.resizable()
.body(width: 60, top: 60)
.cornerRadius(10)
VStack {
HStack {
Spacer()
Picture(systemName: "backward.finish.fill")
.foregroundColor(.white)
.body(width: 20, top: 20)
Spacer().body(width: 20)
}
Spacer()
}
}
HStack {
Spacer().body(width: 20)
VStack {
Spacer().body(width: 0, top: 2)
Textual content(knowledge)
.font(.system(dimension: 15))
.foregroundColor(.white)
Spacer().body(width: 0, top: 2)
Textual content("Dhvani")
.font(.system(dimension: 15))
.foregroundColor(.grey)
Spacer().body(width: 0, top: 5)
}
}
HStack {
Spacer().body(width: 25)
Button(motion: {
// Deal with Earlier button motion
}) {
Label("Earlier", systemImage: "backward.fill")
.padding()
.foregroundColor(.white)
.body(width: 10, top: 10)
}
Spacer()
Button(motion: {
// Deal with Pause button motion
}) {
Label("Pause", systemImage: "pause.fill")
.padding()
.foregroundColor(.white)
.body(width: 10, top: 10)
}
Spacer()
Button(motion: {
handleNext()
}) {
Label("Subsequent", systemImage: "ahead.fill")
.padding()
.foregroundColor(.white)
.body(width: 10, top: 10)
}
Spacer().body(width: 25)
}
Spacer().body(top: 20)
}
}
}
func handleNext() {
Job {
do {
let end result = strive await trignext(knowledge: $knowledge).carry out()
} catch {
print("Error dealing with subsequent: (error)")
}
}
}
}
That is the AppIntent which updates the worth of information variable, right here its giving error when @binding is used, it doesn’t permit to move the info variable.
import Intents
struct trignext: AppIntent {
static var title: LocalizedStringResource = "Subsequent Music"
static var description = IntentDescription("Orders a soup out of your favourite restaurant.")
@Binding var knowledge: String
init(knowledge: Binding<String>) {
_data = knowledge
}
func carry out() async throws -> some IntentResult {
let updatedData = strive await NativeMethodChannel.triggerNext()
DispatchQueue.primary.async {
knowledge = updatedData ?? "Default Information"
}
return .end result(worth: knowledge)
}
}
That is the AppIntent which updates the worth of information variable, right here its giving error when @binding is used, it doesn’t permit to move the info variable.
[ad_2]