I have encountered the same issue on my emulator. I have not tried it on my physical device.
If some one has any answer that would be appreciated.
Post
Replies
Boosts
Views
Activity
Same issue here with my mac. I have an older Mac but with 512 SSD and 8 GB ram and still runs too slow.
@OOPer the "currentFrResponse" is an object of struct pasted below:
struct CurrentFrResponse: Codable {
var frId : String?
var clientFrId : String?
var customerRefId : String?
var requestorName : String?
var requestorContactNo : String?
var location : Location?
var building : Building?
var division : Division?
var locationDesc : String?
var faultCategory : Division?
var priority : Division?
var department : Division?
var maintGrp : Division?
var remarks : [String]?
var purchaseOrder : String?
var attendedBy : [AttendedBy]?
}
I have removed some properties from this struct to make it simple.
@OOPer
I don't know what the issue is. If I only change the 'List' to 'ForEach' in the above shown code.... it prints out the remarks but doesn't work for 'List'.
If someone still has an issue... Please check this
https://stackoverflow.com/questions/59270505/how-to-implement-a-list-of-textfields-in-swiftui-without-breaking-deletion
As @rspoon3 mentioned.
canvasView.drawing.strokes.isEmpty
this is working correctly.
In the end i used a ForEach loop for this. I actually wished to create a list of textfields which could be add on the basis of the remarks received from the API call. Also this list needed to be dynamic, i.e, I could add or remove the textfields dynamically by using buttons which is why I wanted to add a list...
Unfortunately I couldn't. But now I created a a for loop and then added two buttons which could add or remove the textfields and it now works perfectly.
Here is the code for this. }
if showUpdateButton {
HStack{
Button(action:{
self.remarksList.append("")
}) {
Text("Add Remarks")
}
Spacer()
Button(action:{
_ = self.remarksList.popLast()
}) {
Text("Delete Remarks")
}
}.padding(30)
}
added code details below
Below is the code that I have currently
struct CheckListCard: View {
@Binding var checkListData : ChecklistModel
@State var statusList: [String] = []
@State var currentStatus : String = ""
@State var currentRemark: String = ""
@Binding var enableButtonBool: Bool
var body: some View {
VStack{
Text("Description").padding()
.onAppear(){
addData()
}
if checkListData.description != nil{
Text(checkListData.description!)
.padding()
}
Text("Status").padding()
if checkListData.status != nil {
Picker("Status", selection: $currentStatus ) {
ForEach(GeneralMethods().uniqueElementsFrom(array: statusList), id: \.self){ status in
Text(status)
}
}.pickerStyle(SegmentedPickerStyle())
.padding()
.disabled(!enableButtonBool)
}
Text("Remarks")
if checkListData.remarks != nil{
TextField("Remarks", text: $currentRemark)
.disabled(!enableButtonBool)
.padding()
.background(Color(.white))
.cornerRadius(8)
.accentColor(.gray)
}else{
TextField("Remarks", text: $currentRemark)
.disabled(!enableButtonBool)
.padding()
.background(Color(.white))
.cornerRadius(8)
}
}
struct CheckListSheet: View {
@State var taskId: Int
@State var pmTaskResponse : PmTaskResponse
@State var checklistResponse: [ChecklistModel] = [ChecklistModel()]
@State var enableButtonBool: Bool = false
var body: some View {
Text("Checklist Items")
.padding()
.font(.title)
ScrollView{
ForEach(checklistResponse, id:\.self){ checklist in
CheckListCard(checkListData: Binding(get: {
return checklist
}, set: { (newValue) in
checklistResponse.append(newValue)
}) , enableButtonBool: $enableButtonBool)
}
if enableButtonBool{
Button("Update"){
updateCheckList()
}.buttonStyle(MainButton())
}
}
.onAppear(){
getChecklists()
}
}
@OOPer I have attached the file for you to see. Let me know if you need anything else.
CheckListSheet.swift
I have refactored the file and I am sending it again.
CheckListSheet.swift
Can anybody help. Is this a bug or I am doing something wrong. I have attached a video as well.
@OOPer the file is large almost 700 lines and to help someone run it... I will have to make many changes to it. I will try to do something on my end. Thanks anyway.
I have the same issue in the current build of XCODE 12.5 and ios 14.6. Has somebody found an answer?
@OOPer found the issue. I am using custom toolbar using .toolbar which is causing this issue. I removed it and it works fine. Need to have a work around for this.