Ancestors

Written by John Siracusa on 2024-12-18 at 03:31

Welcome to my new series on things I don’t understand about Apple’s premier user interface framework. I’m calling it…

[#]SwiftUWhy

To be clear, these are things I don’t understand, not necessarily things that are “wrong.” They sure look wrong (or at least “suboptimal”) to me! But maybe there are good reasons, and I just don’t know them yet. SwiftUI experts and historians, please tell me!

The first entry is coming up…

=> More informations about this toot | More toots from siracusa@mastodon.social

Written by John Siracusa on 2024-12-18 at 03:35

Why in the world does this interface look like this:

.padding(.top, 1)

.padding(.leading, 2)

.padding(.bottom, 3)

.padding(.trailing, 4)

…or this:

.padding(EdgeInsets(top: 1, leading: 2, bottom: 3, trailing: 4))

…instead of the much more idiomatic:

.padding(top: 1, leading: 2, bottom: 3, trailing: 4)

Like, who in the world thought of this foo(.key, value) API interface in a language with named parameters?!

[#]SwiftUWhy

=> More informations about this toot | More toots from siracusa@mastodon.social

Written by Mike Apurin on 2024-12-18 at 05:03

@siracusa one thing is that in most cases composing padding like that helps convey intent. If I want padding around edges, but more on left/right

.padding(8)

.padding(.horizontal, 8)

reads better than

.padding(top: 8, leading: 16, bottom: 8, trailing: 16)

=> More informations about this toot | More toots from auramagi@hachyderm.io

Written by John Siracusa on 2024-12-18 at 05:06

@auramagi .padding(horizontal: 16, vertical: 8)

=> More informations about this toot | More toots from siracusa@mastodon.social

Written by Mike Apurin on 2024-12-18 at 05:08

@siracusa how many overloads for a simple padding do we need? ;)

=> More informations about this toot | More toots from auramagi@hachyderm.io

Toot

Written by John Siracusa on 2024-12-18 at 05:14

@auramagi At least one more!

=> More informations about this toot | More toots from siracusa@mastodon.social

Descendants

Written by Joseph Humfrey on 2024-12-18 at 06:37

@siracusa @auramagi one more? Well I often use:

.padding([.top, .bottom], 5)

But only because I didn’t know about .vertical!

=> More informations about this toot | More toots from joethephish@mastodon.gamedev.place

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113672117262683288
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
354.742593 milliseconds
Gemini-to-HTML Time
1.168738 milliseconds

This content has been proxied by September (3851b).