Skip to content

Commit

Permalink
Reverse the polarity
Browse files Browse the repository at this point in the history
  • Loading branch information
hartez committed Jul 27, 2023
1 parent ce10d27 commit df7fd1a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 49 deletions.
6 changes: 2 additions & 4 deletions src/Controls/src/Core/ContentPage/ContentPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ protected override void InvalidateMeasureOverride()
IView IReplaceableView.ReplacedView => HotReload.MauiHotReloadHelper.GetReplacedView(this) ?? this;

HotReload.IReloadHandler HotReload.IHotReloadableView.ReloadHandler { get; set; }
Thickness IPadding.Padding { get; }

void HotReload.IHotReloadableView.TransferState(IView newView)
{
Expand All @@ -108,10 +109,8 @@ void HotReload.IHotReloadableView.Reload()
//TODO: if reload handler is null, Do a manual reload?
});
}
#endregion

#if NETSTANDARD
// NetStandard doesn't support default interface implementations, so we provide them here.
#endregion

Size IContentView.CrossPlatformArrange(Rect bounds)
{
Expand All @@ -122,6 +121,5 @@ Size IContentView.CrossPlatformMeasure(double widthConstraint, double heightCons
{
return (this as ICrossPlatformLayout).CrossPlatformMeasure(widthConstraint, heightConstraint);
}
#endif
}
}
26 changes: 4 additions & 22 deletions src/Core/src/Core/IContentView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,16 @@ public interface IContentView : IView, IPadding, ICrossPlatformLayout
/// </summary>
IView? PresentedContent { get; }

#if NETSTANDARD2_0
/// <summary>
/// This interface method is provided as a stub for .NET Standard
/// This interface method is provided for backward compatibility with previous versions.
/// Implementing classes should implement the ICrossPlatformLayout interface rather than directly implementing this method.
/// </summary>
new Size CrossPlatformMeasure(double widthConstraint, double heightConstraint);

/// <summary>
/// This interface method is provided as a stub for .NET Standard
/// This interface method is provided for backward compatibility with previous versions.
/// Implementing classes should implement the ICrossPlatformLayout interface rather than directly implementing this method.
/// </summary>
new Size CrossPlatformArrange(Rect bounds);
#else
/// <summary>
/// This implementation is provided as a bridge for previous versions. Implementing classes should implement
/// the ICrossPlatformLayout interface rather than directly implementing this method.
/// </summary>
new Size CrossPlatformMeasure(double widthConstraint, double heightConstraint)
{
return (this as ICrossPlatformLayout).CrossPlatformMeasure(widthConstraint, heightConstraint);
}

/// <summary>
/// This implementation is provided as a bridge for previous versions. Implementing classes should implement
/// the ICrossPlatformLayout interface rather than directly implementing this method.
/// </summary>
new Size CrossPlatformArrange(Rect bounds)
{
return (this as ICrossPlatformLayout).CrossPlatformArrange(bounds);
}
#endif
}
}
24 changes: 24 additions & 0 deletions src/Core/src/Core/ICrossPlatformLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,37 @@ public interface ICrossPlatformLayout
/// <param name="widthConstraint">The width limit for measuring the ICrossPlatformLayout.</param>
/// <param name="heightConstraint">The height limit for measuring the ICrossPlatformLayout.</param>
/// <returns>The desired size of the ILayout.</returns>
#if NETSTANDARD2_0
Size CrossPlatformMeasure(double widthConstraint, double heightConstraint);
#else
Size CrossPlatformMeasure(double widthConstraint, double heightConstraint)
{
return this switch
{
IContentView contentView => contentView.CrossPlatformMeasure(widthConstraint, heightConstraint),
ILayout layout => layout.CrossPlatformMeasure(widthConstraint, heightConstraint),
_ => Size.Zero,
};
}
#endif

/// <summary>
/// Arranges the children of the ICrossPlatformLayout within the given bounds.
/// </summary>
/// <param name="bounds">The bounds in which the ICrossPlatformLayout's children should be arranged.</param>
/// <returns>The actual size of the arranged ICrossPlatformLayout.</returns>
#if NETSTANDARD2_0
Size CrossPlatformArrange(Rect bounds);
#else
Size CrossPlatformArrange(Rect bounds)
{
return this switch
{
IContentView contentView => contentView.CrossPlatformArrange(bounds),
ILayout layout => layout.CrossPlatformArrange(bounds),
_ => Size.Zero,
};
}
#endif
}
}
28 changes: 5 additions & 23 deletions src/Core/src/Core/ILayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,16 @@ public interface ILayout : IView, IContainer, ISafeAreaView, IPadding, ICrossPla
/// </summary>
bool ClipsToBounds { get; }

#if NETSTANDARD2_0
/// <summary>
/// This interface method is provided as a stub for .NET Standard
/// </summary>
new Size CrossPlatformMeasure(double widthConstraint, double heightConstraint);

/// <summary>
/// This interface method is provided as a stub for .NET Standard
/// This interface method is provided for backward compatibility with previous versions.
/// Implementing classes should implement the ICrossPlatformLayout interface rather than directly implementing this method.
/// </summary>
new Size CrossPlatformArrange(Rect bounds);
#else
/// <summary>
/// This implementation is provided as a bridge for previous versions. Implementing classes should implement
/// the ICrossPlatformLayout interface rather than directly implementing this method.
/// </summary>
new Size CrossPlatformMeasure(double widthConstraint, double heightConstraint)
{
return (this as ICrossPlatformLayout).CrossPlatformMeasure(widthConstraint, heightConstraint);
}

/// <summary>
/// This implementation is provided as a bridge for previous versions. Implementing classes should implement
/// the ICrossPlatformLayout interface rather than directly implementing this method.
/// This interface method is provided for backward compatibility with previous versions.
/// Implementing classes should implement the ICrossPlatformLayout interface rather than directly implementing this method.
/// </summary>
new Size CrossPlatformArrange(Rect bounds)
{
return (this as ICrossPlatformLayout).CrossPlatformArrange(bounds);
}
#endif
new Size CrossPlatformMeasure(double widthConstraint, double heightConstraint);
}
}

0 comments on commit df7fd1a

Please sign in to comment.