Untitled

mail@pastecode.io avatar
unknown
swift
2 years ago
7.0 kB
2
Indexable
Never
import SwiftUI
import UniformTypeIdentifiers

struct ReferAndEarn: View {
    @StateObject private var referAndEarnObserver = ReferAndEarnObserver(cust_id: UserDefaultsManager.fetchCustomer()?.customer_id ?? "")
//    @StateObject private var ref = ReferAndEarnObserver(cust_id: "")
    var body: some View {
        GeometryReader { geometry in
                        VStack(spacing:0){
                            HStack(spacing:20){
                                Image("Vector 1")
                                    .padding(.leading,10)
                                Text(Strings.label_referandearn)
                                    .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)
                            
                            Image("Refer_img")
                                .resizable()
                                .aspectRatio(contentMode: .fit)
                                .frame(width: geometry.size.width*0.45, height: geometry.size.height*0.24)
                            Text("Earn UPTO ₹1500")
                                .multilineTextAlignment(.center)
                                .foregroundColor(Color.init(hex: Colors.color_bg_F1))
                                .font(Font.custom(Fonts.product_medium, size: 18))
                                .padding(.bottom,20)

                            
                            VStack(alignment: .center,spacing: 20) {
                                Text(referAndEarnObserver.referAndEarnResponse?.campaigns.referral_message ?? "")
                                    .multilineTextAlignment(.center)
                                    .foregroundColor(Color.init(hex: Colors.color_bg_F1))
                                    .font(Font.custom(Fonts.product_medium, size: 18))
                                    .padding(.bottom,10)
                                    .padding(.top,20)

                                Text("Your referral code")
                                    .multilineTextAlignment(.center)
                                    .foregroundColor(Color.init(hex: Colors.color_bg_F1))
                                    .font(Font.custom(Fonts.product_medium, size: 15))
                                
                                HStack{
                                    Text(referAndEarnObserver.referAndEarnResponse?.campaigns.customer_referral_code ?? "")
                                        .frame(width: geometry.size.width * 0.6,height: 50)
                                        .multilineTextAlignment(.center)
                                        .foregroundColor(Color.init(hex: Colors.color_or))
                                        .font(Font.custom(Fonts.product_medium, size: 15))
                                }
                                .background(Color.init(hex: Colors.color_wh))
                                .cornerRadius(10)
                                    .overlay(RoundedRectangle(cornerRadius: 10)
                                                .stroke(style: StrokeStyle(lineWidth: 1, dash: [10.0]))
                                                .foregroundColor(.orange))
                                HStack(spacing:20){
                                    Image("mail")
                                        .resizable()
                                        .aspectRatio(contentMode: .fit)
                                        .frame(width: 40, height: 40)
                                    Image("whatsapp")
                                        .resizable()
                                        .aspectRatio(contentMode: .fit)
                                        .frame(width: 40, height: 40)
                                    Image("facebook")
                                        .resizable()
                                        .aspectRatio(contentMode: .fit)
                                        .frame(width: 40, height: 40)
                                }
                                HStack{
                                    Image("Rectangle 20")
                                        .resizable()
                                        .aspectRatio(contentMode: .fit)
                                        .frame(width: 90, height: 10)
                                    Image("Or")
                                        .resizable()
                                        .aspectRatio(contentMode: .fit)
                                        .frame(width: 20, height: 20)
                                    Image("Rectangle 19")
                                        .resizable()
                                        .aspectRatio(contentMode: .fit)
                                        .frame(width: 90, height: 10)
                                }
                                Button(action: actionSheet) {
                                    HStack{
                                        Text(Strings.label_Invite)
                                            .frame(width: geometry.size.width * 0.9, height: 50)
                                            .font(Font.custom(Fonts.product_medium, size: 15))
                                            .foregroundColor(Color.init(hex: Colors.color_wh))
                                    }
                                }
                                    .background(Color.init(hex: Colors.color_or))
                                    .cornerRadius(10)
                            }
                            .frame(width: geometry.size.width, height:geometry.size.height * 0.45,alignment: .top)
                                .background(Color.init(hex: Colors.color_gr))
                                .cornerRadius(30, corners: [.topLeft, .topRight])
                        }
                        .background(Color.init(hex: Colors.color_wh))
                        .frame(width: geometry.size.width, height:geometry.size.height)
                    }
                    .navigationBarTitle("")
                    .navigationBarBackButtonHidden(true)
                    .navigationBarHidden(true)
    }
    func actionSheet() {
                guard let urlShare = URL(string: "https://developer.apple.com/xcode/swiftui/") else { return }
                let activityVC = UIActivityViewController(activityItems: [urlShare], applicationActivities: nil)
                UIApplication.shared.windows.first?.rootViewController?.present(activityVC, animated: true, completion: nil)
            }
//https://developer.apple.com/xcode/swiftui/
}

struct ReferAndEarn_Previews: PreviewProvider {
    static var previews: some View {
        ReferAndEarn()
    }
}