comparison LazyBear/Views/Company/Helpers/NewsList.swift @ 447:8621ba6fd457

Fixes #48
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Wed, 23 Jun 2021 10:54:47 +0200
parents 7d1c4dc8d1d8
children
comparison
equal deleted inserted replaced
446:9cc0455bc46f 447:8621ba6fd457
7 7
8 import SwiftUI 8 import SwiftUI
9 9
10 struct NewsList: View { 10 struct NewsList: View {
11 var latestNews: [LatestNewsModel] 11 var latestNews: [LatestNewsModel]
12 @Binding var isPresented: Bool
13 12
14 var body: some View { 13 var body: some View {
15 NavigationView { 14 ScrollView(showsIndicators: false) {
16 ScrollView(showsIndicators: false) { 15 VStack {
17 VStack { 16 ForEach(latestNews, id: \.self) { new in
18 ForEach(latestNews, id: \.self) { new in 17 if !new.headline.isEmpty {
19 if !new.headline.isEmpty { 18 NewsRow(new: new)
20 NewsRow(new: new) 19 Divider()
21 Divider() 20 .padding()
22 .padding() 21
23
24 }
25 }
26 }
27 .padding()
28 }
29 .navigationTitle("Latest news")
30 .toolbar {
31 ToolbarItem(placement: .cancellationAction) {
32 Button(action: { self.isPresented.toggle() }) {
33 Image(systemName: "multiply")
34 } 22 }
35 } 23 }
36 } 24 }
25 .padding()
37 } 26 }
38 } 27 }
39 } 28 }
40 29
41 struct NewsList_Previews: PreviewProvider { 30 struct NewsList_Previews: PreviewProvider {
48 image: "https://cloud.iexapis.com/v1/news/image/99abeb99-6d9e-47c8-ae7b-53404eacccec", 37 image: "https://cloud.iexapis.com/v1/news/image/99abeb99-6d9e-47c8-ae7b-53404eacccec",
49 source: "Investing.com", 38 source: "Investing.com",
50 summary: "https://www.investing.com/news/stock-market-news", 39 summary: "https://www.investing.com/news/stock-market-news",
51 url: "https://cloud.iexapis.com/v1/news/article/99abeb99-6d9e-47c8-ae7b-53404eacccec") 40 url: "https://cloud.iexapis.com/v1/news/article/99abeb99-6d9e-47c8-ae7b-53404eacccec")
52 ] 41 ]
53 , isPresented: .constant(true)
54 ) 42 )
55 } 43 }
56 } 44 }