Module 4, Wrap Up! (part 4)

The Challenge so Far

The challenge concludes:

  1. Created ‘Ratings’ selection Picker(),
    • Learned about .onAppear, which replaces the default rating with the book’s rating once the book has been selected.
  2. The challenge solution uses a new element indices – another one we haven’t encountered before. It’s some kind of challenge when the ‘solution’ requires knowledge of so many things we’ve not covered in this module.
    • Back to Google…
    • Seems the general consensus is that ForEach(array.indices){} (that we haven’t seen before) is better practice than ForEach(0..<array.count){} (that’s we’ve been using),
    • Making a note…
  3. Finish up with a look into .tabViewStyle() and .indexViewStyle(). I’m beginning to conclude that ‘helpful’ documentation on the internet is anything but ‘helpful’. Explaining complicated elements in a convulted way so as you’re less clear after reading up on them than you were before is no real help. Are there people out there intentionally making it seem more difficult than it needs to be?

So, that’s Module 4 completed, but I think I need to note down some basics before I move on…

Initial view: (ContentView):

var body: some View {
    NavigationView {
        ScrollView {
            LazyVStack() {
                ForEach() { r in
                    NavigationLink(destination: )) {                            
                    }
                }            
            } 
            .navigationTitle()
        }
    }
}

Selection, with Picker:

VStack {
    NavigationLink(destination: ) {
        VStack {
            Text()
            Image()
         }
    }
    Text()#
    Button(action: {}) {
        Image()
    }
    Text()
    Picker("", selection: $b) {
        ForEach (0) { r in
            Text ()
        }
    }
    .pickerStyle(SegmentedPickerStyle())
    .onChange(of: , perform: { })
}
.onAppear {}
.navigationBarTitle()

Tabs (swipeable):

TabView(selection: $sc) {
    ForEach(array.indices) { s in
    }
}
.tabViewStyle(PageTabViewStyle())
.indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .never))
.onChange(of: , perform: { v in })
.onAppear {}

Here’s hoping that this will help trigger the old memory when needed.