blob: ca45c5d3c1005e52d72969632acb3a4ad190efd6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
//
// ChangeLogViewModel.swift
// MullvadVPN
//
// Created by Mojgan on 2023-08-22.
// Copyright © 2023 Mullvad VPN AB. All rights reserved.
//
import Foundation
import UIKit.NSAttributedString
import UIKit.UIFont
struct ChangeLogViewModel {
let header: String = Bundle.main.shortVersion
let title: String = NSLocalizedString(
"CHANGE_LOG_TITLE",
tableName: "Account",
value: "Changes in this version:",
comment: ""
)
let body: NSAttributedString
init(body: [String]) {
self.body = body.changeLogAttributedString
}
}
fileprivate extension Array where Element == String {
var changeLogAttributedString: NSAttributedString {
let bullet = "• "
let font = UIFont.preferredFont(forTextStyle: .body)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineBreakMode = .byWordWrapping
paragraphStyle.headIndent = bullet.size(withAttributes: [.font: font]).width
return NSAttributedString(
string: self.map {
"\(bullet)\($0)"
}
.joined(separator: "\n"),
attributes: [
.paragraphStyle: paragraphStyle,
.font: font,
.foregroundColor: UIColor.white.withAlphaComponent(0.8),
]
)
}
}
|