Server code to fetch and toggle devices
This commit is contained in:
@@ -9,9 +9,9 @@
|
||||
import UIKit
|
||||
|
||||
class ConnectionStatusView: UIView {
|
||||
private var _connectivityStatus:Bool = false
|
||||
private var _japaneseLabel: UILabel = UILabel()
|
||||
private var _englishLabel: UILabel = UILabel()
|
||||
private var _connectivityStatus: ConnectionStatus = .Disconnected
|
||||
private var _japaneseLabel: UILabel = UILabel()
|
||||
private var _englishLabel: UILabel = UILabel()
|
||||
|
||||
static private let labelsVMargin: CGFloat = 5.0
|
||||
|
||||
@@ -27,7 +27,7 @@ class ConnectionStatusView: UIView {
|
||||
_englishLabel.textColor = UIColor.whiteColor()
|
||||
self.addSubview(_englishLabel)
|
||||
|
||||
self.connectivityStatus = false
|
||||
self.connectivityStatus = .Disconnected
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder)
|
||||
@@ -74,7 +74,7 @@ class ConnectionStatusView: UIView {
|
||||
|
||||
// MARK: API
|
||||
|
||||
var connectivityStatus: Bool
|
||||
var connectivityStatus: ConnectionStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -85,17 +85,30 @@ class ConnectionStatusView: UIView {
|
||||
{
|
||||
_connectivityStatus = newStatus
|
||||
|
||||
if (_connectivityStatus == true) {
|
||||
switch (_connectivityStatus) {
|
||||
case .Disconnected:
|
||||
_japaneseLabel.text = "非直結"
|
||||
_japaneseLabel.textColor = UIColor.redColor()
|
||||
|
||||
_englishLabel.text = "offline"
|
||||
_englishLabel.textColor = UIColor.redColor()
|
||||
case .Connecting:
|
||||
_japaneseLabel.text = "接続中"
|
||||
_japaneseLabel.textColor = UIColor.yellowColor()
|
||||
|
||||
_englishLabel.text = "connecting..."
|
||||
_englishLabel.textColor = UIColor.yellowColor()
|
||||
case .Connected:
|
||||
_japaneseLabel.text = "直結"
|
||||
_japaneseLabel.textColor = UIColor.greenColor()
|
||||
|
||||
_englishLabel.text = "online"
|
||||
_englishLabel.textColor = UIColor.greenColor()
|
||||
} else {
|
||||
_japaneseLabel.text = "非直結"
|
||||
case .Error:
|
||||
_japaneseLabel.text = "過失"
|
||||
_japaneseLabel.textColor = UIColor.redColor()
|
||||
|
||||
_englishLabel.text = "offline"
|
||||
_englishLabel.text = "error"
|
||||
_englishLabel.textColor = UIColor.redColor()
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ public class WemoDeviceCellView: WemoCellView {
|
||||
}
|
||||
|
||||
public class WemoActionCellView: WemoCellView {
|
||||
public var textLabel: UILabel = UILabel()
|
||||
var textLabel: UILabel = UILabel()
|
||||
|
||||
override init(frame: CGRect)
|
||||
{
|
||||
@@ -197,4 +197,16 @@ public class WemoActionCellView: WemoCellView {
|
||||
super.layoutSubviews()
|
||||
self.textLabel.frame = self.bounds
|
||||
}
|
||||
|
||||
var enabled: Bool = true
|
||||
{
|
||||
didSet
|
||||
{
|
||||
if (enabled) {
|
||||
self.textLabel.textColor = UIColor.whiteColor()
|
||||
} else {
|
||||
self.textLabel.textColor = UIColor.darkGrayColor()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user