adospace / reactorui-maui

MauiReactor is a MVU UI framework built on top of .NET MAUI
MIT License
568 stars 47 forks source link

Update Margin Default : 0 #243

Closed lukewire129 closed 2 weeks ago

lukewire129 commented 4 weeks ago

Hi there, I've been working on a side project with MauiReactor recently, and I thought I'd make a request I thought it would be nice to make a request!

BEFORE

public static T Margin<T>(this T view, double leftRight, double topBottom, RxThicknessAnimation? customAnimation = null)
        where T : IView

public static T Margin<T>(this T view, double left, double top, double right, double bottom, RxThicknessAnimation? customAnimation = null)
      where T : IView

Example

Grid()
  .Margin(left:10, right:0, top:0, bottom:0)
Grid()
  .Margin(leftRight: 10, topBottom: 0)

AFTER

public static T Margin<T>(this T view, double leftRight = 0, double topBottom = 0, RxThicknessAnimation? customAnimation = null)
        where T : IView

public static T Margin<T>(this T view, double left = 0, double top = 0, double right = 0, double bottom = 0, RxThicknessAnimation? customAnimation = null)
      where T : IView

Example

Grid()
  .Margin(left:10)
``

Before
```csharp
Grid()
  .Margin(leftRight: 10)

In the example of before code, I need to set the values of other margins to 0 for one margin to be displayed.

If the default value is 0 like in the after code, it can be omitted. I'd like to suggest that you can type the margin value only for the required area!

adospace commented 2 weeks ago

hey after further investigations I found that this change would break a lot of code. For example, the compiler won't be able to compile this call:

view.Margin(10,4);

because both of these would be applicable: public static T Margin(this T view, double leftRight = 0, double topBottom = 0, RxThicknessAnimation? customAnimation = null) where T : IView

public static T Margin(this T view, double left = 0, double top = 0, double right = 0, double bottom = 0, RxThicknessAnimation? customAnimation = null) where T : IView