Untitled
unknown
swift
2 years ago
11 kB
3
Indexable
// // AddAddressView.swift // Garageworks-iOS-Revamp // // Created by mac on 01/12/22. // import SwiftUI struct AddAddressView: View { @State var callAddressSelectionFragment: Int? = nil @State var callDate_TimeSelectionView: Int? = nil @State var showText: String = "" @State var isProceed :Bool = false @State var selectedSlot: Int = 0 @State var indexes : Int = -1//selected question indexes @State var selectedAddressList : [String] = [] // selected ans ids var body: some View { GeometryReader { geometry in VStack(spacing:0){ NavigationLink(destination:AddressSelectionFragmentView().navigationBarHidden(true)){ HStack(spacing:20){ Image("Vector 1") .padding(.leading,10) Text(Strings.label_Please_select_your_address) .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(alignment: .center) { ScrollView{ LazyVStack{ ForEach(UserDefaultsManager.fetchCustomerAddressList().indices, id:\.self){ value in VStack{ var selectedAddress = UserDefaultsManager.fetchCustomerAddressList()[value] VStack{ HStack(alignment:.top){ Text(selectedAddress.address_type ?? "") .font(Font.custom(Fonts.product_regular, size: 16)) .foregroundColor(Color.init(hex: Colors.color_gr2)) Spacer() // ZStack { NavigationLink(destination: AddressSelectionFragmentView().navigationBarHidden(true), tag: 1, selection: $callAddressSelectionFragment){ // EmptyView() // } // } // .frame(width: 0, height: 0) // .opacity(0.0) // .buttonStyle(PlainButtonStyle()) Image("editImage") .renderingMode(.original) .resizable() .aspectRatio(contentMode: .fit) .frame(width: 20, height: 23) .onTapGesture { self.callAddressSelectionFragment = 1 } } } .padding(.bottom,5) VStack(alignment:.leading,spacing:5){ Text(Strings.label_address) .font(Font.custom(Fonts.product_regular, size: 12)) .foregroundColor(Color.init(hex: Colors.color_light_gr)) Text(selectedAddress.google_map ?? "") .font(Font.custom(Fonts.product_regular, size: 14)) .foregroundColor(Color.init(hex: Colors.color_gr2)) } } .padding() .cornerRadius(10) HStack(spacing:120){ VStack(alignment:.leading,spacing:5){ Text(Strings.label_area) .font(Font.custom(Fonts.product_regular, size: 12)) .foregroundColor(Color.init(hex: Colors.color_light_gr)) .frame(alignment:.leading) Text(selectedAddress.area ?? "") .font(Font.custom(Fonts.product_regular, size: 14)) .foregroundColor(Color.init(hex: Colors.color_bk)) .frame(alignment:.leading) } VStack(alignment:.leading,spacing:5){ Text(Strings.label_city) .font(Font.custom(Fonts.product_regular, size: 12)) .foregroundColor(Color.init(hex: Colors.color_light_gr)) .frame(alignment:.leading) Text(selectedAddress.city ?? "") .font(Font.custom(Fonts.product_regular, size: 14)) .foregroundColor(Color.init(hex: Colors.color_bk)) .frame(alignment:.leading) } } .padding(.bottom,15) } .frame(width: geometry.size.width * 0.9, height:geometry.size.width * 0.45) .background(.white) .cornerRadius(10) .overlay( RoundedRectangle(cornerRadius: 10) .stroke(Color.init(hex: indexes == value ? Colors.color_or : Colors.color_wh), lineWidth: 0.9)) .onTapGesture { indexes = value self.isProceed = true // self.$selectedSlot.append(value) } } NavigationLink(destination: AddressSelectionFragmentView().navigationBarHidden(true), tag: 1, selection: $callAddressSelectionFragment){ Text(Strings.input_add_new_address) .frame(width:geometry.size.width * 0.9, height: 50) .foregroundColor(Color.init(hex: Colors.color_bl)) .background(Color.init(hex: Colors.color_e6)) .font(Font.custom(Fonts.product_medium, size: 15)) .cornerRadius(10) .overlay( RoundedRectangle(cornerRadius: 10) .stroke(Color.init(hex: Colors.color_bl), lineWidth: 0.8)) } .onTapGesture { self.callAddressSelectionFragment = 1 } // add Button }.frame(width:geometry.size.width) .background(Color.init(hex: Colors.color_gr)) .cornerRadius(30, corners: [.topLeft, .topRight]) // .padding(.horizontal) }.frame(width:geometry.size.width, height:geometry.size.height * 0.8,alignment: .top) .padding() VStack{ NavigationLink(destination: Date_TimeSelectionView().navigationBarHidden(true), tag:1 ,selection: $callDate_TimeSelectionView){ Text(Strings.label_procced) .frame(width:geometry.size.width * 0.9, height: 50) .foregroundColor(Color.init(hex: Colors.color_wh)) .background(Color.init(hex: Colors.color_or)) .font(Font.custom(Fonts.product_medium, size: 15)) .cornerRadius(10) .onTapGesture { if isProceed == false{ self.showText = "Please Select Address Slot" } else{ print("navigation procced............") self.callDate_TimeSelectionView = 1 } } } } .frame(width:geometry.size.width * 0.9, height: 80,alignment:.top) .background(Color.init(hex: Colors.color_gr)) .showToast(text: $showText) } .frame(width:geometry.size.width, height:geometry.size.height * 0.99,alignment: .bottom) .background(Color.init(hex: Colors.color_gr)) .cornerRadius(30, corners: [.topLeft, .topRight]) .edgesIgnoringSafeArea(.bottom) } .frame(width:geometry.size.width,height:geometry.size.height) .background(Color.init(hex: Colors.color_wh)) } .navigationBarTitle("") .navigationBarBackButtonHidden(true) .navigationBarHidden(true) } } struct AddAddressView_Previews: PreviewProvider { static var previews: some View { AddAddressView() } } // .showToast(text: $loginObserver.wrongOTPMessage) // .padding(.horizontal)
Editor is loading...