iOS 15: Conditional modifiers – Views and Modifiers SwiftUI Tutorial 5/10

preview_player
Показать описание

Other parts in Project 3:

5. Conditional modifiers: This video

Рекомендации по теме
Комментарии
Автор

Thanks Paul, finally because of you I'm starting to understand swiftUI. Great work.

neilaryaofficial
Автор

I'm wondering if this could be explained another way - I guess opinions can differ on which is best :)

I'm thinking that I'd say something like: "Make your conditions within the arguments to modifiers where possible"

That is the essence of what you're getting at, as I see it. What operators I use to get that a isn't really relevant. After all, I could use a ternary operator yet still have the "bad" version:

...some View {
return someCondition ? Button(...).modifier(.red) : Button(...).modifier(.blue)
}

This uses the ternary operator rather than if else, yet has the same problems as the if else.

Love your work, this isn't a nitpick, this is more "checking I've understood the real message here" :)

hoagy_ytfc
Автор

Could you please tell me what kind of presentation app you're using?

HungNguyen-pudv