aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2020-12-15 14:21:21 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-12-15 15:56:22 +0100
commit9a483a46faa46f4a58d0087af75e77e87925ca61 (patch)
treee2b7864695f05b346e8ac1a386316733615496a5
parentWireGuardApp: Remove 200ms delay when updating tunnel status switch (diff)
downloadwireguard-apple-9a483a46faa46f4a58d0087af75e77e87925ca61.tar.xz
wireguard-apple-9a483a46faa46f4a58d0087af75e77e87925ca61.zip
WireGuardApp: Animate switch control in TunnelListCell
Signed-off-by: Andrej Mihajlov <and@mullvad.net>
-rw-r--r--Sources/WireGuardApp/UI/iOS/View/TunnelListCell.swift18
1 files changed, 9 insertions, 9 deletions
diff --git a/Sources/WireGuardApp/UI/iOS/View/TunnelListCell.swift b/Sources/WireGuardApp/UI/iOS/View/TunnelListCell.swift
index 1a8520d..636443e 100644
--- a/Sources/WireGuardApp/UI/iOS/View/TunnelListCell.swift
+++ b/Sources/WireGuardApp/UI/iOS/View/TunnelListCell.swift
@@ -5,16 +5,16 @@ import UIKit
class TunnelListCell: UITableViewCell {
var tunnel: TunnelContainer? {
- didSet(value) {
+ didSet {
// Bind to the tunnel's name
nameLabel.text = tunnel?.name ?? ""
nameObservationToken = tunnel?.observe(\.name) { [weak self] tunnel, _ in
self?.nameLabel.text = tunnel.name
}
// Bind to the tunnel's status
- update(from: tunnel?.status)
+ update(from: tunnel?.status, animated: false)
statusObservationToken = tunnel?.observe(\.status) { [weak self] tunnel, _ in
- self?.update(from: tunnel.status)
+ self?.update(from: tunnel.status, animated: true)
}
}
}
@@ -82,12 +82,12 @@ class TunnelListCell: UITableViewCell {
onSwitchToggled?(statusSwitch.isOn)
}
- private func update(from status: TunnelStatus?) {
+ private func update(from status: TunnelStatus?, animated: Bool) {
guard let status = status else {
- reset()
+ reset(animated: animated)
return
}
- statusSwitch.isOn = !(status == .deactivating || status == .inactive)
+ statusSwitch.setOn(!(status == .deactivating || status == .inactive), animated: animated)
statusSwitch.isUserInteractionEnabled = (status == .inactive || status == .active)
if status == .inactive || status == .active {
busyIndicator.stopAnimating()
@@ -105,14 +105,14 @@ class TunnelListCell: UITableViewCell {
statusSwitch.isEnabled = !editing
}
- private func reset() {
- statusSwitch.isOn = false
+ private func reset(animated: Bool) {
+ statusSwitch.setOn(false, animated: animated)
statusSwitch.isUserInteractionEnabled = false
busyIndicator.stopAnimating()
}
override func prepareForReuse() {
super.prepareForReuse()
- reset()
+ reset(animated: false)
}
}