// // ArticlesView.swift // Hair Society Go // // Created by Joshua Srery on 11/29/20. // import SwiftUI struct ArticlesView: View { @StateObject var articlesInfo = ArticlesInfo() @State var myColorScheme: ColorScheme? @Environment(\.colorScheme) var systemColorScheme var body: some View { NavigationView { List { ForEach(articlesInfo.articles) { article in // Cannot convert value of type '[ArticleInfo]' to expected argument type 'Range<Int>' NavigationLink(destination: ArticleView(title: article.title, image: article.img, content: article.content, author: article.author, date: article.date)) { // Value of type 'Int' has no member 'title,' 'img,' 'content,' 'author,' or 'date' ArticleRow(image: article.img, title: article.title, author: article.author, date: article.date) // Value of type 'Int' has no member 'img,' 'title,' 'author,' or 'date' } } } .navigationTitle("Articles") .toolbar(content: { Menu { Button("Date", action: {}) Button("Title", action: {}) NavigationLink(destination: SettingsView(colorScheme: $myColorScheme)) { Text("Customize...") } } label: { Label("Filter", systemImage: "line.horizontal.3.decrease.circle") } }) .onAppear { articlesInfo.loadArticles() } .colorScheme(myColorScheme ?? systemColorScheme) } } } struct ArticleRow: View { let image: String let title: String let author: String let date: String var body: some View { HStack { Image(image) .resizable() .frame(minWidth: 75, maxWidth: 100, maxHeight: 75) .cornerRadius(12) VStack(alignment: .leading, content: { Text(title) .font(.headline) Text("\(author) • \(date)") .font(.subheadline) }) } } }