comparison LazyBearWatchOS Extension/Views/Helpers/WatchOSNewsList.swift @ 455:b560babcd5ed

WatchOS views implemented
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Mon, 28 Jun 2021 11:55:19 +0200
parents
children c6913f0ce46e
comparison
equal deleted inserted replaced
454:c79a3ed3d230 455:b560babcd5ed
1 //
2 // WatchOSNewsList.swift
3 // LazyBearWatchOS Extension
4 //
5 // Created by Dennis Concepción Martín on 27/06/2021.
6 //
7
8 import SwiftUI
9
10 struct WatchOSNewsList: View {
11 var latestNews: [LatestNewsModel]?
12
13 var body: some View {
14 VStack {
15 if let latestNews = latestNews {
16 List(latestNews, id: \.self) { new in
17 NavigationLink(destination: WatchOSNewsDetail(new: new)
18 .navigationTitle("News")
19 ) {
20 WatchOSNewsRow(new: new)
21 }
22 }
23 } else {
24 // Handle if there is no data
25 }
26 }
27 }
28 }
29
30 struct WatchOSNewsList_Previews: PreviewProvider {
31 static var previews: some View {
32 WatchOSNewsList(
33 latestNews: [
34 LatestNewsModel(
35 datetime: 1621037430000,
36 headline: "Chaos Monkeys' author calls Apple's statement on his departure defamatory",
37 image: "https://cloud.iexapis.com/v1/news/image/99abeb99-6d9e-47c8-ae7b-53404eacccec",
38 source: "Investing.com",
39 summary: "https://www.investing.com/news/stock-market-news",
40 url: "https://bloomberg.com")
41 ]
42 )
43 }
44 }