Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/contributing/code-style/swift.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ class ClassName {

### Exceptions

- In UI objects—such as views and view modifiers—properties that are displayed should be in the
order in which they are displayed, following the top-left-bottom-right pattern that Apple uses in
components such as
[`UIEdgeInsets`](<https://developer.apple.com/documentation/uikit/uiedgeinsets/init(top:left:bottom:right:)-1s1t9>).
For example, if a `title` is displayed above a `subtitle`, then it should be ordered `title` then
`subtitle` in the properties list and therefore initializer and function parameter lists as
appropriate. Properties that are not displayed then go after the displayed properties, in
alphabetical order. You can see an example of this in
[`BitwardenTextField`](https://github.com/bitwarden/ios/blob/main/BitwardenKit/UI/Platform/Application/Views/BitwardenTextField.swift).
- Closure parameters should be placed last in the method parameter list, to allow for
[trailing closure syntax](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/closures/#Trailing-Closures).
As well,
Expand Down