@@ -25,11 +25,8 @@ public abstract class Layout : View, Microsoft.Maui.ILayout, IList<IView>, IPadd
2525
2626 public bool IsReadOnly => ( ( ICollection < IView > ) _children ) . IsReadOnly ;
2727
28- IReadOnlyList < IView > IContainer . Children => _children . AsReadOnly ( ) ;
29-
3028 public IView this [ int index ] { get => _children [ index ] ; set => _children [ index ] = value ; }
3129
32-
3330 public Thickness Padding
3431 {
3532 get => ( Thickness ) GetValue ( PaddingElement . PaddingProperty ) ;
@@ -53,56 +50,44 @@ public override SizeRequest GetSizeRequest(double widthConstraint, double height
5350 protected override Size MeasureOverride ( double widthConstraint , double heightConstraint )
5451 {
5552 var margin = ( this as IView ) ? . Margin ?? Thickness . Zero ;
56-
5753 // Adjust the constraints to account for the margins
5854 widthConstraint -= margin . HorizontalThickness ;
5955 heightConstraint -= margin . VerticalThickness ;
60-
6156 var sizeWithoutMargins = LayoutManager . Measure ( widthConstraint , heightConstraint ) ;
6257 DesiredSize = new Size ( sizeWithoutMargins . Width + Margin . HorizontalThickness ,
6358 sizeWithoutMargins . Height + Margin . VerticalThickness ) ;
64-
6559 return DesiredSize ;
6660 }
67-
61+
6862 protected override Size ArrangeOverride ( Rectangle bounds )
6963 {
7064 base . ArrangeOverride ( bounds ) ;
71-
7265 Frame = bounds ;
73-
7466 LayoutManager . ArrangeChildren ( Frame ) ;
75-
7667 foreach ( var child in Children )
7768 {
7869 child . Handler ? . NativeArrange ( child . Frame ) ;
7970 }
80-
8171 return Frame . Size ;
8272 }
8373
8474 protected override void InvalidateMeasureOverride ( )
8575 {
8676 base . InvalidateMeasureOverride ( ) ;
87-
8877 foreach ( var child in Children )
8978 {
9079 child . InvalidateMeasure ( ) ;
9180 }
9281 }
93-
82+
9483 public virtual void Add ( IView child )
9584 {
9685 if ( child == null )
9786 return ;
98-
9987 _children . Add ( child ) ;
100-
10188 if ( child is Element element )
10289 element . Parent = this ;
103-
10490 InvalidateMeasure ( ) ;
105-
10691 LayoutHandler ? . Add ( child ) ;
10792 }
10893
@@ -144,19 +129,21 @@ public void Insert(int index, IView child)
144129 LayoutHandler ? . Add ( child ) ;
145130 }
146131
147- public virtual void Remove ( IView child )
132+ public virtual bool Remove ( IView child )
148133 {
149134 if ( child == null )
150- return ;
135+ return false ;
151136
152- _children . Remove ( child ) ;
137+ var result = _children . Remove ( child ) ;
153138
154139 if ( child is Element element )
155140 element . Parent = null ;
156141
157142 InvalidateMeasure ( ) ;
158143
159144 LayoutHandler ? . Remove ( child ) ;
145+
146+ return result ;
160147 }
161148
162149 public void RemoveAt ( int index )
@@ -178,23 +165,6 @@ public void RemoveAt(int index)
178165 LayoutHandler ? . Remove ( child ) ;
179166 }
180167
181- bool ICollection < IView > . Remove ( IView child )
182- {
183- if ( child == null )
184- return false ;
185-
186- var result = _children . Remove ( child ) ;
187-
188- if ( child is Element element )
189- element . Parent = null ;
190-
191- InvalidateMeasure ( ) ;
192-
193- LayoutHandler ? . Remove ( child ) ;
194-
195- return result ;
196- }
197-
198168 void IPaddingElement . OnPaddingPropertyChanged ( Thickness oldValue , Thickness newValue )
199169 {
200170 InvalidateMeasure ( ) ;
0 commit comments