Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
//
2
//  ProgressView.swift
3
//  twogetskills
4
//
5
//  Created by Efrain Yanez Recanatini on 5/5/22.
6
//
7
 
8
import Foundation
9
import SwiftUI
10
 
11
struct MyProgressView: View {
12
 
13
    @ObservedObject private var viewModel = ProgressViewModel()
14
 
15
    private let colorTitle = UIColor(hex: Config.COLOR_TEXT_VIEW_TITLE)
16
 
17
 
18
    private let colorBackgroundTopic = UIColor(hex: Config.COLOR_BACKGROUND_TOPIC)
19
 
20
    private let colorAppBackground = UIColor(hex: Config.COLOR_APP_BAR)
21
 
22
    private let colorWindowBackground = UIColor(hex: Config.COLOR_WINDOW_BACKGROUND)
23
 
24
    init()
25
    {
26
        viewModel.load()
27
    }
28
 
29
    var body: some View {
30
 
31
        GeometryReader { geometry in
32
            VStack {
33
                HStack {
34
                    Text("Cápsulas")
35
                        .font(.title3)
36
                        .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
37
                        .foregroundColor(Color(colorTitle ?? .gray))
38
                    Spacer()
39
                }.padding([.top], 10)
40
                .padding(.horizontal, 10)
41
 
42
 
43
                HStack {
44
                    Spacer()
45
 
46
 
47
                    PieChartView(
48
                        values:[viewModel.percentajeCapsuleIncomplete, viewModel.percentajeCapsuleComplete],
49
                        names: ["", ""],
50
                        formatter: {value in String(format: "%.2f%%", value)},
51
                        colors: [
52
                            .gray,
53
                            Color(colorAppBackground ?? .green)
54
                        ],
55
                        backgroundColor: Color(colorBackgroundTopic ?? .gray),
56
                        widthFraction: 0.75,
57
                        innerRadiusFraction: 0.60,
58
                        chartSize : 250,
59
                        total : viewModel.percentajeCapsuleComplete
60
                    )
61
                    .frame(width: 190, height: 190,  alignment: .center)
62
 
63
                    Spacer()
64
                }
65
 
66
 
67
 
68
                HStack {
69
                    Spacer()
70
                    VStack {
71
                        Text(String(viewModel.capsuleTotal))
72
                            .font(.subheadline)
73
                            .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
74
                            .foregroundColor(Color(colorTitle ?? .systemBlue))
75
 
76
                        Text("Total")
77
                            .font(.subheadline)
78
                            .foregroundColor(.gray)
79
                    }
80
                    VStack {
81
                        Text(String(viewModel.capsuleTotalStarted))
82
                            .font(.subheadline)
83
                            .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
84
                            .foregroundColor(Color(colorTitle ?? .systemBlue))
85
 
86
                        Text("Iniciadas")
87
                            .font(.subheadline)
88
                            .foregroundColor(.gray)
89
                    }
90
                    VStack {
91
                        Text(String(viewModel.capsuleTotalForStart))
92
                            .font(.subheadline)
93
                            .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
94
                            .foregroundColor(Color(colorTitle ?? .systemBlue))
95
 
96
                        Text("Por realizar")
97
                            .font(.subheadline)
98
                            .foregroundColor(.gray)
99
                    }
100
                    VStack {
101
                        Text(String(viewModel.capsuleTotalCompleted))
102
                            .font(.subheadline)
103
                            .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
104
                            .foregroundColor(Color(colorTitle ?? .systemBlue))
105
 
106
                        Text("Completadas")
107
                            .font(.subheadline)
108
                            .foregroundColor(.gray)
109
                    }
110
                    Spacer()
111
 
112
                }.padding([.top], 5)
113
 
114
                HStack {
115
                    Text("Retorno")
116
                        .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
117
                        .font(.title3)
118
                        .foregroundColor(Color(colorTitle ?? .gray))
119
                    Spacer()
120
                }.padding([.top], 5)
121
                .padding(.horizontal, 10)
122
 
123
                HStack {
124
                    Spacer()
125
 
126
                    PieChartView(
127
                            values:[
128
                                Double(viewModel.capsuleTotalWithoutReturning),
129
                                Double(viewModel.capsuleTotalWithReturning)
130
                            ],
131
                            names: ["", ""],
132
                            formatter: {value in String(format: "%.0f", value)},
133
                            colors: [
134
                                .gray,
135
                                Color(colorAppBackground ?? .green)
136
                            ],
137
                            backgroundColor: Color(colorBackgroundTopic ?? .gray),
138
                            widthFraction: 0.75,
139
                            innerRadiusFraction: 0.60,
140
                            chartSize : 250,
141
                            total : Double(viewModel.capsuleTotalWithReturning)
142
 
143
                        )
144
                        .frame(width: 190, height: 190,  alignment: .center)
145
 
146
 
147
 
148
                    Spacer()
149
                }
150
 
151
                Spacer()
152
 
153
            }.onAppear {
154
                viewModel.load()
155
            }
156
            .frame(width: geometry.size.width, height: geometry.size.height, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
157
            .background(Color(colorBackgroundTopic ?? .white))
158
            .navigationTitle("Progreso")
159
            .navigationBarTitleDisplayMode(.inline)
160
            .navigationBarBackButtonHidden(true)
161
 
162
        }
163
    }
164
}
165
 
166
 
167
struct MyProgressView_Previews: PreviewProvider {
168
    static var previews: some View {
169
        MyProgressView()
170
    }
171
}
172