nank1ro / flutter-shadcn-ui

shadcn-ui ported in Flutter. Awesome UI components for Flutter, fully customizable.
https://mariuti.com/shadcn-ui
MIT License
926 stars 56 forks source link

Move size settings to another ThemeData object #2

Closed dickermoshe closed 8 months ago

dickermoshe commented 8 months ago

This implements the button sizes presets into its own theme object for more customization. If presets are being provided then they just be customizable. Having padding, height and width declared twice seems like bad practice

The order of importance for padding, height and width is as follows.

  1. Use whatever is declared on the widget
  2. If a size is declared on the widget, use the padding, height and width from the ButtonSizes theme.
  3. Use size on global theme to get padding, height and width.
nank1ro commented 8 months ago

I would change two things:

  1. Include the ShadcnButtonSizesTheme in the ShadcnBaseTheme. This ensures that when the ShadcnThemeData is created, the default values are set.

  2. Remove the default values from the ShadcnButtonSizesTheme, and rename the buttonSizesTheme in the ShadcnButtonTheme to sizes, because we’re already in a subtheme

This allows the user to customize the ShadcnButtonSizesTheme for the whole app by passing the buttonSizesTheme to ShadcnThemeData, if someone wants to customize a specific button style, like the primary button, should set the sizes parameter to the primaryButtonTheme

What do you think? Is kind of the same behaviors as radius

dickermoshe commented 8 months ago

Done

nank1ro commented 8 months ago

Thanks for the PR, I really appreciate it 🙏