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

            //Hide MT Buttons
            //Ad1MTButton.Alpha = 0f;
            //Ad2MTButton.Alpha = 0f;
            //Ad3MTButton.Alpha = 0f;
            //Ad4MTButton.Alpha = 0f;

            var ad1 = DataObject.Ads[0];

            //var ad2 = DataObject.Ads[1];
            //var ad3 = DataObject.Ads[2];
            //var ad4 = DataObject.Ads[3];

            //Hide text button if broker doesn't have a cell phone
            if (string.IsNullOrEmpty(ad1.BrokerCellPhone))
            {
                Ad1MessageButton.Alpha = 0f;
            }
            ;
            //if (string.IsNullOrEmpty(ad2.BrokerCellPhone))
            //{
            //	Ad2MessageButton.Alpha = 0f;
            //};
            //if (string.IsNullOrEmpty(ad3.BrokerCellPhone))
            //{
            //	Ad3MessageButton.Alpha = 0f;
            //};
            //if (string.IsNullOrEmpty(ad4.BrokerCellPhone))
            //{
            //	Ad4MessageButton.Alpha = 0f;
            //};



            AdImage1.SetImage(
                url: new NSUrl(ad1.ImageURL),
                placeholder: UIImage.FromBundle("ad_placeholder.jpg")
                );

            AdName1.Text  = ad1.Name;
            AdPrice1.Text = ad1.Price;



            Ad1NameButton.SetTitle(ad1.Name, UIControlState.Normal);


            //		AdImage2.SetImage(
            //	url: new NSUrl(ad2.ImageURL),
            //	placeholder: UIImage.FromBundle("ad_placeholder.jpg")
            //);

            //		AdName2.Text = ad2.Name;
            //		AdPrice2.Text = ad2.Price;


            //		Ad2NameButton.SetTitle(ad2.Name, UIControlState.Normal);


            //		AdImage3.SetImage(
            //	url: new NSUrl(ad3.ImageURL),
            //	placeholder: UIImage.FromBundle("ad_placeholder.jpg")
            //);

            //		AdName3.Text = ad3.Name;
            //		AdPrice3.Text = ad3.Price;


            //		Ad3NameButton.SetTitle(ad3.Name, UIControlState.Normal);


            //		AdImage4.SetImage(
            //	url: new NSUrl(ad4.ImageURL),
            //	placeholder: UIImage.FromBundle("ad_placeholder.jpg")
            //);

            //		AdName4.Text = ad4.Name;
            //		AdPrice4.Text = ad4.Price;


            //		Ad4NameButton.SetTitle(ad4.Name, UIControlState.Normal);

            var labelAttribute = new UIStringAttributes
            {
                Font = UIFont.BoldSystemFontOfSize(18)
            };
            var brokerLabelAttribute = new UIStringAttributes
            {
                Font = UIFont.BoldSystemFontOfSize(15)
            };

            var valueAttribute = new UIStringAttributes
            {
                Font            = UIFont.SystemFontOfSize(15),
                ForegroundColor = UIColor.Blue
            };

            Ad1TeaserLabel.Text = ad1.Teaser == string.Empty ? "Inquire for Details" : ad1.Teaser;
            //Ad2TeaserLabel.Text = ad2.Teaser == string.Empty ? "Inquire for Details" : ad2.Teaser;
            //Ad3TeaserLabel.Text = ad3.Teaser == string.Empty ? "Inquire for Details" : ad3.Teaser;
            //Ad4TeaserLabel.Text = ad4.Teaser == string.Empty ? "Inquire for Details" : ad4.Teaser;

            #region attributed labels
            Ad1BrokerButton.SetAttributedTitle(HelperMethods.GetBrokerAttributedString(ad1, brokerLabelAttribute, valueAttribute), UIControlState.Normal);
            //Ad2BrokerButton.SetAttributedTitle(HelperMethods.GetBrokerAttributedString(ad2, brokerLabelAttribute, valueAttribute), UIControlState.Normal);
            //Ad3BrokerButton.SetAttributedTitle(HelperMethods.GetBrokerAttributedString(ad3, brokerLabelAttribute, valueAttribute), UIControlState.Normal);
            //Ad4BrokerButton.SetAttributedTitle(HelperMethods.GetBrokerAttributedString(ad4, brokerLabelAttribute, valueAttribute), UIControlState.Normal);

            Ad1RegistrationLabel.AttributedText = HelperMethods.GetRegistrationAttributedString(ad1, labelAttribute);
            //Ad2RegistrationLabel.AttributedText = HelperMethods.GetRegistrationAttributedString(ad2, labelAttribute);
            //Ad3RegistrationLabel.AttributedText = HelperMethods.GetRegistrationAttributedString(ad3, labelAttribute);
            //Ad4RegistrationLabel.AttributedText = HelperMethods.GetRegistrationAttributedString(ad4, labelAttribute);

            Ad1SerialLabel.AttributedText = HelperMethods.GetSerialAttributedString(ad1, labelAttribute);
            //Ad2SerialLabel.AttributedText = HelperMethods.GetSerialAttributedString(ad2, labelAttribute);
            //Ad3SerialLabel.AttributedText = HelperMethods.GetSerialAttributedString(ad3, labelAttribute);
            //Ad4SerialLabel.AttributedText = HelperMethods.GetSerialAttributedString(ad4, labelAttribute);

            Ad1TimeLabel.AttributedText = HelperMethods.GetTotalTimeAttributedString(ad1, labelAttribute);
            //Ad2TimeLabel.AttributedText = HelperMethods.GetTotalTimeAttributedString(ad2, labelAttribute);
            //Ad3TimeLabel.AttributedText = HelperMethods.GetTotalTimeAttributedString(ad3, labelAttribute);
            //Ad4TimeLabel.AttributedText = HelperMethods.GetTotalTimeAttributedString(ad4, labelAttribute);

            Ad1LocationLabel.AttributedText = HelperMethods.GetLocationAttributedString(ad1, labelAttribute);
            //Ad2LocationLabel.AttributedText = HelperMethods.GetLocationAttributedString(ad2, labelAttribute);
            //Ad3LocationLabel.AttributedText = HelperMethods.GetLocationAttributedString(ad3, labelAttribute);
            //Ad4LocationLabel.AttributedText = HelperMethods.GetLocationAttributedString(ad4, labelAttribute);
            #endregion

            #region price changed
            if (!HelperMethods.ShowPriceChangedLabel(ad1.PriceLastUpdated))
            {
                Ad1PriceChangeLabel.Alpha = 0f;
            }
            //if (!HelperMethods.ShowPriceChangedLabel(ad2.PriceLastUpdated))
            //{
            //	Ad2PriceChangeLabel.Alpha = 0f;

            //}
            //if (!HelperMethods.ShowPriceChangedLabel(ad3.PriceLastUpdated))
            //{
            //	Ad3PriceChangeLabel.Alpha = 0f;

            //}
            //if (!HelperMethods.ShowPriceChangedLabel(ad4.PriceLastUpdated))
            //{
            //	Ad4PriceChangeLabel.Alpha = 0f;
            //}
            #endregion



            //Set initial state of like buttons
            if (DataObject.Ads[0].IsLiked)
            {
                HelperMethods.SetInitialLikeButtonState(AdLike1, DataObject.Ads[0]);
            }

            //if (DataObject.Ads[1].IsLiked)
            //{
            //	HelperMethods.SetInitialLikeButtonState(AdLike2, DataObject.Ads[1]);
            //}

            //if (DataObject.Ads[2].IsLiked)
            //{
            //	HelperMethods.SetInitialLikeButtonState(AdLike3, DataObject.Ads[2]);
            //}

            //if (DataObject.Ads[3].IsLiked)
            //{
            //	HelperMethods.SetInitialLikeButtonState(AdLike4, DataObject.Ads[3]);
            //}

            //webview image tap gestures
            AdImage1.UserInteractionEnabled = true;
            AdImage2.UserInteractionEnabled = true;
            AdImage3.UserInteractionEnabled = true;
            AdImage4.UserInteractionEnabled = true;

            //UITapGestureRecognizer tapGesture1 = new UITapGestureRecognizer(TapImageAction1);
            //AdImage1.AddGestureRecognizer(tapGesture1);
            //UITapGestureRecognizer tapGesture2 = new UITapGestureRecognizer(TapImageAction2);
            //AdImage2.AddGestureRecognizer(tapGesture2);
            //UITapGestureRecognizer tapGesture3 = new UITapGestureRecognizer(TapImageAction3);
            //AdImage3.AddGestureRecognizer(tapGesture3);
            //UITapGestureRecognizer tapGesture4 = new UITapGestureRecognizer(TapImageAction4);
            //AdImage4.AddGestureRecognizer(tapGesture4);

            tapGesture1 = new UITapGestureRecognizer(TapImageAction1);
            tapGesture2 = new UITapGestureRecognizer(TapImageAction2);
            tapGesture3 = new UITapGestureRecognizer(TapImageAction3);
            tapGesture4 = new UITapGestureRecognizer(TapImageAction4);

            int currentIndex = this.DataObject.MagazinePageIndex;
            int totalPages   = this.DataObject.TotalPages;

            PageIndicator.SetIndicatorState(currentIndex, totalPages);

            //Randomly load banmanpro
            //HelperMethods.LoadWebBanManPro(this.View);
        }