示例#1
0
        private void InitializeAddressInfoLayout()
        {
            mAddressInfoLayout = new Image () {
                WidthRequest = MyDevice.GetScaledSize(600),
                HeightRequest = MyDevice.GetScaledSize(214),
                /*CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false,*/
                Source = "SettingsPage_AddressInfoBackground.png"
            };

            var informationLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (400),
                HeightRequest = MyDevice.GetScaledSize(52),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor = Color.FromRgb(189,82,121),
                Text = "You have selected the following:",
                FontSize = MyDevice.FontSizeSmall
            };

            var regionLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (509),
                HeightRequest = MyDevice.GetScaledSize(30),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor = Color.FromRgb(98,98,98),
                Text = "JVC / Serviced by Bluemart",
                FontSize = MyDevice.FontSizeSmall
            };

            var locationLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (509),
                HeightRequest = MyDevice.GetScaledSize(25),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor = Color.FromRgb(98,98,98),
                Text = "Location: JVC",
                FontSize = MyDevice.FontSizeSmall
            };

            var changeLocationHint = new Label () {
                WidthRequest = MyDevice.GetScaledSize (600),
                HeightRequest = MyDevice.GetScaledSize(70),
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor = Color.FromRgb(98,98,98),
                Text = "< TAP TO CHANGE LOCATION >",
                FontSize = MyDevice.FontSizeMedium
            };

            var addAddressButton = new Label () {
                WidthRequest = MyDevice.GetScaledSize (215),
                HeightRequest = MyDevice.GetScaledSize(62),
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.Center,
                BackgroundColor = Color.FromRgb(132,178,98),
                TextColor = Color.White,
                Text = "ADD NEW\nDELIVERY ADDRESS",
                FontSize = MyDevice.FontSizeMicro
            };

            var continueToShop = new Label () {
                WidthRequest = MyDevice.GetScaledSize (215),
                HeightRequest = MyDevice.GetScaledSize(62),
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.Center,
                BackgroundColor = Color.FromRgb(132,178,98),
                TextColor = Color.White,
                Text = "CONTINUE\nTO SHOP",
                FontSize = MyDevice.FontSizeMicro
            };

            var browseAddressInfoLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (500),
                HeightRequest = MyDevice.GetScaledSize(62),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor = Color.FromRgb(98,98,98),
                Text = "Your Addresses:",
                FontSize = MyDevice.FontSizeSmall
            };

            var addAddressTapRecognizer = new TapGestureRecognizer ();
            addAddressTapRecognizer.Tapped += (sender, e) => {
                mParent.LoadAddAddress();
            };
            addAddressButton.GestureRecognizers.Add (addAddressTapRecognizer);

            var addressStackLayout = new StackLayout {
                Orientation = StackOrientation.Vertical,
                Padding = 0,
                Spacing = 0
            };

            string region = mUserModel.GetUser().ActiveRegion;
            int shopNumber = RegionHelper.DecideShopNumber (region);
            string shopName = RegionHelper.DecideShopName (shopNumber);

            regionLabel.Text = region + " / Serviced by Bluemart";
            locationLabel.Text = "Location: "+shopName;
            browseAddressInfoLabel.Text = "Your Addresses:";

            var addressList = mAddressModel.GetAddressList (shopNumber);

            foreach (var address in addressList) {
                if (address != null) {
                    if (address.IsActive) {
                        mActiveAddressCell = new AddressCell (address, this);
                        addressStackLayout.Children.Add (mActiveAddressCell.View);
                    }
                    else
                        addressStackLayout.Children.Add (new AddressCell (address, this).View);
                }
            }

            var changeAddressTapRecognizer = new TapGestureRecognizer ();
            changeAddressTapRecognizer.Tapped += (sender, e) => {
                mParent.Navigation.PopAsync();
            };
            changeLocationHint.GestureRecognizers.Add (changeAddressTapRecognizer);

            var continueToShopTapRecognizer = new TapGestureRecognizer ();
            continueToShopTapRecognizer.Tapped += (sender, e) => {
                mParent.SwitchTab("BrowseCategories");
            };
            continueToShop.GestureRecognizers.Add (continueToShopTapRecognizer);

            var addressScrollView = new ScrollView {
                Orientation = ScrollOrientation.Vertical,
                Content = addressStackLayout
            };

            mMidLayout.Children.Add (mAddressInfoLayout,
                Constraint.RelativeToView (menuIcon, (p, sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (mTopLayout, (p, sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(25);
                })
            );

            mMidLayout.Children.Add (informationLabel,
                Constraint.RelativeToView (mAddressInfoLayout, (p, sibling) => {
                    return sibling.Bounds.Left + MyDevice.GetScaledSize(67);
                }),
                Constraint.RelativeToView (mAddressInfoLayout, (p, sibling) => {
                    return sibling.Bounds.Top + MyDevice.GetScaledSize(12);
                })
            );

            mMidLayout.Children.Add (regionLabel,
                Constraint.RelativeToView (informationLabel, (p, sibling) => {
                    return sibling.Bounds.Left + MyDevice.GetScaledSize(5);
                }),
                Constraint.RelativeToView (informationLabel, (p, sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(10);
                })
            );

            mMidLayout.Children.Add (locationLabel,
                Constraint.RelativeToView (regionLabel, (p, sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (regionLabel, (p, sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(4);
                })
            );

            mMidLayout.Children.Add (changeLocationHint,
                Constraint.RelativeToView (mAddressInfoLayout, (p, sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (mAddressInfoLayout, (p, sibling) => {
                    return sibling.Bounds.Bottom - MyDevice.GetScaledSize(70);
                })
            );

            mMidLayout.Children.Add (addAddressButton,
                Constraint.RelativeToView (mAddressInfoLayout, (p, sibling) => {
                    return sibling.Bounds.Left + MyDevice.GetScaledSize(60);
                }),
                Constraint.RelativeToView (mAddressInfoLayout, (p, sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(20);
                })
            );

            mMidLayout.Children.Add (continueToShop,
                Constraint.RelativeToView (addAddressButton, (p, sibling) => {
                    return sibling.Bounds.Right + MyDevice.GetScaledSize(60);
                }),
                Constraint.RelativeToView (addAddressButton, (p, sibling) => {
                    return sibling.Bounds.Top;
                })
            );

            mMidLayout.Children.Add (browseAddressInfoLabel,
                Constraint.RelativeToView (mAddressInfoLayout, (p, sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (addAddressButton, (p, sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(20);
                })
            );

            double addressHeight = MyDevice.GetScaledSize (117)*(addressStackLayout.Children.Count);

            if (addressHeight > MyDevice.GetScaledSize (400))
                addressHeight = MyDevice.GetScaledSize (400);

            mMidLayout.Children.Add (addressScrollView,
                Constraint.RelativeToView (browseAddressInfoLabel, (parent,sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (browseAddressInfoLabel, (parent,sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(16);
                }),
                Constraint.Constant(MyDevice.GetScaledSize(600)),
                Constraint.Constant(addressHeight)
            );
        }
示例#2
0
 public void SwitchActiveAddress(AddressCell address)
 {
     mActiveAddressCell.mActiveAddressImage.IsVisible = true;
     mActiveAddressCell = address;
     mActiveAddressCell.mActiveAddressImage.IsVisible = false;
 }