You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While the documentation speaks of hiding the default when it comes to modifiers there is no mention of how to do this with properties in a Struct's initializer.
For example we see how GhostButton is displayed:
GhostButton("Your title",
size:.large,
hugContent: false
){// Place your action here}
The Problem
The trouble is its displaying the defaults of size: .large and hugContent: false. And it's common Swift convention of not writing out property values if they are the default. As it stands now the above code would get flagged in code review.
This is how developers should write it in the above case.
GhostButton("Your title"){// Place your action here}// ideally if theres only one value its like so. but that may be more difficult to implement. so this is not a blocker but the above is.GhostButton("Your title"){// Place your action here}
For reference here's how I have it coded:
structPDLGhostButton_doc:FigmaConnect{@FigmaString("Label")varlabel:String="Label"@FigmaEnum("Density", mapping:["Large":.large,"Medium":.medium,"Small":.small], hideDefault: true)vardensity:PedalButton.Size=.large
@FigmaBoolean("Hug content", hideDefault: true)varhugContent:Bool= false
varbody:someView{GhostButton(
label,
size: density,
hugContent: hugContent
){// Place your action here}}}
I would have thought that the 'hideDefault` would be respected and the property not shown in the initializer. Can this be currently done? if not then I'd like to make a feature request that properties on the initializer should be not shown if hideDefault is set to true.
running version 1.1.3,
Mac OS X: 14.6.1 (23G93)
The text was updated successfully, but these errors were encountered:
While the documentation speaks of hiding the default when it comes to modifiers there is no mention of how to do this with properties in a Struct's initializer.
For example we see how GhostButton is displayed:
The Problem
The trouble is its displaying the defaults of
size: .large
andhugContent: false
. And it's common Swift convention of not writing out property values if they are the default. As it stands now the above code would get flagged in code review.This is how developers should write it in the above case.
For reference here's how I have it coded:
I would have thought that the 'hideDefault` would be respected and the property not shown in the initializer. Can this be currently done? if not then I'd like to make a feature request that properties on the initializer should be not shown if hideDefault is set to true.
running version
1.1.3
,Mac OS X:
14.6.1 (23G93)
The text was updated successfully, but these errors were encountered: