Friday, May 1, 2026
HomeiOS Developmentios - Reload physique objects as soon as knowledge from service layer...

ios – Reload physique objects as soon as knowledge from service layer hundreds in swiftUI

[ad_1]

I am new to the swiftUI, on the lookout for a option to refresh view as soon as service knowledge retrieved. What I need is, as soon as web page hundreds, -or earlier than web page loads- I need to name fillUI perform so I can retrieve parsed json knowledge from service layer, with that knowledge I need to refresh this code block so my foreach block works with knowledge I’ve:

                            VStack(spacing:15 ) {
                                ScrollView(.horizontal) {
                                    VStack {
                                            ForEach(0..<5) { i in
                                                MeetingCellView(meetingData: meetingListData?.get(at: i) )
                                                    .body(width: 340, top: 150)
                                                    .padding(.horizontal)
                                                    
                                            }.body(width: 350)

                                    }
                                }.body(width: 350)
                            }

In UIKit, i used to be capable of clear up these points with a approach like loading and retrieving all the info first, then exhibiting the view itself with an information. For swiftUI what’s the greatest method to try this?

Right here is the total code of my associated view physique. I had searched web however could not discover the one but.

import SwiftUI

struct HomeView: View {
    @State var username: String = ""
    @State var meetingCode: String = ""
    @State var knowledge: GetUserDetailModel? = nil
    @State var meetingListData: [Datum]? = nil
    @State var requestLoaded = false
    
    var physique: some View {
        
        ZStack{
            VStack {
                Picture("house.background")
                    .resizable()
                    .body(maxHeight: 338)
                Spacer()
                
                ZStack {
                    VStack {
                        RoundedRectangle(cornerRadius: 8)
                            .padding(.prime, -20)
                            .foregroundColor(.white)
                    }
                    ScrollView(.vertical, showsIndicators: false)
                    {
                        //MARK: - ScrollView Begin
                        VStack {
                            HStack(spacing: 13.0) {
                                NavigationLink(vacation spot: CreateMeetingView()) {
                                    
                                    
                                    ZStack {
                                        RoundedRectangle(cornerRadius: 12)
                                            .foregroundColor(Coloration(pink: 0.935, inexperienced: 0.914, blue: 0.957))
                                        VStack(spacing: 18) {
                                            HStack {
                                                Picture("icon.digital camera")
                                                Spacer()
                                            }
                                            HStack {
                                                Textual content("New Assembly")
                                                    .foregroundColor(Coloration(pink: 0.476, inexperienced: 0.228, blue: 0.701))
                                                    .font(.customized("inter-semibold", dimension: 15))
                                                Spacer()
                                            }
                                            
                                        }.padding(.horizontal, 15)
                                        
                                    }.body(maxWidth: .infinity, idealHeight: 101)
                                        .padding(.main, 25)
                                }
                                
                                NavigationLink(vacation spot: Textual content("there"))
                                {
                                    ZStack {
                                        RoundedRectangle(cornerRadius: 12)
                                            .foregroundColor(Coloration(pink: 0.897, inexperienced: 0.939, blue: 0.978))
                                        VStack(spacing: 18) {
                                            HStack {
                                                Picture("icon.calendar")
                                                Spacer()
                                            }
                                            HStack {
                                                Textual content("Schedule Now")
                                                    .foregroundColor(Coloration(pink: 0.038, inexperienced: 0.525, blue: 0.917))
                                                    .font(.customized("inter-semibold", dimension: 15))
                                                Spacer()
                                            }
                                            
                                        }.padding(.horizontal, 15)
                                        
                                    }.body(maxWidth: .infinity, idealHeight: 101)
                                        .padding(.trailing, 25)
                                }
                            }
                        }
                        
                        VStack {
                            HStack {
                                Textual content("Upcoming Conferences")
                                    .font(.customized("inter-semibold", dimension: 17))
                                    .padding(.main, 25)
                                Spacer()
                            }
                            
                            ZStack {
                                
                                VStack(spacing: 30) {
                                    HStack {
                                        Picture("upcoming.calendar")
                                    }
                                    HStack {
                                        Textual content("You do not need a upcoming assembly.")
                                            .font(.customized("inter-regular", dimension: 15))
                                            .foregroundColor(Coloration(pink: 0.692, inexperienced: 0.692, blue: 0.692))
                                    }
                                }.hidden()
                                    .padding(.vertical, 46)
                                
                                
                                VStack(spacing:15 ) {
                                    ScrollView(.horizontal) {
                                        VStack {
                                                ForEach(0..<5) { i in
                                                    MeetingCellView(meetingData: meetingListData?.get(at: i) )
                                                        .body(width: 340, top: 150)
                                                        .padding(.horizontal)
                                                        
                                                }.body(width: 350)
    
                                        }
                                    }.body(width: 350)
                                }
                                
                            }
                                .padding(.horizontal ,15)
                            
                        }.padding(.prime, 25)
                            .padding(.backside, 100)
                        
                        //MARK:  ScrollView Finish
                    }
                }
            }.ignoresSafeArea()
            
            
            VStack {
                HStack {
                    Picture("splash.brand")
                        .resizable()
                        .body(maxWidth: 100, maxHeight: 20)
                        .padding(.main, 24)
                    Spacer()
                    Picture("icon.profile")
                        .padding(.trailing,25)
                    
                    
                }
                VStack(spacing: 10.0) {
                    HStack {
                        Textual content("Good Morning,")
                            .font(.customized("inter-semibold", dimension: 13))
                            .foregroundColor(.white)
                        Spacer()
                    }
                    HStack {
                        Textual content(username)
                            .font(.customized("inter-semibold", dimension: 22))
                            .foregroundColor(.white)
                        Spacer()
                    }
                    
                    
                }.padding(.main, 24)
                
                ZStack {
                    Coloration.white
                    VStack(spacing: 10.0) {
                        
                        HStack {
                            Textual content("Be a part of Assembly")
                                .font(.customized("inter-semibold", dimension: 13))
                            Spacer()
                        }
                        
                        HStack {
                            TextField("Enter assembly code", textual content: $meetingCode)
                                .font(.customized("inter-regular", dimension: 15))
                                .keyboardType(.numbersAndPunctuation)
                        }
                    }.padding(.horizontal, 15)
                    
                    
                }
                .cornerRadius(6)
                .body(maxWidth: .infinity, maxHeight: 75.0)
                .padding(.horizontal, 25.0)
                .padding(.prime, 30)
                
                
                Spacer()
            }.hiddenNavigationBarStyle()
            
        }
            .onAppear(carry out: fillUI)
            
            
            
    }
    func fillUI() {
        username = knowledge?.givenName ?? "error"
        Community.meetingList {conferences in
            //print(conferences)
            meetingListData = conferences?.knowledge
            requestLoaded = true
            
        }
    }
}

struct HomeView_Previews: PreviewProvider {
    static var previews: some View {
        HomeView()
    }
}

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments