Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For: #28 #25
NiceButton
This PR introduces
NiceButton
, a protocol that adds a bunch of flexibility and useful default behaviour to all button components.Some problems addressed by NiceButton:
Firstly, every button component had the exact same view body constructed with the only difference being the button style.
The shared body is now constructed in an extension to NiceButton within a viewBuilder property called
defaultBody
. This allows easy conformance to NiceButton without needing to duplicate code. DefaultBody will also be helpful for the eventual next step of this component which will be to allow a viewBuilder constructor to be passed in.Secondly, tweaking properties of button components has been quite tedious and verbose. There was pretty much no way to do this other than reconstruct the
ButtonStyle
object and re-setting the same properties for the most part. Also, depending on the border-style of your button, it would require you to remember to tweak other related properties. For instance if you styled your button to be pill shaped and you wanted to change the height, you would have to remember to change the cornerRadius as well in order to keep the uniform pill shape.Changing the primary button height before:
New way of changing button height:
The borderRadius is automatically set for you because the border theme is set to
.capsule
.You can also set any other properties of buttons on the fly, without needing to reconstruct an entire ButtonStyle object.
Thirdly, I found it a bit odd that you would replace your entire button with an entirely new button for supporting disabled states. If you had a PrimaryButton you would need to explicitly code your disabled condition to instead render InActiveButton when disabled. This has changed so that you now pass your disabled flag into the button component.
The styling is set by new properties in NiceButtonStyle. (
disabledSurfaceColor
&disabledOnSurfaceColor
)NiceBorderStyle:
BorderStyle has been replaced with an enum for easier use/initialization and extra helpful behaviour. ( StrokeStyle now supported as well )
You can now add Left/Right icons to button components like this:
Bug Fixes: