1 |
efrain |
1 |
//
|
|
|
2 |
// CompanyListView.swift
|
|
|
3 |
// twogetskills
|
|
|
4 |
//
|
|
|
5 |
// Created by Efrain Yanez Recanatini on 7/30/22.
|
|
|
6 |
//
|
|
|
7 |
|
|
|
8 |
import SwiftUI
|
|
|
9 |
|
|
|
10 |
struct CompanyListView: View {
|
|
|
11 |
@EnvironmentObject private var networkMonitor : NetworkMonitor
|
|
|
12 |
@EnvironmentObject private var appNavigation : AppNavigation
|
|
|
13 |
|
|
|
14 |
@ObservedObject var viewModel : CompanyListViewModel = CompanyListViewModel()
|
21 |
efrain |
15 |
private var appData = Environment(\.appData).wrappedValue
|
1 |
efrain |
16 |
|
|
|
17 |
var body: some View {
|
|
|
18 |
VStack(spacing: 0) {
|
|
|
19 |
HStack {
|
|
|
20 |
Image("logo")
|
|
|
21 |
.resizable()
|
|
|
22 |
.frame(width: 32, height: 32, alignment: .center)
|
|
|
23 |
.aspectRatio(contentMode: .fit)
|
|
|
24 |
.aspectRatio(contentMode: .fit)
|
|
|
25 |
.foregroundColor(networkMonitor.status == .disconnected ? Color("color_network_disconnected_foreground") : Color("color_app_bar_foreground"))
|
|
|
26 |
.padding(.leading, 16)
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
Text(networkMonitor.status == .disconnected ? Config.LANG_ERROR_NETWORK_MESSAGE_SHORT : Config.LANG_TAB_BAR_BUTTON_COMPANIES)
|
|
|
30 |
.font(Font.custom(Config.FONT_NAME_REGULAR, size: Config.FONT_SIZE_APP_BAR_HEAD1 ))
|
|
|
31 |
.aspectRatio(contentMode: .fit)
|
|
|
32 |
.foregroundColor(networkMonitor.status == .disconnected ? Color("color_network_disconnected_foreground") : Color("color_app_bar_foreground"))
|
|
|
33 |
.padding(.leading, 4)
|
|
|
34 |
|
|
|
35 |
Spacer()
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
}
|
|
|
39 |
.edgesIgnoringSafeArea(.top)
|
|
|
40 |
.frame(height: 50)
|
|
|
41 |
.background(networkMonitor.status == .disconnected ? Color("color_network_disconnected_background") : Color("color_app_bar_background"))
|
|
|
42 |
|
|
|
43 |
Divider().background(networkMonitor.status == .disconnected ? Color("color_network_disconnected_background") : Color("color_app_bar_background"))
|
|
|
44 |
|
|
|
45 |
ScrollView {
|
|
|
46 |
LazyVStack {
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
ForEach(0..<self.viewModel.companies.count) { index in
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
CompanyListItemView(companyUuid: self.viewModel.companies[index].uuid)
|
17 |
efrain |
54 |
.environmentObject(appNavigation).onTapGesture {
|
|
|
55 |
appData.companyUuidActive = self.viewModel.companies[index].uuid
|
|
|
56 |
appData.save()
|
|
|
57 |
|
|
|
58 |
withAnimation {
|
|
|
59 |
appNavigation.subpageActive = .progress
|
|
|
60 |
}
|
|
|
61 |
}
|
1 |
efrain |
62 |
}
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
}
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
}
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
struct CompanyListView_Previews: PreviewProvider {
|
|
|
78 |
static var previews: some View {
|
|
|
79 |
CompanyListView()
|
|
|
80 |
}
|
|
|
81 |
}
|