Beispiel #1
0
        /// <summary>
        /// Initializes the table views
        /// Primary table view refers to the table view to the left with the 14 conditions
        /// Secondary table view refers to the table view to the right with 2 condition
        /// The secondary table view contains the conditions located at index 1 and 2 from the conditions outputted by the model
        /// </summary>
        private void SetTableViews()
        {
            this.OnClick = HandleCellClick;

            //grab references to table view in storyboard
            primaryTableView   = TableViewConditionsList;
            secondaryTableView = SecondaryTableViewConditionsList;

            nfloat secondaryTableViewHeight = secondaryTableView.Frame.Height;

            primaryTableView.RegisterNibForCellReuse(UINib.FromName(ConditionViewCell.XIBKey, NSBundle.MainBundle), ConditionViewCell.CellReuseId);
            primaryTableView.RegisterNibForCellReuse(UINib.FromName(ConditionViewCell.PrimaryXIBKey, NSBundle.MainBundle), ConditionViewCell.PrimaryCellReuseId);
            secondaryTableView.RegisterNibForCellReuse(UINib.FromName(ConditionViewCell.XIBKey, NSBundle.MainBundle), ConditionViewCell.CellReuseId);

            // Set TableView source
            primaryTableView.Source = new ConditionsTableViewSource(conditionResults, OnClick, ConditionsTableViewSource.TableType.Primary, secondaryTableViewHeight);
            primaryTableView.ReloadData();

            //NOTE: we are assuming that there will be at least 3 conditions to display
            ConditionResult[] conditionsResultsSubset = { conditionResults[1], conditionResults[2] };

            ConditionsTableViewSource secondarySource = new ConditionsTableViewSource(conditionsResultsSubset, OnClick, ConditionsTableViewSource.TableType.Secondary, secondaryTableViewHeight);

            // See more
            secondaryTableView.Source = secondarySource;
            secondaryTableView.ReloadData();

            //initially disable scrolling
            primaryTableView.ScrollEnabled   = false;
            secondaryTableView.ScrollEnabled = false;

            //set borders for tableviews
            primaryTableView.Layer.BorderWidth   = borderWidth;
            primaryTableView.Layer.BorderColor   = Constants.LightGrey.CGColor;
            secondaryTableView.Layer.BorderWidth = borderWidth;
            secondaryTableView.Layer.BorderColor = Constants.LightGrey.CGColor;
        }
Beispiel #2
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;
            }
                );
        }