1 |
efrain |
1 |
//
|
|
|
2 |
// UserExtendedPointView.swift
|
|
|
3 |
// twogetskills
|
|
|
4 |
//
|
|
|
5 |
// Created by Efrain Yanez Recanatini on 5/6/22.
|
|
|
6 |
//
|
|
|
7 |
|
|
|
8 |
import Foundation
|
|
|
9 |
import SwiftUI
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
struct UserExtendedPointView : View {
|
|
|
15 |
|
|
|
16 |
private let colorBackgroundTopic = UIColor(hex: Config.COLOR_BACKGROUND_TOPIC)
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
private let colorAppTextView = UIColor(hex: Config.COLOR_APP_TEXT_VIEW_TITLE)
|
|
|
20 |
|
|
|
21 |
private let colorAppBackground = UIColor(hex: Config.COLOR_APP_BAR)
|
|
|
22 |
|
|
|
23 |
private var userExtendedPoint: UserExtendedPoint
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
init (userExtendedPoint: UserExtendedPoint)
|
|
|
27 |
{
|
|
|
28 |
self.userExtendedPoint = userExtendedPoint
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
var body: some View {
|
|
|
36 |
|
|
|
37 |
let color = Color((self.userExtendedPoint.type == .company ? colorAppBackground : colorBackgroundTopic) ?? .gray)
|
|
|
38 |
|
|
|
39 |
GeometryReader { geometry in
|
|
|
40 |
|
|
|
41 |
let posXCircle = (10 + (geometry.size.width / 2)) - geometry.size.width
|
|
|
42 |
|
|
|
43 |
let posYCircle = (geometry.size.height / 2)
|
|
|
44 |
|
|
|
45 |
let posXLine = (10 + (geometry.size.width / 2)) - geometry.size.width
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
ZStack {
|
|
|
51 |
Circle().frame(width: 10, height: 10, alignment: .topTrailing)
|
|
|
52 |
.foregroundColor(.white)
|
|
|
53 |
.offset(x: posXCircle, y: posYCircle)
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
Rectangle().frame(width:5, height: geometry.size.height)
|
|
|
58 |
.foregroundColor(.white)
|
|
|
59 |
.offset(x: posXLine, y: 0)
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
HStack{
|
|
|
63 |
|
|
|
64 |
VStack(alignment: .leading, spacing: 8) {
|
|
|
65 |
Text(self.userExtendedPoint.label)
|
|
|
66 |
.bold()
|
|
|
67 |
.font(.callout)
|
|
|
68 |
.lineLimit(1).foregroundColor(Color.gray)
|
|
|
69 |
|
|
|
70 |
Text(self.userExtendedPoint.value)
|
|
|
71 |
.font(.caption2)
|
|
|
72 |
.foregroundColor(Color.gray)
|
|
|
73 |
|
|
|
74 |
}.padding(.leading, 25)
|
|
|
75 |
|
|
|
76 |
Spacer()
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
}
|
|
|
85 |
}
|
|
|
86 |
}.background(color)
|
|
|
87 |
}
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
struct UserExtendedPointView_Previews: PreviewProvider {
|
|
|
92 |
static var previews: some View {
|
|
|
93 |
let userExtendedPoint = UserExtendedPoint(type: .company, label: "Company1", value : "Value1")
|
|
|
94 |
|
|
|
95 |
UserExtendedPointView(userExtendedPoint : userExtendedPoint )
|
|
|
96 |
}
|
|
|
97 |
}
|
|
|
98 |
|