Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spec] Fluent API for MVU #199

Closed
mgierlasinski opened this issue Jan 11, 2022 · 0 comments · Fixed by #201
Closed

[Spec] Fluent API for MVU #199

mgierlasinski opened this issue Jan 11, 2022 · 0 comments · Fixed by #201
Assignees
Labels
Milestone

Comments

@mgierlasinski
Copy link
Owner

mgierlasinski commented Jan 11, 2022

Create extension methods for IGradientControl to setup gradients with simple, fluent API useful for MVU-style UI.

Source extensions

Source(IGradientSource source);
Source(string css);
Source(Action<GradientBuilder> build);
new GradientView()
   .Source(new MySource())

new GradientView()
   .Source("linear-gradient(red, green, blue)")

new GradientView()
   .Source(b => b
      .AddLinearGradient(s => s
         .Rotate(45))
      .AddRadialGradient())

Size extensions

Size(Dimensions size);
Size(string css);
new GradientView()
   .Size(Dimensions.Abs(40,40))

new GradientView()
   .Size("40px 40px")

Repeat extensions

Repeat(BackgroundRepeat repeat);
Repeat(string css);
new GradientView()
   .Repeat(BackgroundRepeat.RepeatX)

new GradientView()
   .Repeat("repeat-x")

Mask extensions

Mask(IGradientMask mask);

Use cases

[Body]
View body () => new VStack 
{
   new GradientView()
      .Source("linear-gradient(orange, yellow)")
      .Size("100px 200px"),
   new GradientView()
      .Source(b => b
         .AddLinearGradient(s => s
            .AddStops(Colors.Blue, Colors.Pink)
            .Rotate(90)))
      .Size(Dimensions.Prop(0.5, 0.5))
      .Repeat(BackgroundRepeat.RepeatY)
};
@mgierlasinski mgierlasinski added the 🛠️ enhancement New feature or request label Jan 11, 2022
@mgierlasinski mgierlasinski added this to the Road to MAUI milestone Jan 11, 2022
@mgierlasinski mgierlasinski self-assigned this Jan 11, 2022
@mgierlasinski mgierlasinski added this to To do in Magic Gradients via automation Jan 11, 2022
Magic Gradients automation moved this from To do to Done Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

1 participant