NewUserAddressView
unknown
swift
2 years ago
15 kB
3
Indexable
// // NewUserAddressView.swift // Garageworks-iOS-Revamp // // Created by Digitalflake Kapil on 21/02/23. // import SwiftUI // AddressSelectionView.swift // Garageworks-iOS-Revamp // // Created by mac on 16/11/22. // struct NewUserAddressView: View { @State var zoom : Float = 15.0 @ObservedObject var viewModel = AddressSelectionObserver() @State var currentLocation : Bool = false @State var address : (text : String,location : String) = ("","") @Binding var shouldShowAddressView : Bool @Binding var addressFlat : String @Binding var name : String @Binding var email : String @Binding var alternateMobile : String @State private var isShowingAddAddressView = false @State var callAddAddress: Int? = nil @State var isfromAddAddressView:Bool = false @Environment(\.presentationMode) var presentationMode @State private var isEdited = false @Binding var addressDetailsAdded : Bool @Binding var isServicableArea: Bool @Binding var dismissCurrentNavView: Bool @Binding var BookingUtilsObject : BookingUtils @State var showNonServiceableAreaPopUp: Bool = true var body: some View { NavigationView{ GeometryReader{ geometry in VStack{ // ZStack{ ZStack(alignment: .top){ GoogleMapsView(zoom : $zoom,location: $viewModel.location, showCurrentLocation: $currentLocation, placeAddress: $viewModel.placeAddress, placePincode: $viewModel.placePincode, placeCity: $viewModel.placeCity, placeArea: $viewModel.placeArea, currentLocation: $viewModel.currentLocation) .onAppear{ viewModel.fetchAddress() } .background() .onChange(of: viewModel.placePincode, perform: { _ in print("Value Changed!") viewModel.searchArea(pincode: viewModel.placePincode) }) VStack(alignment: .trailing){ NavigationLink(destination: PlaceView(location: $viewModel.location, dismissCurrentNavView: $dismissCurrentNavView).navigationBarHidden(true)) { HStack{ Image("search") .foregroundColor(.black) Text("Search Places") .foregroundColor(Color.init(hex: Colors.color_3f)) .font(Font.custom(Fonts.product_medium, size: 12)) } .padding(10) .background(.white) .clipShape(RoundedRectangle(cornerRadius: 20)) .padding(.leading,230) } Spacer() Button{ currentLocation.toggle() currentLocation = true // print("GPS") }label: { Image("gps") .padding(10) .background(.orange) .frame(alignment: .trailing) }.clipShape(Circle()) VStack(spacing:1){ Button{ if(zoom<10){ zoom = 13 } zoom = zoom + 1 // print("add ",zoom) print("Tapped address-----",viewModel.placeAddress) }label: { Image("add") } .padding(10) .background(.white) .cornerRadius(20, corners: [.topLeft, .topRight]) Button{ // print("minus",zoom) if(zoom>22){ zoom = 21 } if(zoom >= 10){ zoom = zoom - 1 } }label: { Image("minus") } .padding(10) .background(.white) .cornerRadius(20, corners: [.bottomLeft, .bottomRight]) } .padding(.bottom,70) } .frame(width: geometry.size.width, height: geometry.size.height*0.8) .padding(15) } .frame(width: geometry.size.width, height: geometry.size.height*0.96,alignment: .top) .cornerRadius(27, corners: [.topLeft, .topRight]) .background(.white) .onTapGesture { self.shouldShowAddressView = false print("shouldShowAddressView",shouldShowAddressView) } //MARK : Address show ZStack{ Spacer() // .frame(width: geometry.size.width, height: geometry.size.height) VStack(){ Text("Your Address") .padding() .font(Font.custom(Fonts.product_medium, size: 15)) .foregroundColor(Color.init(hex: Colors.color_gr2)) .frame(width: geometry.size.width, alignment: .topLeading) .onChange(of: viewModel.isServicableArea, perform: { _ in self.isServicableArea = viewModel.isServicableArea }) Text(viewModel.placeAddress) .padding() .foregroundColor(Color.init(hex: Colors.color_gr2)) .frame(width: geometry.size.width * 0.9, alignment: .topLeading) .background(Color.init(hex: Colors.color_wh)) .cornerRadius(10) .padding(.bottom,5) if shouldShowAddressView { VStack(spacing:10){ TextField("Flat/Building/Street*", text: $addressFlat) .padding() .foregroundColor(Color.init(hex: Colors.color_gr2)) .frame(width: geometry.size.width * 0.9, alignment: .topLeading) .background(Color.init(hex: Colors.color_wh)) .cornerRadius(10) .onChange(of: addressFlat, perform: { _ in print("Value Changed!") if(addressFlat != ""){ isEdited = true } }) Text(viewModel.placeArea) .padding() .foregroundColor(Color.init(hex: Colors.color_gr2)) .frame(width: geometry.size.width * 0.9, alignment:.topLeading) .background(Color.init(hex: Colors.color_wh)) .cornerRadius(10) // hide when existing user TextField("Name*", text: $name) .padding() .foregroundColor(Color.init(hex: Colors.color_gr2)) .frame(width: geometry.size.width * 0.9, alignment: .topLeading) .background(Color.init(hex: Colors.color_wh)) .cornerRadius(10) TextField("Email", text: $email) .padding() .foregroundColor(Color.init(hex: Colors.color_gr2)) .frame(width: geometry.size.width * 0.9, alignment: .topLeading) .background(Color.init(hex: Colors.color_wh)) .cornerRadius(10) TextField("Alternate No.", text: $alternateMobile) .padding() .foregroundColor(Color.init(hex: Colors.color_gr2)) .frame(width: geometry.size.width * 0.9, alignment: .topLeading) .background(Color.init(hex: Colors.color_wh)) .cornerRadius(10) HStack(spacing:5){ RadioButtonGroups { selected in print("Selected work_type is: \(selected)") UserDefaultsManager.storeSelectedAddressType(value: selected) print(UserDefaultsManager.fetchSelectedAddressType()) } .frame(height: 50) .padding(.leading,10) .onAppear{ UserDefaultsManager.storeSelectedAddressType(value: "") } } .frame(width: geometry.size.width * 0.9, alignment: .topLeading) .background(Color.init(hex: Colors.color_wh)) .cornerRadius(10) } } } .background(Color.init(hex: Colors.color_gr), ignoresSafeAreaEdges: .bottom) .cornerRadius(27, corners: [.topLeft, .topRight]) } .frame(width: geometry.size.width, height: geometry.size.height*0.98,alignment: .bottom) // .background(.red) } .frame(width: geometry.size.width,height: geometry.size.height,alignment: .top) } .frame(width: geometry.size.width,height: geometry.size.height) .background(LinearGradient(colors: [.white, Color.init(hex: Colors.color_gr)], startPoint: .top, endPoint: .center), ignoresSafeAreaEdges: .bottom) } // .navigationBarTitle("") .onAppear{ UserDefaultsManager.storeFromWhichView(value: Screens.NewUserAddressView) UserDefaultsManager.storeDismissPlaceView(value: false) UserDefaultsManager.storeDismissServiceAddressFragmentView(value: false) } .onChange(of: viewModel.isServicableArea, perform: {_ in if viewModel.isServicableArea{ isServicableArea = true showNonServiceableAreaPopUp = true }else{ isServicableArea = false showNonServiceableAreaPopUp = false } }) if(!showNonServiceableAreaPopUp){ VStack{ } .frame(width:UIScreen.main.bounds.width ,height:UIScreen.main.bounds.height,alignment: .top) .background(Color.black.opacity(0.5)) .disabled(true) NonServiceableAreaAlertView(isServiceableArea: $showNonServiceableAreaPopUp,viewModel : viewModel) } // .ignoresSafeArea(edges: .bottom) } .navigationBarBackButtonHidden(true) .navigationBarHidden(true) } } //struct NewUserAddressView_Previews: PreviewProvider { // static var previews: some View { // NewUserAddressView(addressDetailsAdded: .constant(false), viewModel: ViewM) // } //} //struct GoToDashboard: View { // var body: some View { //// MARK: new user and Resigtered user dashboard values(area,city) update condition. // if UserDefaultsManager.fetchIsFrom() == true{ // MainHomeView() // } // else{ // MakeView() // } // } //}
Editor is loading...