Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
//// ProgressView.swift// twogetskills//// Created by Efrain Yanez Recanatini on 5/5/22.//import Foundationimport SwiftUIstruct MyProgressView: View {@ObservedObject private var viewModel = ProgressViewModel()init(){viewModel.load()}var body: some View {GeometryReader { geometry inVStack(spacing: 0) {HStack {Image("logo").resizable().frame(width: 32, height: 32, alignment: .center).aspectRatio(contentMode: .fit).foregroundColor(Color("color_app_bar_foreground")).padding(.leading, 16)Text(Config.LANG_TAB_BAR_BUTTON_PROGRESS).font(Font.custom(Config.FONT_NAME_REGULAR, size: Config.FONT_SIZE_APP_BAR_HEAD1 )).foregroundColor(Color("color_app_bar_foreground")).padding(.leading, 4)Spacer()}.background(Color("color_app_bar_background")).edgesIgnoringSafeArea(.top).frame(height: 50)Divider()HStack {Text("Cápsulas").font(.title3).fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/).foregroundColor(Color("color_app_bar_foreground"))Spacer()}.padding([.top], 10).padding(.horizontal, 10)HStack {Spacer()PieChartView(values:[viewModel.percentajeCapsuleIncomplete, viewModel.percentajeCapsuleComplete],names: ["", ""],formatter: {value in String(format: "%.2f%%", value)},colors: [.gray,Color("color_app_bar_foreground")],backgroundColor: Color("color_window_background"),widthFraction: 0.75,innerRadiusFraction: 0.60,chartSize : 250,total : viewModel.percentajeCapsuleComplete).frame(width: 190, height: 190, alignment: .center)Spacer()}HStack {Spacer()VStack {Text(String(viewModel.capsuleTotal)).font(.subheadline).fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/).foregroundColor(Color("color_textview"))Text("Total").font(.subheadline).foregroundColor(.gray)}VStack {Text(String(viewModel.capsuleTotalStarted)).font(.subheadline).fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/).foregroundColor(Color("color_textview"))Text("Iniciadas").font(.subheadline).foregroundColor(.gray)}VStack {Text(String(viewModel.capsuleTotalForStart)).font(.subheadline).fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/).foregroundColor(Color("color_textview"))Text("Por realizar").font(.subheadline).foregroundColor(.gray)}VStack {Text(String(viewModel.capsuleTotalCompleted)).font(.subheadline).fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/).foregroundColor(Color("color_textview"))Text("Completadas").font(.subheadline).foregroundColor(.gray)}Spacer()}.padding([.top], 5)HStack {Text("Retorno").fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/).font(.title3).foregroundColor(Color("color_textview"))Spacer()}.padding([.top], 5).padding(.horizontal, 10)HStack {Spacer()PieChartView(values:[Double(viewModel.capsuleTotalWithoutReturning),Double(viewModel.capsuleTotalWithReturning)],names: ["", ""],formatter: {value in String(format: "%.0f", value)},colors: [.gray,Color("color_app_bar_background")],backgroundColor: Color("color_window_background"),widthFraction: 0.75,innerRadiusFraction: 0.60,chartSize : 250,total : Double(viewModel.capsuleTotalWithReturning)).frame(width: 190, height: 190, alignment: .center)Spacer()}Spacer()}.onAppear {viewModel.load()}.frame(width: geometry.size.width, height: geometry.size.height, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/).background(Color("color_window_background")).navigationTitle("Progreso").navigationBarTitleDisplayMode(.inline).navigationBarBackButtonHidden(true)}}}struct MyProgressView_Previews: PreviewProvider {static var previews: some View {MyProgressView()}}