-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContentView.swift
61 lines (51 loc) · 2.04 KB
/
ContentView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// ContentView.swift
// EAInterviewTask
//
// Created by Banka, Sathyanath (Cognizant) on 14/06/24.
//
import SwiftUI
import Combine
struct ContentView: View {
@StateObject var viewModel: HomeViewModel
var body: some View {
ZStack{
if viewModel.isLoading ?? false {
Color.black.opacity(0.3)
.edgesIgnoringSafeArea(.all)
LoaderView()
}else {
VStack {
ScrollView(showsIndicators: false){
LazyVStack(alignment: .leading ,content: {
ForEach(viewModel.data ?? [], id: \.id) { item in
Section {
Text("\((item.name?.isEmpty ?? true) ? "No Record Name" : item.name ?? "No Record Name")")
ScrollView {
LazyVStack(content: {
ForEach(item.bands ?? [], id: \.id) { band in
BandView(band: band)
}
})
}
}
}
})
}
}.onAppear {
if viewModel.data?.isEmpty ?? true {
viewModel.getbandDetails(homeService: HomeImplementation(manager: NetworkManager())) }
}
.alert("Important message", isPresented: $viewModel.isShowAlert ) {
Button("OK", role: .cancel) {
viewModel.isShowAlert = false
}
}
.padding()
}
}
}
}
#Preview {
ContentView(viewModel: HomeViewModel())
}