Files
2021-07-01 15:16:36 +03:00

47 lines
1.3 KiB
Swift

//
// NotificationCellModel.swift
// PrivadoVPN
//
// Created by Juraldinio on 4/6/21.
// Copyright © 2021 Privado LLC. All rights reserved.
//
import Foundation
import SwiftyMarkdown
import AppKit
struct NotificationCellModel {
private static let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "dd/MM/yyyy"
return formatter
}()
private enum Constants {
enum Font {
static let color = NSColor(red: 122, green: 134, blue: 190)
static let name = PrivadoConstants.Font.light
static let size: CGFloat = 14
}
}
let title: String // notification.payload.subject ?? ""
let sentDate: Date // notification.payload.sentDate
let body: String // notification.payload.body
var date: String { Self.dateFormatter.string(from: self.sentDate) }
var markdown: NSAttributedString { Self.getFormattedMarkdown(from: self.body) }
// MARK: - Static Private
private static func getFormattedMarkdown(from body: String) -> NSAttributedString {
let markdown = SwiftyMarkdown(string: body)
markdown.body.color = Constants.Font.color
markdown.body.fontName = Constants.Font.name
markdown.body.fontSize = Constants.Font.size
return markdown.attributedString()
}
}