"Resolving UI Update Issues with iOS 13 ObservedObject: Exploring Alternatives to StateObject"
"I've explored several alternatives for StateObject, which is only available in iOS 14. Unfortunately, I need a solution compatible with iOS 13. Any guidance or suggestions on addressing this problem would be highly appreciated."
How to achieve same thing in iOS 13 with ObservedObject??
I tried for ObservedObject in iOS 13 but that is not working to update the UI.
Code
import SwiftUI
struct AiicoTermsConditionsView: View {
@Environment(\.presentationMode) var presentationMode
@ObservedObject var viewModel: AiicoTermsConditionsViewModel
@ObservedObject var webmodel = WebViewModel(url: "")
let backArrowImg = "arrow.left"
var btnBack : some View { Button(action: {
self.presentationMode.wrappedValue.dismiss()
}) {
HStack {
Image(backArrowImg)
.aspectRatio(contentMode: .fit)
.foregroundColor(.colorBlack)
}
}
}
var rightBarButton : some View { Button(action: {
}) {
HStack {
viewModel.rightButtonBar()
}
}
}
var body: some View {
GeometryReader { geo in
VStack{
NavigationLink(destination: InsuranceSelectPlanView(viewModel: InsuranceSelectPlanViewModel(rechargeData: viewModel.rechargeData, title: viewModel.title, billerType: viewModel.billerType, isDoctorDay: viewModel.isDoctorDay, selectedPlanData: viewModel.selectedPlanData, selectedHospitalData: viewModel.selectedHospitalData, insuranceType: viewModel.insuranceType, formType: .selfDetailsForm, detailFormModel: viewModel.detailFormModel, KinFormModel: viewModel.KinFormModel, documentFormModel: viewModel.documentFormModel, isFromPreview: false, selectHospitalMode: .purchasePolicy)), isActive: $viewModel.navigateTONext){
EmptyView()
}
if viewModel.isDoctorDay {
Text("docterdey_about_message".localized.toString())
.font(.kMontserratMedium14)
.padding([.leading,.trailing],20)
Spacer()
}
else
{
// webview
LoadingView(isShowing: $webmodel.isLoading) { WebView(viewModel: webmodel) }
}
// Bottom button
NWRoundedButton(title: kNext,
textColor: Color.colorGolden,
buttonBackgroundColor: Color.colorBlack,
action:
{
viewModel.navigateTONext = true
})
.frame(height: 70)
}
.onAppear(){
}
.navigationTitle("about_insurance".localized.toString()).font(.kMontserratRegular17)
.navigationBarTitleDisplayMode(.inline)
.navigationBarBackButtonHidden(true)
.navigationBarItems(leading: btnBack , trailing: rightBarButton)
}
}
}
@StateObject