| 1 |
efrain |
1 |
//
|
|
|
2 |
// GridTopicView.swift
|
|
|
3 |
// twogetskills
|
|
|
4 |
//
|
|
|
5 |
// Created by Efrain Yanez Recanatini on 1/26/22.
|
|
|
6 |
//
|
|
|
7 |
|
|
|
8 |
import SwiftUI
|
|
|
9 |
|
|
|
10 |
struct GridTopicView: View {
|
|
|
11 |
//@EnvironmentObject var appDelegate: AppDelegate
|
|
|
12 |
// @EnvironmentObject var sceneDelegate: SceneDelegate
|
|
|
13 |
private var viewModel : TopicGridViewModel = TopicGridViewModel()
|
|
|
14 |
|
|
|
15 |
private let colorBackgroundTopic = UIColor(hex: Config.COLOR_BACKGROUND_TOPIC)
|
|
|
16 |
private let colorAppBar = UIColor(hex: Config.COLOR_APP_BAR)
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
let config = [
|
|
|
20 |
GridItem(.flexible()),
|
|
|
21 |
GridItem(.flexible())
|
|
|
22 |
]
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
var body: some View {
|
|
|
28 |
VStack(spacing: 0.0) {
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
ScrollView() {
|
|
|
32 |
|
|
|
33 |
LazyVGrid(columns: config, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/, spacing: /*@START_MENU_TOKEN@*/nil/*@END_MENU_TOKEN@*/, pinnedViews: /*@START_MENU_TOKEN@*/[]/*@END_MENU_TOKEN@*/, content: {
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
ForEach(0..<self.viewModel.topics.count) { i in
|
|
|
37 |
CardTopicView(
|
|
|
38 |
topicModel: self.viewModel.topics[i]
|
|
|
39 |
).frame(
|
|
|
40 |
width: Constants.CARD_WIDTH,
|
|
|
41 |
height: Constants.CARD_HEIGHT,
|
|
|
42 |
alignment: .center
|
|
|
43 |
)
|
|
|
44 |
|
|
|
45 |
}
|
|
|
46 |
}).padding(.top, 10)
|
|
|
47 |
}
|
|
|
48 |
Spacer()
|
|
|
49 |
} .onAppear {
|
|
|
50 |
print("CardTopicView")
|
|
|
51 |
}
|
|
|
52 |
.background(Color(colorBackgroundTopic ?? .gray))
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
struct GridTopicView_Previews: PreviewProvider {
|
|
|
59 |
static var previews: some View {
|
|
|
60 |
GridTopicView()
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
|