import Foundation import Models import Utils import Views struct WebReaderContent { let textFontSize: Int let lineHeight: Int let maxWidthPercentage: Int let item: LinkedItem let themeKey: String let fontFamily: WebFont let articleContent: ArticleContent let prefersHighContrastText: Bool init( item: LinkedItem, articleContent: ArticleContent, isDark: Bool, fontSize: Int, lineHeight: Int, maxWidthPercentage: Int, fontFamily: WebFont, prefersHighContrastText: Bool ) { self.textFontSize = fontSize self.lineHeight = lineHeight self.maxWidthPercentage = maxWidthPercentage self.item = item self.themeKey = isDark ? "Gray" : "LightGray" self.fontFamily = fontFamily self.articleContent = articleContent self.prefersHighContrastText = prefersHighContrastText } // swiftlint:disable line_length var styledContent: String { let savedAt = "new Date(\(item.unwrappedSavedAt.timeIntervalSince1970 * 1000)).toISOString()" let createdAt = "new Date(\(item.unwrappedCreatedAt.timeIntervalSince1970 * 1000)).toISOString()" let publishedAt = item.publishDate != nil ? "new Date(\(item.publishDate!.timeIntervalSince1970 * 1000)).toISOString()" : "undefined" return """