Exemplo n.º 1
0
        void ReleaseDesignerOutlets()
        {
            if (IntroductionLabel != null)
            {
                IntroductionLabel.Dispose();
                IntroductionLabel = null;
            }

            if (AboutLabel != null)
            {
                AboutLabel.Dispose();
                AboutLabel = null;
            }

            if (LearnMoreButton != null)
            {
                LearnMoreButton.Dispose();
                LearnMoreButton = null;
            }

            if (FooterLabel != null)
            {
                FooterLabel.Dispose();
                FooterLabel = null;
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);

            // setup the news title
            NewsTitle = new UILabel( );
            NewsTitle.Layer.AnchorPoint = CGPoint.Empty;
            View.AddSubview(NewsTitle);
            ControlStyling.StyleUILabel(NewsTitle, ControlStylingConfig.Font_Bold, ControlStylingConfig.Large_FontSize);
            NewsTitle.Text = NewsItem.Title;
            NewsTitle.SizeToFit( );

            // populate the details view with this news item.
            NewsDescription = new UITextView( );
            NewsDescription.Layer.AnchorPoint = CGPoint.Empty;
            View.AddSubview(NewsDescription);
            NewsDescription.Text               = NewsItem.Description;
            NewsDescription.BackgroundColor    = UIColor.Clear;
            NewsDescription.TextColor          = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.Label_TextColor);
            NewsDescription.Font               = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Light, ControlStylingConfig.Small_FontSize);
            NewsDescription.TextContainerInset = UIEdgeInsets.Zero;
            NewsDescription.TextContainer.LineFragmentPadding = 0;
            NewsDescription.Editable = false;

            // we should always assume images are in cache. If they aren't, show a placeholder.
            // It is not our job to download them.
            ImageBanner = new UIImageView( );
            ImageBanner.Layer.AnchorPoint = CGPoint.Empty;

            // scale the image down to fit the contents of the window, but allow cropping.
            ImageBanner.BackgroundColor = UIColor.Clear;
            ImageBanner.ContentMode     = UIViewContentMode.ScaleAspectFill;
            ImageBanner.ClipsToBounds   = true;

            View.AddSubview(ImageBanner);

            // do we have the real image?
            if (TryLoadHeaderImage(NewsItem.ImageName) == false)
            {
                // no, so use a placeholder and request the actual image
                ImageBanner.Image = new UIImage(NSBundle.MainBundle.BundlePath + "/" + PrivateGeneralConfig.NewsDetailsPlaceholder);

                // resize the image to fit the width of the device
                nfloat imageAspect = PrivateNewsConfig.NewsMainAspectRatio;
                ImageBanner.Frame = new CGRect(0, 0, View.Bounds.Width, View.Bounds.Width * imageAspect);

                // request!
                string widthParam = string.Format("&width={0}", View.Bounds.Width * UIScreen.MainScreen.Scale);
                string requestUrl = Rock.Mobile.Util.Strings.Parsers.AddParamToURL(NewsItem.ImageURL, widthParam);

                FileCache.Instance.DownloadFileToCache(requestUrl, NewsItem.ImageName, null,
                                                       delegate
                {
                    Rock.Mobile.Threading.Util.PerformOnUIThread(delegate {
                        if (IsVisible == true)
                        {
                            TryLoadHeaderImage(NewsItem.ImageName);
                        }
                    });
                });
            }

            DetailsBannerButton = new UIButton( );
            View.AddSubview(DetailsBannerButton);

            DetailsBannerButton.Frame = ImageBanner.Frame;

            DetailsBannerButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                Handle_LearnMore( );
            };

            // if we're in developer mode, add the start / end times for this promotion
            if (MobileApp.Shared.Network.RockLaunchData.Instance.Data.DeveloperModeEnabled == true)
            {
                NewsDescription.Text += NewsItem.GetDeveloperInfo( );
            }


            // finally setup the Learn More button
            LearnMoreButton = UIButton.FromType(UIButtonType.System);
            View.AddSubview(LearnMoreButton);
            LearnMoreButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                Handle_LearnMore( );
            };

            // if there's no URL associated with this news item, hide the learn more button.
            if (string.IsNullOrWhiteSpace(NewsItem.ReferenceURL) == true)
            {
                LearnMoreButton.Hidden = true;
            }
            ControlStyling.StyleButton(LearnMoreButton, NewsStrings.LearnMore, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);
            LearnMoreButton.SizeToFit( );
        }