Post

Replies

Boosts

Views

Activity

Reply to Omit items from List without leaving a gap in produced list
Update here is the code: import SwiftUI struct CurrencyList: View {     @EnvironmentObject var FetchedRates:FetchRates          // Info : FetchedRates.faves = ["AUD", "BGN", "CNY", "GBP"] //     @Environment(\.managedObjectContext) private var viewContext          @FetchRequest(         entity: CURRENCIES.entity(),         sortDescriptors: [             NSSortDescriptor(keyPath: \CURRENCIES.core_Country, ascending: true)         ])          var items: FetchedResultsCURRENCIES     @State var showFavs = false          var body: some View {         VStack{             HStack{                 Toggle("Favourites only", isOn: $showFavs)                              }             Divider()                      }                  List {             ForEach(items) { record in                                  HStack{                     VStack{                         if FetchedRates.faves.contains(record.core_Code) && showFavs == true {                             HStack{                                 Text(record.core_Country)                                                                  Spacer()                             }                             HStack(alignment: .center){                                 Text(FLAGCODES[record.core_Code] ?? "")                                                                  Text(record.core_Code)                                                                  Text(record.core_Currency_Name)                                                                  NavigationLink(destination: CurrencyDetail2(RowData: record)) {                                                                      }                             }                         }                         else{                                                      }                     }                 }                 .frame(height: 50)             }         }                  .navigationBarTitle(Text("Exchange Rates"), displayMode: .inline)         .listStyle(DefaultListStyle())         .navigationBarItems(trailing:                                 Image(systemName:"antenna.radiowaves.left.and.right").resizable()                                 .foregroundColor(FetchedRates.dataStatus))     } } So basically output of the list is only the currencies within the array of FetchedRates.faves ["AUD","BGN","CNY","GBR"] which is what should happen, but the list has large gaps in it where other currencies which aren't favourited would normally be.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Where to learn this world?
I would start off with the '100 days of swift course' (google it) - a little bit of Swift every day for 100 days. And it's totally free. I have learned a lot from that site over the past couple of years. On the site are numerous "how-to's" so that when you get started on your own projects then get stuck you can use it as a quick reference. Want an example of how to do a list in iOS ? its there! etc. But as mentioned above, make use of as many resources as you can. All will explain things in slightly different ways and it may just 'stick' better explained in a different way from a different site.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Data between views
Should have added - the error I currently get with the code show above is "Cannot convert value of type 'Flight.Type' to expected argument type 'Flight'" on the Navigation link of the FlightView. If trying to use the EnvironmentObject I tend to get error "Trailing closure passed to parameter of type 'HorizontalAlignment' that does not accept a closure"
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22