Exemple #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Checkout";

            var footerView = new UIView(new CGRect(0, 0, View.Bounds.Width, 164));

            var creditCardButton = new UIButton(UIButtonType.RoundedRect);

            creditCardButton.SetTitle("Checkout with Credit Card", UIControlState.Normal);
            creditCardButton.BackgroundColor    = UIColor.FromRGBA(0.48f, 0.71f, 0.36f, 1.0f);
            creditCardButton.Layer.CornerRadius = 6;
            creditCardButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            creditCardButton.TranslatesAutoresizingMaskIntoConstraints = false;
            creditCardButton.TouchUpInside += CheckoutWithCreditCard;
            footerView.AddSubview(creditCardButton);

            var webCheckoutButton = new UIButton(UIButtonType.RoundedRect);

            webCheckoutButton.SetTitle("Web Checkout", UIControlState.Normal);
            webCheckoutButton.BackgroundColor    = UIColor.FromRGBA(0.48f, 0.71f, 0.36f, 1.0f);
            webCheckoutButton.Layer.CornerRadius = 6;
            webCheckoutButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            webCheckoutButton.TranslatesAutoresizingMaskIntoConstraints = false;
            webCheckoutButton.TouchUpInside += CheckoutOnWeb;
            footerView.AddSubview(webCheckoutButton);

            var applePayButton = BUYPaymentButton.Create(BUYPaymentButtonType.Buy, BUYPaymentButtonStyle.Black);

            applePayButton.TranslatesAutoresizingMaskIntoConstraints = false;
            applePayButton.TouchUpInside += CheckoutWithApplePay;
            footerView.AddSubview(applePayButton);

            var views = NSDictionary.FromObjectsAndKeys(new [] {
                creditCardButton,
                webCheckoutButton,
                applePayButton
            }, new [] {
                "creditCardButton",
                "webCheckoutButton",
                "applePayButton"
            });

            footerView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-[creditCardButton]-|", 0, null, views));
            footerView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-[webCheckoutButton]-|", 0, null, views));
            footerView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-[applePayButton]-|", 0, null, views));
            footerView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-[creditCardButton(44)]-[webCheckoutButton(==creditCardButton)]-[applePayButton(==creditCardButton)]-|", 0, null, views));

            TableView.TableFooterView = footerView;

            // Prefetch the shop object for Apple Pay
            client.GetShop((shop, error) => {
                this.shop = shop;
            });
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            Title = "Checkout";

            var footerView = new UIView (new CGRect (0, 0, View.Bounds.Width, 164));

            var creditCardButton = new UIButton (UIButtonType.RoundedRect);
            creditCardButton.SetTitle ("Checkout with Credit Card", UIControlState.Normal);
            creditCardButton.BackgroundColor = UIColor.FromRGBA (0.48f, 0.71f, 0.36f, 1.0f);
            creditCardButton.Layer.CornerRadius = 6;
            creditCardButton.SetTitleColor (UIColor.White, UIControlState.Normal);
            creditCardButton.TranslatesAutoresizingMaskIntoConstraints = false;
            creditCardButton.TouchUpInside += CheckoutWithCreditCard;
            footerView.AddSubview (creditCardButton);

            var webCheckoutButton = new UIButton (UIButtonType.RoundedRect);
            webCheckoutButton.SetTitle ("Web Checkout", UIControlState.Normal);
            webCheckoutButton.BackgroundColor = UIColor.FromRGBA (0.48f, 0.71f, 0.36f, 1.0f);
            webCheckoutButton.Layer.CornerRadius = 6;
            webCheckoutButton.SetTitleColor (UIColor.White, UIControlState.Normal);
            webCheckoutButton.TranslatesAutoresizingMaskIntoConstraints = false;
            webCheckoutButton.TouchUpInside += CheckoutOnWeb;
            footerView.AddSubview (webCheckoutButton);

            var applePayButton = BUYPaymentButton.Create (BUYPaymentButtonType.Buy, BUYPaymentButtonStyle.Black);
            applePayButton.TranslatesAutoresizingMaskIntoConstraints = false;
            applePayButton.TouchUpInside += CheckoutWithApplePay;
            footerView.AddSubview (applePayButton);

            var views = NSDictionary.FromObjectsAndKeys (new [] {
                creditCardButton,
                webCheckoutButton,
                applePayButton
            }, new [] {
                "creditCardButton",
                "webCheckoutButton",
                "applePayButton"
            });
            footerView.AddConstraints (NSLayoutConstraint.FromVisualFormat ("H:|-[creditCardButton]-|", 0, null, views));
            footerView.AddConstraints (NSLayoutConstraint.FromVisualFormat ("H:|-[webCheckoutButton]-|", 0, null, views));
            footerView.AddConstraints (NSLayoutConstraint.FromVisualFormat ("H:|-[applePayButton]-|", 0, null, views));
            footerView.AddConstraints (NSLayoutConstraint.FromVisualFormat ("V:|-[creditCardButton(44)]-[webCheckoutButton(==creditCardButton)]-[applePayButton(==creditCardButton)]-|", 0, null, views));

            TableView.TableFooterView = footerView;

            // Prefetch the shop object for Apple Pay
            client.GetShop ((shop, error) => {
                this.shop = shop;
            });
        }