Skip to content

Instantly share code, notes, and snippets.

@bestiosdeveloper
Created June 21, 2019 12:26
Show Gist options
  • Save bestiosdeveloper/dcc4acd2c2afec89e6dcb9beb024f7d3 to your computer and use it in GitHub Desktop.
Save bestiosdeveloper/dcc4acd2c2afec89e6dcb9beb024f7d3 to your computer and use it in GitHub Desktop.
import SwiftUI
struct NewsDetailV : View {
let artical: Artical
private let imageWidth: CGFloat = (UIDevice.screenWidth-30.0)
var body: some View {
VStack(alignment: .center) {
Image("ic_news_placeholder")
.frame(width: imageWidth, height: imageWidth * 0.5, alignment: Alignment.center)
.scaledToFill()
Text(verbatim: artical.title)
.lineLimit(nil)
.font(.headline)
HStack {
Image(uiImage: #imageLiteral(resourceName: "ic_publish"))
.frame(width: 20.0, height: 20.0, alignment: Alignment.center)
Text(artical.publishDate?.toString(dateFormat: "d MMM, yyyy") ?? defaultText)
.font(.system(size: 12.0))
Spacer()
Image(uiImage: #imageLiteral(resourceName: "ic_author"))
.frame(width: 20.0, height: 20.0, alignment: Alignment.center)
Text(artical.sourceName)
.font(.system(size: 12.0))
}
.padding(EdgeInsets(top: 0.0, leading: 16.0, bottom: 0.0, trailing: 16.0))
Text(artical.description)
.lineLimit(nil)
.font(.subheadline)
.padding(.top, 16.0)
}
.padding(EdgeInsets(top: 0.0, leading: 16.0, bottom: 0.0, trailing: 16.0))
.offset(x: 0, y: -180)
.padding(.bottom, -180)
}
}
#if DEBUG
struct NewsDetailV_Previews : PreviewProvider {
static var previews: some View {
NewsDetailV(artical: Artical.getDefault())
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment