summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2023-04-28 16:31:05 +0200
committerAndrej Mihajlov <and@mullvad.net>2023-04-28 16:31:05 +0200
commit3595658d8f0f0f6851f113effcab0d2c93e75cb8 (patch)
tree6fe0fe43887356378ecf4618a30d4ba4ad2c152d
parent0c6ce745286de83edff01650d4d1670c81346c5f (diff)
parentad438b82edc0f0d8edd089048975dea1f82699f9 (diff)
downloadmullvadvpn-3595658d8f0f0f6851f113effcab0d2c93e75cb8.tar.xz
mullvadvpn-3595658d8f0f0f6851f113effcab0d2c93e75cb8.zip
Merge branch 'add-creation-date-to-device-name-in-too-ios-134'
-rw-r--r--ios/MullvadVPN/View controllers/DeviceList/DeviceManagementViewController.swift8
-rw-r--r--ios/MullvadVPN/View controllers/DeviceList/DeviceRowView.swift28
2 files changed, 32 insertions, 4 deletions
diff --git a/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementViewController.swift b/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementViewController.swift
index ff64a5ea43..191b02e799 100644
--- a/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementViewController.swift
+++ b/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementViewController.swift
@@ -104,7 +104,12 @@ class DeviceManagementViewController: UIViewController, RootContainment {
let viewModels = devices.map { restDevice -> DeviceViewModel in
return DeviceViewModel(
id: restDevice.id,
- name: restDevice.name.capitalized
+ name: restDevice.name.capitalized,
+ creationDate: DateFormatter.localizedString(
+ from: restDevice.created,
+ dateStyle: .short,
+ timeStyle: .none
+ )
)
}
@@ -263,4 +268,5 @@ class DeviceManagementViewController: UIViewController, RootContainment {
struct DeviceViewModel {
let id: String
let name: String
+ let creationDate: String
}
diff --git a/ios/MullvadVPN/View controllers/DeviceList/DeviceRowView.swift b/ios/MullvadVPN/View controllers/DeviceList/DeviceRowView.swift
index 088a00237a..c044ebd4e2 100644
--- a/ios/MullvadVPN/View controllers/DeviceList/DeviceRowView.swift
+++ b/ios/MullvadVPN/View controllers/DeviceList/DeviceRowView.swift
@@ -26,6 +26,14 @@ class DeviceRowView: UIView {
return activityIndicator
}()
+ let creationDateLabel: UILabel = {
+ let creationDateLabel = UILabel()
+ creationDateLabel.translatesAutoresizingMaskIntoConstraints = false
+ creationDateLabel.font = UIFont.systemFont(ofSize: 14)
+ creationDateLabel.textColor = .white.withAlphaComponent(0.6)
+ return creationDateLabel
+ }()
+
let removeButton: UIButton = {
let image = UIImage(named: "IconClose")?
.withTintColor(
@@ -65,21 +73,35 @@ class DeviceRowView: UIView {
backgroundColor = .primaryColor
directionalLayoutMargins = UIMetrics.rowViewLayoutMargins
- for subview in [textLabel, removeButton, activityIndicator] {
+ for subview in [textLabel, removeButton, activityIndicator, creationDateLabel] {
addSubview(subview)
}
textLabel.text = viewModel.name
+ creationDateLabel.text = .init(
+ format:
+ NSLocalizedString(
+ "CREATED_DEVICE_LABEL",
+ tableName: "DeviceManagement",
+ value: "Created: %@",
+ comment: ""
+ ),
+ viewModel.creationDate
+ )
removeButton.addTarget(self, action: #selector(handleButtonTap(_:)), for: .touchUpInside)
NSLayoutConstraint.activate([
textLabel.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor),
textLabel.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor),
- textLabel.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor)
+
+ creationDateLabel.leadingAnchor.constraint(equalTo: textLabel.leadingAnchor),
+ creationDateLabel.topAnchor.constraint(equalTo: textLabel.bottomAnchor, constant: 4.0),
+ creationDateLabel.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor)
.withPriority(.defaultLow),
+ creationDateLabel.trailingAnchor.constraint(equalTo: textLabel.trailingAnchor),
- removeButton.centerYAnchor.constraint(equalTo: textLabel.centerYAnchor),
+ removeButton.centerYAnchor.constraint(equalTo: layoutMarginsGuide.centerYAnchor),
removeButton.leadingAnchor.constraint(
greaterThanOrEqualTo: textLabel.trailingAnchor,
constant: 8