Post

Replies

Boosts

Views

Activity

Reply to Get data from view after it gets added on screen using ForEach
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()     }         }
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Back button removed in the navigation bar once the view loads
I had a view that used to be opened from a list. The view contained a scrollview and all the items are listed in it including the TextFields, Texts, Button, Picker and others. I was using a custom modifier in the toolbar trialing items to show a notification Sheet and a logout button. Below is the custom code: ScrollView{ // some code }.toolbar(){       ToolbarItem(placement: .navigationBarTrailing){         Logout().environmentObject(settings)       }     } The logout class held the messaging sheet and the logout button. This caused the back button to be disappearing whenever the view loaded. I have now changed it to: ScrollView{ //some code } .navigationBarItems(trailing: Logout().environmentObject(settings))
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’21
Reply to Get data from view after it gets added on screen using ForEach
added code details below
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Get data from view after it gets added on screen using ForEach
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()     }         }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Get data from view after it gets added on screen using ForEach
@OOPer I have attached the file for you to see. Let me know if you need anything else. CheckListSheet.swift
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Get data from view after it gets added on screen using ForEach
I have refactored the file and I am sending it again. CheckListSheet.swift
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Back button removed in the navigation bar once the view loads
Can anybody help. Is this a bug or I am doing something wrong. I have attached a video as well.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to Back button removed in the navigation bar once the view loads
@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.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to Why does this view load twice?
I have the same issue in the current build of XCODE 12.5 and ios 14.6. Has somebody found an answer?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to Back button removed in the navigation bar once the view loads
@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.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to Back button removed in the navigation bar once the view loads
I had a view that used to be opened from a list. The view contained a scrollview and all the items are listed in it including the TextFields, Texts, Button, Picker and others. I was using a custom modifier in the toolbar trialing items to show a notification Sheet and a logout button. Below is the custom code: ScrollView{ // some code }.toolbar(){       ToolbarItem(placement: .navigationBarTrailing){         Logout().environmentObject(settings)       }     } The logout class held the messaging sheet and the logout button. This caused the back button to be disappearing whenever the view loaded. I have now changed it to: ScrollView{ //some code } .navigationBarItems(trailing: Logout().environmentObject(settings))
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to Open view deep in NavigationView from push notification
@bobandsee did you find the answer to this? I have the same issue and I can't really find anything regarding SwiftUI to handle this.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’21