From 48ba446936b51fffafa7c3600c0dadc6ac0e8c20 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期五, 10 七月 2020 10:52:13 +0800 Subject: [PATCH] 2020-07-10-01 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/ListViewLayoutControls/VerticalListControl.cs | 122 ++++++++++++++++++++++++++++++++++++++-- 1 files changed, 115 insertions(+), 7 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/ListViewLayoutControls/VerticalListControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/ListViewLayoutControls/VerticalListControl.cs index df9a338..282f443 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/ListViewLayoutControls/VerticalListControl.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/ListViewLayoutControls/VerticalListControl.cs @@ -15,6 +15,29 @@ /// 琛屼箣闂寸殑闂磋窛 /// </summary> public int rowSpace = 0; + /// <summary> + /// 鏈�澶ч珮搴� + /// </summary> + private int maxHeight = -1; + /// <summary> + /// 涓�涓病浠�涔堢敤鐨勪笢瑗� + /// </summary> + private FrameLayout frameBackTemp = null; + /// <summary> + /// 鑷畾涔夌殑鑾峰彇瀛愭帶浠朵釜鏁� + /// </summary> + public new int ChildrenCount + { + get + { + int count = base.ChildrenCount; + if (frameBackTemp != null && frameBackTemp.Parent != null) + { + count--; + } + return count < 0 ? 0 : count; + } + } #endregion @@ -26,7 +49,14 @@ /// <param name="i_rowSpace">琛屼箣闂寸殑闂磋窛(杩欎釜鍊兼槸涓庤鎺т欢缁戝畾涓�璧蜂娇鐢ㄧ殑)</param> public VerticalListControl(int i_rowSpace = 0) { - rowSpace = Application.GetRealHeight(i_rowSpace); + this.rowSpace = Application.GetRealHeight(i_rowSpace); +#if iOS + //鑷姩鍋忕Щ鍙栨秷 + if (UIKit.UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) + { + (this.uiView as UIKit.UIScrollView).ContentInsetAdjustmentBehavior = UIKit.UIScrollViewContentInsetAdjustmentBehavior.Never; + } +#endif } #endregion @@ -47,28 +77,106 @@ view.Height += rowSpace; } } + if (maxHeight == -1) + { + maxHeight = this.Height; + } } #endregion #region 鈻� 璋冩暣鐪熷疄楂樺害_______________________ /// <summary> + /// 杩樺師楂樺害 + /// </summary> + public void RecoverHeight() + { + if (this.maxHeight != -1) + { + this.Height = this.maxHeight; +#if iOS + this.ReLocation(); +#endif + } + } + + /// <summary> /// 璋冩暣鎺т欢鐪熷疄楂樺害(鍙拡瀵硅鎺т欢閮芥槸鐩稿悓楂樺害鐨�,楂樺害鍙細鍑忓皯,涓嶄細澧炲姞) /// </summary> /// <param name="bottomSpace">搴曢儴绌虹櫧闂磋窛(鐪熷疄鍊�)</param> - public void AdjustRealHeight(int bottomSpace) + /// <param name="addSpace">褰撶湡瀹為珮搴﹁秴杩囧師鏈夐珮搴︽椂,鏄惁娣诲姞绌虹櫧</param> + public void AdjustRealHeight(int bottomSpace, bool addSpace = true) + { + //鎬讳箣,鍏堥噸缃嚦鏈�澶� + this.RecoverHeight(); + + int count = this.ChildrenCount; + if (count <= 0) + { + frameBackTemp?.RemoveFromParent(); + frameBackTemp = null; + return; + } + + //璋冩暣鍒楄〃鎺т欢鐨勯珮搴� + var realHeight = count * this.GetChildren(0).Height + bottomSpace; + if (realHeight < this.Height) + { + frameBackTemp?.RemoveFromParent(); + frameBackTemp = null; + //缂╁皬鎺т欢楂樺害 + this.Height = realHeight; +#if iOS + this.ReLocation(); +#endif + } + else if (addSpace == true && bottomSpace > 0 && realHeight > this.maxHeight) + { + frameBackTemp?.RemoveFromParent(); + + frameBackTemp = new FrameLayout(); + frameBackTemp.Height = bottomSpace; + this.AddChidren(frameBackTemp); + } + } + + /// <summary> + /// 閽堝搴曢儴鐐瑰嚮鎸夐挳,璋冩暣鎺т欢鐪熷疄楂樺害 + /// </summary> + /// <param name="bottomSpace">搴曢儴绌虹櫧闂磋窛(鐪熷疄鍊�,濡傛灉鍒楄〃鎺т欢鐪熷疄楂樺害娌℃湁瓒呰繃鏃�,浣跨敤姝ゅ��)</param> + /// <param name="correctionsValue">Y杞磋ˉ姝e��(鐪熷疄鍊�,鍒楄〃鎺т欢涓嶅湪bodyFramelayout鐨勬椂鍊欎娇鐢�)</param> + public void AdjustRealHeightByBottomButton(int bottomSpace, int correctionsValue = 0) { if (this.ChildrenCount == 0) { + frameBackTemp?.RemoveFromParent(); + frameBackTemp = null; + if (maxHeight != -1) + { + //杩樺師涓烘渶澶ч珮搴� + this.Height = maxHeight; +#if iOS + this.ReLocation(); +#endif + } return; } - //璋冩暣鍒楄〃鎺т欢鐨勯珮搴� - var realHeight = this.ChildrenCount * this.GetChildren(0).Height + bottomSpace; - if (realHeight < this.Height) + var realHeight = this.ChildrenCount * this.GetChildren(0).Height + this.Y + correctionsValue; + var btnTemp = new BottomClickButton(); + if (btnTemp.Yaxis >= realHeight) { - //缂╁皬鎺т欢楂樺害 - this.Height = realHeight; + //娌℃湁瓒呰繃 + this.AdjustRealHeight(bottomSpace); + return; } + //瓒呰繃鏃�,閲嶇疆鑷虫渶澶� + this.RecoverHeight(); + + //娣诲姞涓存椂鎺т欢,鐩磋嚦鍙互婊戝姩瓒呰繃搴曢儴鎸夐挳 + frameBackTemp?.RemoveFromParent(); + frameBackTemp = new FrameLayout(); + frameBackTemp.Height = ControlCommonResourse.BodyFrameHeight - btnTemp.Yaxis + bottomSpace; + this.AddChidren(frameBackTemp); } #endregion -- Gitblit v1.8.0