comparison LazyBear/Views/Company/Helpers/NewsList.swift @ 442:6eae10397501

Implementing NewsHelper in CompanyView
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Mon, 21 Jun 2021 13:28:45 +0200
parents
children ffbb1dbab531
comparison
equal deleted inserted replaced
441:417148200aaf 442:6eae10397501
1 //
2 // NewsList.swift
3 // LazyBear
4 //
5 // Created by Dennis Concepción Martín on 21/6/21.
6 //
7
8 import SwiftUI
9
10 struct NewsList: View {
11 var latestNews: [LatestNewsModel]
12 @Environment(\.presentationMode) private var newsListPresentation
13
14 var body: some View {
15 NavigationView {
16 ScrollView {
17 VStack {
18 ForEach(latestNews, id: \.self) { new in
19 if !new.headline.isEmpty {
20 NewsRow(new: new)
21 Divider()
22 .padding(.leading, 80)
23
24 }
25 }
26 }
27 .padding()
28 }
29 .navigationTitle("Latest news")
30 .toolbar {
31 ToolbarItem(placement: .cancellationAction) {
32 Button(action: { newsListPresentation.wrappedValue.dismiss() }) {
33 Image(systemName: "multiply")
34 }
35 }
36 }
37 }
38 }
39 }
40
41 struct NewsList_Previews: PreviewProvider {
42 static var previews: some View {
43 NewsList(
44 latestNews: [
45 LatestNewsModel(
46 datetime: 1621037430000,
47 headline: "Chaos Monkeys' author calls Apple's statement on his departure defamatory",
48 image: "https://cloud.iexapis.com/v1/news/image/99abeb99-6d9e-47c8-ae7b-53404eacccec",
49 source: "Investing.com",
50 summary: "https://www.investing.com/news/stock-market-news",
51 url: "https://cloud.iexapis.com/v1/news/article/99abeb99-6d9e-47c8-ae7b-53404eacccec")
52 ]
53 )
54 }
55 }