ios – Empty View taken space


I want to show EmptyView() without space if there is no data from sever.

If I put my code inside VStack then EmptyView() takes the space,
If I put the code without Stack, then API is calling infinite number.

My code is follow:

VStack{
            if let arr =  vm.arrMessages{
                getContent()
                    .padding(.top)
            }else if vm.isLoading {
                ProgressView()
            }else if vm.isError {
                EmptyView()
            }
        }


Outside of VStack:

if let arr =  vm.arrMessages{
                getContent()
                    .padding(.top)
            }else if vm.isLoading {
                ProgressView()
            }else if vm.isError {
                EmptyView()
                    
            }

then API is calling infinite time.

thank you

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img