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

Add PrimaryButton and SecondaryButton #63

Open
nivisi opened this issue Aug 1, 2022 · 0 comments
Open

Add PrimaryButton and SecondaryButton #63

nivisi opened this issue Aug 1, 2022 · 0 comments

Comments

@nivisi
Copy link
Contributor

nivisi commented Aug 1, 2022

These are pretty common and we recreate them almost on every project. Would be cool to have them in-place and to design them after we create a project from the template.

The most common parameters would be:

  • String text
  • VoidCallback onPressed
  • bool isEnabled
  • bool isLoading

As most of the time we will use preconfigured button sizes, paddings etc, we could create a named constructor .custom to be able to configure the following parameters:

  • double paddingVertical
  • double paddingHorizontal
  • Color backgroundColor
  • Color foregroundColor
  • TextStyle textStyle

And also a constructor for a custom child, if we ever need to use sth like an icon, e.g. withChild

So the interface is the following. Same for SecondaryButton.

final defaultButton = PrimaryButton(
    String text, {
    VoidCallback? onPressed,
    bool isEnabled = true,
    bool isLoading = false,
  }
);

final defaultButtonWithChild = PrimaryButton.withChild(
  {
    VoidCallback? onPressed,
    bool isEnabled = true,
    bool isLoading = false,
    required Widget child,
  }
);

final customButton = PrimaryButton.custom(
    String text, {
    VoidCallback? onPressed,
    bool isEnabled = true,
    bool isLoading = false,
    TextStyle? textStyle,
    double paddingVertical = 4.0, // or whatever
    double paddingHorizontal = 12.0, // or whatever
    Color? backgroundColor, // in the build method, we will be able to use this custom color
    Color? foregroundColor,  // in the build method, we will be able to use this custom color
  }
);

final customButtonWithChild = PrimaryButton.customWithChild(
  {
    VoidCallback? onPressed,
    bool isEnabled = true,
    bool isLoading = false,
    TextStyle? textStyle,
    double paddingVertical = 4.0, // or whatever
    double paddingHorizontal = 12.0, // or whatever
    Color? backgroundColor, // in the build method, we will be able to use this custom color
    Color? foregroundColor, // in the build method, we will be able to use this custom color
    required Widget child,
  }
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant