Mercurial > public > lazybear
view LazyBear/Views/Company/Helpers/NewsRow.swift @ 413:2984d8946342
Minor UI changes
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Wed, 09 Jun 2021 10:23:52 +0200 |
parents | f9611c94d636 |
children |
line wrap: on
line source
// // NewsRow.swift // LazyBear // // Created by Dennis Concepción Martín on 15/5/21. // import SwiftUI struct NewsRow: View { var new: LatestNewsModel @State private var showingSafariView = false var body: some View { Button(action: { showingSafariView = true }) { RowShape() .frame(height: 140) .overlay( HStack { VStack(alignment: .leading) { Text(new.source.uppercased()) .font(.caption) .opacity(0.5) Text(new.headline) .font(.headline) Text(new.summary) .opacity(0.5) .font(.subheadline) .lineLimit(1) .padding(.bottom, 5) let humanDate = convertEpoch(new.datetime, true) Text("\(humanDate) ago") .font(.caption2) .opacity(0.5) } .padding() Spacer() Image(systemName: "chevron.right") .imageScale(.large) .opacity(0.5) .padding() } ,alignment: .leading ) } .buttonStyle(PlainButtonStyle()) .sheet(isPresented: $showingSafariView) { SFSafariViewWrapper(url: URL(string: new.url)!) } } } struct NewsRow_Previews: PreviewProvider { static var previews: some View { NewsRow(new: LatestNewsModel( datetime: 1621037430000, headline: "Chaos Monkeys' author calls Apple's statement on his departure defamatory", image: "https://cloud.iexapis.com/v1/news/image/99abeb99-6d9e-47c8-ae7b-53404eacccec", source: "Investing.com", summary: "https://www.investing.com/news/stock-market-news", url: "https://cloud.iexapis.com/v1/news/article/99abeb99-6d9e-47c8-ae7b-53404eacccec")) } }