SwiftUI Architecture, A11y, SwiftUI Charts, UICollectionView & More!

SwiftUI Architecture, A11y, SwiftUI Charts, UICollectionView & More!

Sean Allen

3 года назад

5,685 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@darato2015
@darato2015 - 01.02.2021 21:35

I would use a custom modifier in this case, it's just a simple combination of other view modifiers. It doesn't justify creating a new SwiftUI file or refer to it down below for me.

Ответить
@awais.fayyaz
@awais.fayyaz - 01.02.2021 17:28

Thanks for the News Sean. As always, great content!

Ответить
@OmOmingCookies
@OmOmingCookies - 01.02.2021 14:30

I like using custom modifiers, when it's part of the styling needed. If I have buttons, that share some of the modifiers, but don't share some for example. I could have 'ConfirmButton' and 'DeclineButton' that share a bunch of modifiers, but differ in some. That way I only have to write the custom modifier to both and then extend that with the differing modifiers.
So I'm using a combination of both.

Ответить
@mihailsalari
@mihailsalari - 27.01.2021 18:16

Good job man! Keep doing this! Respect!

Ответить
@victoriawaschenko
@victoriawaschenko - 26.01.2021 21:17

I just learned of your videos and am a new subscriber as of today!! I am an interior architect by trade however always had a passion for UIUX and have a background in engineering prior to architecture. I am using my time of unemployment during covid to learn as much as I can about THIS type of architecture! A pivot in career is looking more realistic the more I learn

Ответить
@multitudes389
@multitudes389 - 26.01.2021 15:58

Ah the Build Animated Pie and Donut Charts is behind a paywall... damn ! 😅

Ответить
@dannylones2159
@dannylones2159 - 26.01.2021 13:45

apple created whole new swiftui just basically ditch mvc and do mvvm but some bright minds still insist on mvc for swiftui 🗿🤦‍♂️

Ответить
@chesterman18g
@chesterman18g - 26.01.2021 13:04

I am using the custom view modifiers as something that I can reuse in other UI components. Dedicated Custom view if that works only for the given one case. I find custom modifiers like an extension over some generic type/protocol.

Ответить
@connyhakansson5474
@connyhakansson5474 - 26.01.2021 12:28

I usually distinguish the usage between modifiers and custom views, by its contents. Design /layout goes to modifies. But if I use actions or custom event handling etc, I create a new custom view for that. This makes it very easy to read, for instance a Text view, would use a custom modifier for its repeating modifiers (color, font etc). But a TextField with custom validation would go to a custom TextField view. (appearance vs action)

Ответить
@tenminutetokyo2643
@tenminutetokyo2643 - 26.01.2021 03:24

DOOD!

Ответить
@nX-
@nX- - 26.01.2021 01:50

CustomModifiers, I use for reusing styles. Example: An avatar view might have the same shadow style and border style, as a card view. So you create two different views, but instead of repeating these modifiers, you create a ShadowBackground modifier and use on both AvatarView and CardView.

Ответить
@olgusirman
@olgusirman - 26.01.2021 00:59

It is really hard to convince colleagues and bosses to use more reliable, easy to implement, accessible, bug free native controls sometimes. They only want to see fancy things, they thought looks cheap ( actually the opposite ) and they want to show every data without thinking 👎

Ответить
@VlastimirRadojevic
@VlastimirRadojevic - 26.01.2021 00:19

Wouldn’t be useful to create a custom modifier if you need it to implement same modifiers on different view elements, whereas a custom View Element would be for reusability of that specific type of element?

Ответить
@DavidMcleanWhite_Shadoow
@DavidMcleanWhite_Shadoow - 25.01.2021 23:12

I was asking myself the same thing yesterday, I going for custom view 100%. Just cause that's what I learned first.

Ответить
@kamilgoralski4659
@kamilgoralski4659 - 25.01.2021 22:43

Custom modifier can be used for other views, not just for TextView. In my opinion this is an advantage of this approach.

Ответить
@sergeimeza4663
@sergeimeza4663 - 25.01.2021 21:59

I think is easier to onboard new developers with standard SwiftUI elements with custom modifiers rather than having custom SwiftUI views altogether. That being said if the element is complex and handles State I would use a custom SwiftUI view.

Ответить
@EmmaKAlexandra
@EmmaKAlexandra - 25.01.2021 21:11

On custom view modifiers, I think they’re great for defining consistent styling in your app. I tend to avoid making Views with single elements just because it abstracts away too much.

For example, if you build a custom View that contains a Text view & some view modifiers you can’t add additional modifiers to the Text view. The custom View erases the Text view to `some View`. So if, in the future, you want to add a strikethrough or apply a different font with the same styling you can’t use the custom view because the underlying Text view is erased. You can sometimes fix this with defining the Type of your `body` property to be Text but not always.

I think maintaining the underlying type of your View is really important in SwiftUI and often overlooked because so many view modifiers are available just on View. But if you look at the Text view documentation you can see a lot of the view modifiers for Text actually return a Text instance rather than `some View`. Some view modifiers are available exclusively on Text, which is why you sometimes get type errors when applying multiple view modifiers in a random order. The same is true for a lot of Views. So if you want to take advantage of these type-dependent view modifiers in the future you should avoid erasing your types like you would with a single element View.

I tend to reserve custom Views for times when composition of multiple Views is required. So, a custom layout of multiple Views, containing some complex, reusable logic on multiple views or handling some complex ObservedObjects.

Ответить
@michaellatta
@michaellatta - 25.01.2021 19:43

Custom modifier if you are creating a “style” that can be applied to a range of views.

Ответить
@tahmidazam639
@tahmidazam639 - 25.01.2021 19:41

Sean what’s the best option to start writing articles for SwiftUI and iOS development?

Ответить
@huntermeyer4972
@huntermeyer4972 - 25.01.2021 19:08

I would use a ViewModifier when I'm changing style (such as the Text example), but I'd create a custom View when I need to modify the layout or pass any data that is more complex than what I would feel comfortable passing through a view modifier

Ответить
@605dave
@605dave - 25.01.2021 18:28

We have built an entire struct system for views with modifiers instead of using modifiers directly. I find the code reads better and the extensibility is amazing. Our system has really helped new devs use our custom views with ease

Ответить
@petersuvara
@petersuvara - 25.01.2021 18:24

Keep up the great work Sean! Perhaps one of these days we'll run into each other!

Ответить
@glennadams7047
@glennadams7047 - 25.01.2021 17:56

Good content ! Thanks Sean

Ответить
@muhammadyusoffjamaluddin
@muhammadyusoffjamaluddin - 25.01.2021 17:56

A week has gone by, thanks Sean. :D

Ответить
@NickRossik
@NickRossik - 25.01.2021 17:55

Can somebody share UI for watchOS? 🥺

Ответить
@JunaidKhan-ny8tu
@JunaidKhan-ny8tu - 25.01.2021 17:38

Perfect one ❤️❤️

Ответить