Exemplo n.º 1
0
        /// <summary>
        /// Toggle see more
        /// </summary>
        /// <param name="button">UIButton</param>
        partial void SeeMore(UIButton button)
        {
            nfloat    imageViewHeight     = ImageViewWrapper.Frame.Height;
            nfloat    imageViewWidth      = ImageViewWrapper.Frame.Width;
            nfloat    deviceWidth         = View.Frame.Width;
            nfloat    secondaryViewHeight = secondaryTableView.Frame.Height;
            const int scaleFactor         = 2;

            seeMoreToggled = !seeMoreToggled;

            //toggle button state
            ButtonSeeMore.SetTitle(seeMoreToggled ? "Hide" : "See More", UIControlState.Normal);
            ButtonSeeMore.Enabled            = false;
            ButtonSeeMore.AccessibilityLabel = seeMoreToggled ? Constants.AccessibilityLabel_SeeMoreHideButton : Constants.AccessibilityLabel_SeeMoreShowButton;

            View.LayoutIfNeeded();

            primaryTableView.ScrollEnabled = seeMoreToggled;

            //force the primary tableview to scroll to the top
            primaryTableView.ScrollToRow(NSIndexPath.Create(new int[] { 0, 0 }), UITableViewScrollPosition.Top, true);

            //animate secondary conditions
            ConstraintSecondaryTableViewTop.Constant    = seeMoreToggled ? secondaryViewHeight : 0;
            ConstraintSecondaryTableViewBottom.Constant = seeMoreToggled ? -secondaryViewHeight : 0;

            //animate tableview into frame
            ConstraintPrimaryTableViewTop.Constant = seeMoreToggled ? -imageViewHeight : 0;

            AnalyzedImageFileNameHeaderLabel.Text = seeMoreToggled ? "Analyzed Image" : "X-Ray Image";

            ConditionsTableViewSource primarySource   = primaryTableView.Source as ConditionsTableViewSource;
            ConditionsTableViewSource secondarySource = secondaryTableView.Source as ConditionsTableViewSource;

            // Set see-more visibility for tableviews
            primarySource.SeeMoreVisible   = seeMoreToggled;
            secondarySource.SeeMoreVisible = seeMoreToggled;

            // Reload each tableview
            primaryTableView.ReloadData();
            secondaryTableView.ReloadData();

            // Set the original label voice over status dependent on see-more visibility
            EnableVoiceOverForViews(originalLabels.ToArray(), seeMoreToggled);

            // Focus to top back-button on see-more toggle
            if (seeMoreToggled)
            {
                UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, this.NavigationItem.LeftBarButtonItem);
            }

            UIView.Animate(
                0.33,
                0,
                UIViewAnimationOptions.CurveEaseIn,
                () =>
            {
                View.LayoutIfNeeded();

                //animate image to top right (this needs to be in the animation closure)
                ImageViewWrapper.Layer.AnchorPoint = seeMoreToggled ? new CGPoint(0, 1) : new CGPoint(0.5, 0.5);
                ImageViewWrapper.Transform         = seeMoreToggled ? CGAffineTransform.MakeScale(0.5F, 0.5F) : CGAffineTransform.MakeScale(1F, 1F);

                OriginalImageWrapper.Layer.AnchorPoint = seeMoreToggled ? new CGPoint(0, 0) : new CGPoint(0.5, 0.5);

                //scale & transformation to move original image to to bottom right
                var originalImageTransformation = CGAffineTransform.MakeScale(0.5F, 0.5F);
                originalImageTransformation.Translate(0.0F, secondaryViewHeight / 2);
                OriginalImageWrapper.Transform = seeMoreToggled ? originalImageTransformation : CGAffineTransform.MakeScale(1F, 1F);

                if (seeMoreToggled)
                {
                    //get the distance from the bottom of the Analyzed Image View Wrapper to the top of the original image view wrapper
                    var distance = OriginalImageWrapper.Frame.Top - ImageViewWrapper.Frame.Bottom;

                    //set the height of the info views to distance
                    AnalyzedImageInfoViewHeightConstraint.Constant = distance;
                    OriginalImageInfoViewHeightConstraint.Constant = distance;

                    //force autolayout to recalculate
                    View.LayoutIfNeeded();

                    //move the info views down
                    AnalyzedImageInfoViewBottomConstraint.Constant = AnalyzedImageInfoView.Frame.Size.Height;
                    OriginalImageInfoViewBottomConstraint.Constant = OriginalImageInfoView.Frame.Size.Height;

                    //scale the font size by a factor of 2
                    //because the imagewrapper is scaled by a factor of 0.5
                    AnalyzedImageFileNameHeaderLabel.Font = UIFont.PreferredHeadline.WithSize(UIFont.PreferredHeadline.PointSize * scaleFactor);
                    AnalyzedImageFileNameLabel.Font       = UIFont.PreferredSubheadline.WithSize(UIFont.PreferredSubheadline.PointSize * scaleFactor);
                    AnalyzedImageDateHeaderLabel.Font     = UIFont.PreferredHeadline.WithSize(UIFont.PreferredHeadline.PointSize * scaleFactor);
                    AnalyzedImageDateLabel.Font           = UIFont.PreferredSubheadline.WithSize(UIFont.PreferredSubheadline.PointSize * scaleFactor);

                    OriginalImageFileNameHeaderLabel.Font = UIFont.PreferredHeadline.WithSize(UIFont.PreferredHeadline.PointSize * scaleFactor);
                    OriginalImageFileNameLabel.Font       = UIFont.PreferredSubheadline.WithSize(UIFont.PreferredSubheadline.PointSize * scaleFactor);
                    OriginalImageDateHeaderLabel.Font     = UIFont.PreferredHeadline.WithSize(UIFont.PreferredHeadline.PointSize * scaleFactor);
                    OriginalImageDateLabel.Font           = UIFont.PreferredSubheadline.WithSize(UIFont.PreferredSubheadline.PointSize * scaleFactor);
                }
                else
                {
                    //remove the constants applied from above
                    //this will revert the height and position to before see more is tapped
                    AnalyzedImageInfoViewBottomConstraint.Constant = 0;
                    AnalyzedImageInfoViewHeightConstraint.Constant = 0;
                    OriginalImageInfoViewBottomConstraint.Constant = 0;
                    OriginalImageInfoViewHeightConstraint.Constant = 0;


                    AnalyzedImageFileNameHeaderLabel.Font = UIFont.PreferredHeadline;
                    AnalyzedImageFileNameLabel.Font       = UIFont.PreferredSubheadline;
                    AnalyzedImageDateHeaderLabel.Font     = UIFont.PreferredHeadline;
                    AnalyzedImageDateLabel.Font           = UIFont.PreferredSubheadline;

                    OriginalImageFileNameHeaderLabel.Font = UIFont.PreferredHeadline;
                    OriginalImageFileNameLabel.Font       = UIFont.PreferredSubheadline;
                    OriginalImageDateHeaderLabel.Font     = UIFont.PreferredHeadline;
                    OriginalImageDateLabel.Font           = UIFont.PreferredSubheadline;
                }
            },
                () =>
            {
                ButtonSeeMore.Enabled = true;
            }
                );
        }
        void ReleaseDesignerOutlets()
        {
            if (AnalyzedImageDateHeaderLabel != null)
            {
                AnalyzedImageDateHeaderLabel.Dispose();
                AnalyzedImageDateHeaderLabel = null;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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