From 8e0e5b7cef619dff2120d2b09dcc5e806db2bd01 Mon Sep 17 00:00:00 2001 From: Emircan Duman <s75316@beuth-hochschule.de> Date: Sat, 7 Nov 2020 15:43:18 +0100 Subject: [PATCH] #3 New feature clicking on cell link to ArticleView(), feed_provider_name added --- RSS_Reader/ArticleList.swift | 9 +++-- RSS_Reader/ArticleListRow.swift | 69 ++++++++++++++++++--------------- 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/RSS_Reader/ArticleList.swift b/RSS_Reader/ArticleList.swift index 3883aca..d228716 100644 --- a/RSS_Reader/ArticleList.swift +++ b/RSS_Reader/ArticleList.swift @@ -13,11 +13,12 @@ import SwiftUI struct ArticleList: View { var body: some View { - List { - ForEach(model.article_data){ article in - ArticleListRow(article: article, image: Image("824cf0bb-20a4-4655-a50e-0e6ff7520d0f")) - } + List { + ForEach(model.article_data){ article in + ArticleListRow(article: article, image: Image("824cf0bb-20a4-4655-a50e-0e6ff7520d0f")) } + } + .frame(alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/) } } diff --git a/RSS_Reader/ArticleListRow.swift b/RSS_Reader/ArticleListRow.swift index 70c6255..ff21527 100644 --- a/RSS_Reader/ArticleListRow.swift +++ b/RSS_Reader/ArticleListRow.swift @@ -12,44 +12,49 @@ import SwiftUI */ struct ArticleListRow: View { - + var article: ArticleData var image: Image - + var body: some View { - - HStack { - image - .resizable() - .frame(width: 130, height: 115) - - VStack{ - Text(article.title) - .font(.custom("article_titel", size: 19)) - - Text(article.date_to_string()) - .font(.custom("article_pub_date", size: 12)) - - Text(article.description) - .font(.subheadline) + NavigationLink(destination: ArticleView()){ + HStack { + + VStack{ + Text(article.title) + .font(.custom("article_titel", size: 19)) + HStack{ + Text("feed_provider_name") + .font(.custom("parent_feed_provider_name", size: 10)) + + Text(article.date_to_string()) + .font(.custom("article_pub_date", size: 10)) + } + Text(article.description) + .font(.subheadline) + } + + Spacer() + + //Image(article.image) + image + .resizable() + .frame(width: 130, height: 115) } - //article.image - Spacer() + .frame(alignment: .center) } - - .frame(width: 370, height: 120, alignment: .center) } -} - -struct ArticleListRow_Previews: PreviewProvider { - static var previews: some View { - - let img0 = Image("824cf0bb-20a4-4655-a50e-0e6ff7520d0f") - let img1 = Image("c9f82579-efeb-4ed5-bf07-e10edafc3a4d") - - Group{ - ArticleListRow(article: model.article_data[0],image: img0) - ArticleListRow(article: model.article_data[1],image: img1) + + struct ArticleListRow_Previews: PreviewProvider { + static var previews: some View { + + let img0 = Image("824cf0bb-20a4-4655-a50e-0e6ff7520d0f") + let img1 = Image("c9f82579-efeb-4ed5-bf07-e10edafc3a4d") + + Group{ + ArticleListRow(article: model.article_data[0],image: img0) + ArticleListRow(article: model.article_data[1],image: img1) + } } } } -- GitLab