Untitled

 avatar
unknown
plain_text
3 years ago
5.5 kB
6
Indexable
//
//  SelfInspectionView.swift
//  Garageworks-iOS-Revamp
//
//  Created by mac on 26/12/22.
//

import SwiftUI

struct SelfInspectionView: View {
    @StateObject private var selfInspectionObserver: SelfInspectionObserver = SelfInspectionObserver()

    @State private var messageText = ""
    var body: some View {
        GeometryReader{ geometry in
            VStack{
//                NavigationLink(destination: Date_TimeSelectionView().navigationBarHidden(true)){
                    HStack(spacing:20){
                        Image("Vector 1")
                            .padding(.leading,10)
                        Text(Strings.label_splf_inspection)
                            .font(Font.custom(Fonts.product_regular, size: 16))
                            .foregroundColor(Color.init(hex: Colors.color_gr2))
                        Spacer()
                    }
                    .frame(width:geometry.size.width,height:geometry.size.height * 0.10,alignment: .center)
                    .background(.white)
//                }
                VStack(spacing:10){
                    SelfInspectionQuestionView(selfInspectionServiceQuestions: selfInspectionObserver.selfInspectionServiceQuestions?.answers ?? [])
                    
//                    HStack(alignment:.top,spacing: 30){
//                        Image("GW_logo 1")
//                            .resizable()
//                            .frame(width:geometry.size.width * 0.13, height:50)
//    //                        .padding()
//                        Text(selfInspectionObserver.selfInspectionServiceQuestions?.question ?? "")
//                            .padding(.all,10)
//                            .frame(width:200,alignment: .leading)
//                            .foregroundColor(.black)
//                            .background(.white)
//                            .cornerRadius(10)
//                    }
//                    .frame(width:geometry.size.width * 0.9, alignment: .leading)
//                    .padding([.top,.bottom],30)
                    
//                    ForEach(selfInspectionObserver.selfInspectionServiceQuestions?.answers ?? [], id: \.self){ item in
//                        HStack(alignment:.top, spacing: 10){
//                            Text(item.answer ?? "")
//                                .padding(.all,10)
//                                .frame(width:200, alignment: .leading)
//                                .foregroundColor(.black)
//                                .background(.white)
//                                .cornerRadius(10)
//                                .onTapGesture {
//                                     var saveAnswer_id = item.answer_id
//                                    var saveParent_id  = selfInspectionObserver.selfInspectionServiceQuestions?.parent_id
//
//                                    selfInspectionObserver.getSaveSelfinspectionQuestionAnswers(booking_id: UserDefaultsManager.fetchCustomerBooking()?.booking_id ?? "", session_id: "7ko0f1piirl9772evkti9nacrv8q3hp3",                                                                        answer_id: saveAnswer_id ?? "", question_id: "1", customer_id: UserDefaultsManager.fetchCustomer()?.customer_id ?? "")
//
//                                    selfInspectionObserver.getSelfinspectionServiceQuestions(parent_id: saveParent_id ?? "" , answer_id: saveAnswer_id ?? "", service_id: UserDefaultsManager.fetchSelectedService()?.service_id ?? "", offset: "")
//                                }
//                            Image("person_icon")
//                                .resizable()
//                                .frame(width:geometry.size.width * 0.13, height:50)
//        //                        .padding()
//                        }
//                        .frame(width:geometry.size.width * 0.9, alignment: .trailing)
//                    }
                }
                .frame(width:geometry.size.width, height:geometry.size.height * 0.75,alignment: .top)
                .background(Color.init(hex: Colors.color_gr))
                .cornerRadius(30, corners: [.topLeft, .topRight])
                
                HStack{
                    TextField("Write a massege",text: $messageText)
                        .font(Font.custom(Fonts.product_regular, size: 14))
                        .foregroundColor(Color.init(hex: Colors.color_F6))
                    Image("send-icon")
                        .resizable()
                        .frame(width:30,height: 30)
                }
                .padding()
            }
            .frame(width:geometry.size.width,height: geometry.size.height)
            .background(.white)
        }
        .onAppear(){
            selfInspectionObserver.getSessionId(customer_id: UserDefaultsManager.fetchCustomer()?.customer_id ?? "", booking_id: UserDefaultsManager.fetchCustomerBooking()?.booking_id ?? "")
           
            selfInspectionObserver.getSelfinspectionServiceQuestions(parent_id: "", answer_id: "", service_id: UserDefaultsManager.fetchSelectedService()?.service_id ?? "", offset: "")
           
//            selfInspectionObserver.getSelfInspectionCashbackAdd(customer_id: "13", session_id: "e2n1n27bfusp06gcsclp9n4c0chjaj5h", booking_id: "622", source: "Customer App")
           
            
        }
    }
}

struct SelfInspectionView_Previews: PreviewProvider {
    static var previews: some View {
        SelfInspectionView()
    }
}
Editor is loading...