1 |
efrain |
1 |
//
|
|
|
2 |
// TimeLinePointView.swift
|
|
|
3 |
// twogetskills
|
|
|
4 |
//
|
|
|
5 |
// Created by Efrain Yanez Recanatini on 3/24/22.
|
|
|
6 |
//
|
|
|
7 |
|
|
|
8 |
import Foundation
|
|
|
9 |
import SwiftUI
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
struct TimeLinePointView : View {
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
private let activity : String
|
|
|
17 |
private let imageName : String
|
|
|
18 |
private let date : String
|
|
|
19 |
private let highlight : Bool
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
init(userLogModel : UserLogModel, highlight : Bool)
|
|
|
23 |
{
|
|
|
24 |
self.highlight = highlight
|
|
|
25 |
|
|
|
26 |
let dateFormatterUserLog = DateFormatter()
|
|
|
27 |
dateFormatterUserLog.dateFormat = Constants.FORMAT_DATETIME_SERVICE
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
let dateFormatterView = DateFormatter()
|
|
|
31 |
dateFormatterView.dateFormat = Constants.FORMAT_DATE_TIME_12
|
|
|
32 |
|
|
|
33 |
let now = Date()
|
|
|
34 |
let timeStamp = dateFormatterUserLog.date(from: userLogModel.addedOn) ?? now
|
|
|
35 |
|
|
|
36 |
date = dateFormatterView.string(from: timeStamp)
|
|
|
37 |
|
|
|
38 |
//let dateOn = dateFormatter.string(from: now)
|
|
|
39 |
|
|
|
40 |
if userLogModel.activity == Constants.USER_LOG_ACTIVITY_SIGNIN {
|
|
|
41 |
imageName = "ic_inicio_de_sesion"
|
|
|
42 |
activity = "Inicio sesión"
|
|
|
43 |
}
|
|
|
44 |
else if userLogModel.activity == Constants.USER_LOG_ACTIVITY_SIGNOUT {
|
|
|
45 |
imageName = "ic_cerrar_sesion"
|
|
|
46 |
activity = "Cerrar sesión"
|
|
|
47 |
}
|
|
|
48 |
else if userLogModel.activity == Constants.USER_LOG_ACTIVITY_START_TOPIC {
|
|
|
49 |
imageName = "ic_inicio_un_topico"
|
|
|
50 |
activity = "Inicio un tópico"
|
|
|
51 |
}
|
|
|
52 |
else if userLogModel.activity == Constants.USER_LOG_ACTIVITY_START_CAPSULE {
|
|
|
53 |
imageName = "ic_inicio_una_capsula"
|
|
|
54 |
activity = "Inicio una cápsula"
|
|
|
55 |
}
|
|
|
56 |
else if userLogModel.activity == Constants.USER_LOG_ACTIVITY_COMPLETED_TOPIC {
|
|
|
57 |
imageName = "ic_competo_un_topico"
|
|
|
58 |
activity = "Completo un tópico"
|
|
|
59 |
}
|
|
|
60 |
else if userLogModel.activity == Constants.USER_LOG_ACTIVITY_COMPLETED_CAPSULE {
|
|
|
61 |
imageName = "ic_completo_una_capsula"
|
|
|
62 |
activity = "Completo una cápsula"
|
|
|
63 |
}
|
|
|
64 |
else if userLogModel.activity == Constants.USER_LOG_ACTIVITY_VIEW_SLIDE {
|
|
|
65 |
imageName = "ic_vio_una_diapositiva"
|
|
|
66 |
activity = "Ver una diapositiva"
|
|
|
67 |
}
|
|
|
68 |
else if userLogModel.activity == Constants.USER_LOG_ACTIVITY_TAKE_A_TEST {
|
|
|
69 |
imageName = "ic_tomo_un_quiz"
|
|
|
70 |
activity = "Tomo un cuestionario"
|
|
|
71 |
}
|
|
|
72 |
else if userLogModel.activity == Constants.USER_LOG_ACTIVITY_RETAKE_A_TEST {
|
|
|
73 |
imageName = "ic_repitio_un_quiz"
|
|
|
74 |
activity = "Repitio un cuestionario"
|
|
|
75 |
}
|
|
|
76 |
else if userLogModel.activity == Constants.USER_LOG_ACTIVITY_APPROVED_TEST {
|
|
|
77 |
imageName = "ic_questionario_paso"
|
|
|
78 |
activity = "Aprobo un cuestionario"
|
|
|
79 |
}
|
|
|
80 |
else {
|
|
|
81 |
imageName = "ic_desconocido"
|
|
|
82 |
activity = "Desconocido"
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
var body: some View {
|
|
|
91 |
|
|
|
92 |
GeometryReader { geometry in
|
|
|
93 |
|
|
|
94 |
let posXCircle = (10 + (geometry.size.width / 2)) - geometry.size.width
|
|
|
95 |
|
|
|
96 |
let posYCircle = (geometry.size.height / 2)
|
|
|
97 |
|
|
|
98 |
let posXLine = (10 + (geometry.size.width / 2)) - geometry.size.width
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
ZStack {
|
|
|
104 |
Circle().frame(width: 10, height: 10, alignment: .topTrailing)
|
|
|
105 |
.foregroundColor( Color("color_timeline_list_item_foreground_indicator"))
|
|
|
106 |
.offset(x: posXCircle, y: posYCircle)
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
Rectangle().frame(width:5, height: geometry.size.height)
|
|
|
111 |
.foregroundColor( Color("color_timeline_list_item_foreground_indicator"))
|
|
|
112 |
.offset(x: posXLine, y: 0)
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
HStack{
|
|
|
116 |
|
|
|
117 |
VStack(alignment: .leading, spacing: 8) {
|
|
|
118 |
Text(activity)
|
|
|
119 |
.bold()
|
|
|
120 |
.font(.callout)
|
|
|
121 |
.lineLimit(1)
|
|
|
122 |
.foregroundColor(highlight ? Color("color_timeline_list_item_foreground_highlight") : Color("color_timeline_list_item_foreground"))
|
|
|
123 |
|
|
|
124 |
Text(date)
|
|
|
125 |
.font(.caption2)
|
|
|
126 |
.foregroundColor(highlight ? Color("color_timeline_list_item_foreground_highlight") : Color("color_timeline_list_item_foreground"))
|
|
|
127 |
|
|
|
128 |
}.padding(.leading, 25)
|
|
|
129 |
|
|
|
130 |
Spacer()
|
|
|
131 |
|
|
|
132 |
Image(uiImage: UIImage(named: imageName) ?? UIImage())
|
|
|
133 |
.resizable()
|
|
|
134 |
.aspectRatio(contentMode: .fit)
|
|
|
135 |
.frame(width: 32, height: 32)
|
|
|
136 |
.background(Color("color_timeline_list_item_background"))
|
|
|
137 |
.clipShape(Circle())
|
|
|
138 |
.overlay(Circle().stroke(Color.white, lineWidth: 4))
|
|
|
139 |
.shadow(radius: 10)
|
|
|
140 |
.padding(10)
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
}
|
|
|
151 |
}
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
struct TimeLinePointView_Previews: PreviewProvider {
|
|
|
156 |
static var previews: some View {
|
|
|
157 |
let userLogModel = UserLogModel()
|
|
|
158 |
|
|
|
159 |
TimeLinePointView(userLogModel : userLogModel, highlight: true)
|
|
|
160 |
}
|
|
|
161 |
}
|