Untitled
unknown
swift
3 years ago
11 kB
8
Indexable
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
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(), id:\.self){ value in
// var index = UserDefaultsManager.fetchCustomerAddressList()[value]
VStack() {
// ZStack{
// NavigationLink(destination: Date_TimeSelectionView().navigationBarHidden(true), tag: 1, selection: $callDate_TimeSelectionView){
// EmptyView()
// }
// }
// .opacity(0.0)
HStack(alignment:.top){
Text(value.address_type ?? "")
.font(Font.custom(Fonts.product_regular, size: 16))
.foregroundColor(Color.init(hex: Colors.color_gr2))
// .tag(value.id)
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(value.google_map ?? "")
.font(Font.custom(Fonts.product_regular, size: 14))
.foregroundColor(Color.init(hex: Colors.color_gr2))
}
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(value.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(value.city ?? "")
.font(Font.custom(Fonts.product_regular, size: 14))
.foregroundColor(Color.init(hex: Colors.color_bk))
.frame(alignment:.leading)
}
}
}
.frame(width:geometry.size.width*0.8,height:geometry.size.height * 0.15,alignment: .center)
.onTapGesture {
self.isProceed = true
// self.$selectedSlot.append(value)
}
// .frame(width:geometry.size.width * 0.8)
.padding()
.cornerRadius(10)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color.init(hex: isProceed == true ? Colors.color_or : Colors.color_stroke_Gray), lineWidth: 0.9))
}
.frame(width:geometry.size.width, height: geometry.size.height * 0.2)
// .buttonStyle(PlainButtonStyle())
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, height:geometry.size.height * 0.1, alignment: .bottom)
.background(Color.init(hex: Colors.color_gr))
.showToast(text: $showText)
}.frame(width:geometry.size.width, height:geometry.size.height * 0.95,alignment: .top)
.background(Color.init(hex: Colors.color_gr))
.cornerRadius(30, corners: [.topLeft, .topRight])
}
.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...