예제 #1
0
        /// <summary>
        /// Gets the view for header.
        /// </summary>
        /// <returns>The view for header.</returns>
        /// <param name="tableView">Table view.</param>
        /// <param name="section">Section.</param>
        public override UIView GetViewForHeader(UITableView tableView, nint section)
        {
            var formsView = _settingsView.Model.GetSectionHeaderView((int)section);

            if (formsView != null)
            {
                return(GetNativeSectionHeaderFooterView(formsView, tableView, true));
            }


            var headerView = _tableView.DequeueReusableHeaderFooterView(SettingsViewRenderer.TextHeaderId) as TextHeaderView;

            if (headerView is null)
            {
                // for HotReload
                return(new UIView());
            }

            headerView.Label.Text      = _settingsView.Model.GetSectionTitle((int)section);
            headerView.Label.TextColor = _settingsView.HeaderTextColor == Color.Default ?
                                         UIColor.Gray : _settingsView.HeaderTextColor.ToUIColor();
            headerView.Label.Font = FontUtility.CreateNativeFont(_settingsView.HeaderFontFamily, (float)_settingsView.HeaderFontSize, _settingsView.HeaderFontAttributes);
            //UIFont.SystemFontOfSize((nfloat)_settingsView.HeaderFontSize);
            headerView.BackgroundView.BackgroundColor = _settingsView.HeaderBackgroundColor.ToUIColor();
            headerView.Label.Padding = _settingsView.HeaderPadding.ToUIEdgeInsets();

            var sec = _settingsView.Model.GetSection((int)section);

            if (sec.HeaderHeight != -1 || _settingsView.HeaderHeight != -1)
            {
                headerView.SetVerticalAlignment(_settingsView.HeaderTextVerticalAlign);
            }

            return(headerView);
        }
예제 #2
0
        /// <summary>
        /// Gets the view for footer.
        /// </summary>
        /// <returns>The view for footer.</returns>
        /// <param name="tableView">Table view.</param>
        /// <param name="section">Section.</param>
        public override UIView GetViewForFooter(UITableView tableView, nint section)
        {
            var formsView = _settingsView.Model.GetSectionFooterView((int)section);

            if (formsView != null)
            {
                return(GetNativeSectionHeaderFooterView(formsView, tableView, false));
            }

            var text = _settingsView.Model.GetFooterText((int)section);

            if (string.IsNullOrEmpty(text))
            {
                return(new UIView(CGRect.Empty));
            }

            var footerView = _tableView.DequeueReusableHeaderFooterView(SettingsViewRenderer.TextFooterId) as TextFooterView;

            if (footerView is null)
            {
                // for HotReload
                return(new UIView());
            }

            footerView.Label.Text      = text;
            footerView.Label.TextColor = _settingsView.FooterTextColor == Color.Default ?
                                         UIColor.Gray : _settingsView.FooterTextColor.ToUIColor();
            footerView.Label.Font = FontUtility.CreateNativeFont(_settingsView.FooterFontFamily, (float)_settingsView.FooterFontSize, _settingsView.FooterFontAttributes);
            //UIFont.SystemFontOfSize((nfloat)_settingsView.FooterFontSize);
            footerView.BackgroundView.BackgroundColor = _settingsView.FooterBackgroundColor.ToUIColor();
            footerView.Label.Padding = _settingsView.FooterPadding.ToUIEdgeInsets();

            return(footerView);
        }
        void UpdateValueTextFont()
        {
            if (ValueLabel.Font is null)
            {
                return; // for HotReload
            }
            var family = _LabelCell.ValueTextFontFamily ?? CellParent.CellValueTextFontFamily;
            var attr   = _LabelCell.ValueTextFontAttributes ?? CellParent.CellValueTextFontAttributes;

            if (_LabelCell.ValueTextFontSize > 0)
            {
                ValueLabel.Font = FontUtility.CreateNativeFont(family, (float)_LabelCell.ValueTextFontSize, attr);
            }
            else if (CellParent != null)
            {
                ValueLabel.Font = FontUtility.CreateNativeFont(family, (float)CellParent.CellValueTextFontSize, attr);
            }
        }
        void UpdateDescriptionFont()
        {
            if (DescriptionLabel is null)
            {
                return; // for HotReload
            }
            var family = CellBase.DescriptionFontFamily ?? CellParent.CellDescriptionFontFamily;
            var attr   = CellBase.DescriptionFontAttributes ?? CellParent.CellDescriptionFontAttributes;

            if (CellBase.DescriptionFontSize > 0)
            {
                DescriptionLabel.Font = FontUtility.CreateNativeFont(family, (float)CellBase.DescriptionFontSize, attr);
            }
            else if (CellParent != null)
            {
                DescriptionLabel.Font = FontUtility.CreateNativeFont(family, (float)CellParent.CellDescriptionFontSize, attr);
            }
        }
        void UpdateValueTextFont()
        {
            var family = _EntryCell.ValueTextFontFamily ?? CellParent.CellValueTextFontFamily;
            var attr   = _EntryCell.ValueTextFontAttributes ?? CellParent.CellValueTextFontAttributes;

            if (_EntryCell.ValueTextFontSize > 0)
            {
                ValueField.Font = FontUtility.CreateNativeFont(family, (float)_EntryCell.ValueTextFontSize, attr);
            }
            else if (CellParent != null)
            {
                ValueField.Font = FontUtility.CreateNativeFont(family, (float)CellParent.CellValueTextFontSize, attr);
            }
            //make the view height fit font size
            var contentH = ValueField.IntrinsicContentSize.Height;
            var bounds   = ValueField.Bounds;

            ValueField.Bounds    = new CoreGraphics.CGRect(0, 0, bounds.Width, contentH);
            _FieldWrapper.Bounds = new CoreGraphics.CGRect(0, 0, _FieldWrapper.Bounds.Width, contentH);
        }