Connectivity status indicator view
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
0C41EF501C34B97700AF847F /* HeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C41EF4F1C34B97700AF847F /* HeaderView.swift */; };
|
||||
0C41EF521C34BA4E00AF847F /* Orbitron-Medium.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0C41EF511C34BA4E00AF847F /* Orbitron-Medium.ttf */; };
|
||||
0C41EF541C34BC9800AF847F /* XIONLogoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C41EF531C34BC9800AF847F /* XIONLogoView.swift */; };
|
||||
0C41EF561C35ABCD00AF847F /* ConnectionStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C41EF551C35ABCD00AF847F /* ConnectionStatusView.swift */; };
|
||||
0C63A8731C337381007E4B52 /* CubletsTechnique.plist in Resources */ = {isa = PBXBuildFile; fileRef = 0C63A8721C337381007E4B52 /* CubletsTechnique.plist */; };
|
||||
0C63A8761C3373D1007E4B52 /* HorizontalBlur.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 0C63A8751C3373D1007E4B52 /* HorizontalBlur.vsh */; };
|
||||
0C63A8781C3373D9007E4B52 /* HorizontalBlur.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 0C63A8771C3373D9007E4B52 /* HorizontalBlur.fsh */; };
|
||||
@@ -43,6 +44,7 @@
|
||||
0C41EF4F1C34B97700AF847F /* HeaderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderView.swift; sourceTree = "<group>"; };
|
||||
0C41EF511C34BA4E00AF847F /* Orbitron-Medium.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Orbitron-Medium.ttf"; sourceTree = "<group>"; };
|
||||
0C41EF531C34BC9800AF847F /* XIONLogoView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XIONLogoView.swift; sourceTree = "<group>"; };
|
||||
0C41EF551C35ABCD00AF847F /* ConnectionStatusView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConnectionStatusView.swift; sourceTree = "<group>"; };
|
||||
0C63A8721C337381007E4B52 /* CubletsTechnique.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = CubletsTechnique.plist; sourceTree = "<group>"; };
|
||||
0C63A8751C3373D1007E4B52 /* HorizontalBlur.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = HorizontalBlur.vsh; sourceTree = "<group>"; };
|
||||
0C63A8771C3373D9007E4B52 /* HorizontalBlur.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = HorizontalBlur.fsh; sourceTree = "<group>"; };
|
||||
@@ -108,6 +110,7 @@
|
||||
0C20E2B81C33514100BA789B /* Views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0C41EF551C35ABCD00AF847F /* ConnectionStatusView.swift */,
|
||||
0C41EF4F1C34B97700AF847F /* HeaderView.swift */,
|
||||
0C41EF531C34BC9800AF847F /* XIONLogoView.swift */,
|
||||
);
|
||||
@@ -270,6 +273,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
0C41EF4E1C34B81F00AF847F /* KSIRingView.m in Sources */,
|
||||
0C41EF561C35ABCD00AF847F /* ConnectionStatusView.swift in Sources */,
|
||||
0C63A87D1C33C655007E4B52 /* NSValue+XIONAdditions.m in Sources */,
|
||||
0C20E2BD1C33534F00BA789B /* VisualizationViewController.swift in Sources */,
|
||||
0C41EF4A1C34B51500AF847F /* ArcadeMachinesViewController.swift in Sources */,
|
||||
|
||||
@@ -69,12 +69,12 @@ class MainViewController: UIViewController {
|
||||
|
||||
override func viewDidAppear(animated: Bool)
|
||||
{
|
||||
_headerView.beginAnimating()
|
||||
_headerView.xionLogoView.beginAnimating()
|
||||
}
|
||||
|
||||
override func viewDidDisappear(animated: Bool)
|
||||
{
|
||||
_headerView.stopAnimating()
|
||||
_headerView.xionLogoView.stopAnimating()
|
||||
}
|
||||
|
||||
override func prefersStatusBarHidden() -> Bool
|
||||
|
||||
104
XIONControlPanel/Views/ConnectionStatusView.swift
Normal file
104
XIONControlPanel/Views/ConnectionStatusView.swift
Normal file
@@ -0,0 +1,104 @@
|
||||
//
|
||||
// ConnectionStatusView.swift
|
||||
// XIONControlPanel
|
||||
//
|
||||
// Created by Charles Magahern on 12/31/15.
|
||||
// Copyright © 2015 XION. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class ConnectionStatusView: UIView {
|
||||
private var _connectivityStatus:Bool = false
|
||||
private var _japaneseLabel: UILabel = UILabel()
|
||||
private var _englishLabel: UILabel = UILabel()
|
||||
|
||||
static private let labelsVMargin: CGFloat = 5.0
|
||||
|
||||
override init(frame: CGRect)
|
||||
{
|
||||
super.init(frame: frame)
|
||||
|
||||
_japaneseLabel.font = UIFont(name: "Orbitron-Medium", size: 24.0)
|
||||
_japaneseLabel.textColor = UIColor.whiteColor()
|
||||
self.addSubview(_japaneseLabel)
|
||||
|
||||
_englishLabel.font = UIFont(name: "Orbitron-Medium", size: 16.0)
|
||||
_englishLabel.textColor = UIColor.whiteColor()
|
||||
self.addSubview(_englishLabel)
|
||||
|
||||
self.connectivityStatus = false
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder)
|
||||
{
|
||||
fatalError("unsupported")
|
||||
}
|
||||
|
||||
// MARK: Overrides
|
||||
|
||||
override func sizeThatFits(size: CGSize) -> CGSize
|
||||
{
|
||||
let labelsVMargin = ConnectionStatusView.labelsVMargin
|
||||
let jpLabelSize = _japaneseLabel.sizeThatFits(size)
|
||||
let enLabelSize = _englishLabel.sizeThatFits(size)
|
||||
let totalLabelsHeight = jpLabelSize.height + labelsVMargin + enLabelSize.height
|
||||
let maxLabelsWidth = max(jpLabelSize.width, enLabelSize.width)
|
||||
return CGSize(width: maxLabelsWidth, height: totalLabelsHeight)
|
||||
}
|
||||
|
||||
override func layoutSubviews()
|
||||
{
|
||||
super.layoutSubviews()
|
||||
|
||||
let bounds = self.bounds
|
||||
let labelsVMargin = ConnectionStatusView.labelsVMargin
|
||||
let jpLabelSize = _japaneseLabel.sizeThatFits(bounds.size)
|
||||
let enLabelSize = _englishLabel.sizeThatFits(bounds.size)
|
||||
let totalLabelsHeight = jpLabelSize.height + labelsVMargin + enLabelSize.height
|
||||
|
||||
_japaneseLabel.frame = CGRect(
|
||||
x: rint(bounds.size.width / 2.0 - jpLabelSize.width / 2.0),
|
||||
y: rint(bounds.size.height / 2.0 - totalLabelsHeight / 2.0),
|
||||
width: jpLabelSize.width,
|
||||
height: jpLabelSize.height
|
||||
)
|
||||
|
||||
_englishLabel.frame = CGRect(
|
||||
x: rint(bounds.size.width / 2.0 - enLabelSize.width / 2.0),
|
||||
y: CGRectGetMaxY(_japaneseLabel.frame) + labelsVMargin,
|
||||
width: enLabelSize.width,
|
||||
height: enLabelSize.height
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: API
|
||||
|
||||
var connectivityStatus: Bool {
|
||||
get
|
||||
{
|
||||
return _connectivityStatus
|
||||
}
|
||||
|
||||
set(newStatus)
|
||||
{
|
||||
_connectivityStatus = newStatus
|
||||
|
||||
if (_connectivityStatus == true) {
|
||||
_japaneseLabel.text = "直結"
|
||||
_japaneseLabel.textColor = UIColor.greenColor()
|
||||
|
||||
_englishLabel.text = "online"
|
||||
_englishLabel.textColor = UIColor.greenColor()
|
||||
} else {
|
||||
_japaneseLabel.text = "非直結"
|
||||
_japaneseLabel.textColor = UIColor.redColor()
|
||||
|
||||
_englishLabel.text = "offline"
|
||||
_englishLabel.textColor = UIColor.redColor()
|
||||
}
|
||||
|
||||
self.setNeedsLayout()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,9 @@ import Foundation
|
||||
import UIKit
|
||||
|
||||
class HeaderView: UIView {
|
||||
private var _xionLogoView: XIONLogoView = XIONLogoView()
|
||||
var xionLogoView: XIONLogoView = XIONLogoView()
|
||||
var connectionStatusView: ConnectionStatusView = ConnectionStatusView()
|
||||
|
||||
private var _xionTitleLabel: UILabel = UILabel()
|
||||
private var _xionJapaneseLabel: UILabel = UILabel()
|
||||
|
||||
@@ -20,7 +22,7 @@ class HeaderView: UIView {
|
||||
super.init(frame: frame)
|
||||
|
||||
self.backgroundColor = UIColor.blackColor()
|
||||
self.addSubview(_xionLogoView)
|
||||
self.addSubview(self.xionLogoView)
|
||||
|
||||
_xionTitleLabel.font = UIFont(name: "Orbitron-Medium", size: 16.0)
|
||||
_xionTitleLabel.text = "XION arcade system control panel"
|
||||
@@ -31,6 +33,8 @@ class HeaderView: UIView {
|
||||
_xionJapaneseLabel.text = "ザイーオンゲームセンターのシステム制御プログラム"
|
||||
_xionJapaneseLabel.textColor = UIColor.whiteColor()
|
||||
self.addSubview(_xionJapaneseLabel)
|
||||
|
||||
self.addSubview(self.connectionStatusView)
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder)
|
||||
@@ -52,7 +56,7 @@ class HeaderView: UIView {
|
||||
width: logoDimensions,
|
||||
height: logoDimensions
|
||||
)
|
||||
_xionLogoView.frame = logoFrame
|
||||
self.xionLogoView.frame = logoFrame
|
||||
|
||||
let titleJPVerticalMargin: CGFloat = 5.0
|
||||
let titleLabelSize = _xionTitleLabel.sizeThatFits(bounds.size)
|
||||
@@ -74,17 +78,14 @@ class HeaderView: UIView {
|
||||
height: jpLabelSize.height + 2.0
|
||||
)
|
||||
_xionJapaneseLabel.frame = jpTitleFrame
|
||||
}
|
||||
|
||||
// MARK: API
|
||||
|
||||
func beginAnimating()
|
||||
{
|
||||
_xionLogoView.beginAnimating()
|
||||
}
|
||||
|
||||
func stopAnimating()
|
||||
{
|
||||
_xionLogoView.stopAnimating()
|
||||
let connectionStatusDimensions = CGSize(width: rint((1.0 / 8.0) * bounds.size.width), height: bounds.size.height)
|
||||
let connectionStatusFrame = CGRect(
|
||||
x: bounds.size.width - connectionStatusDimensions.width,
|
||||
y: 0.0,
|
||||
width: connectionStatusDimensions.width,
|
||||
height: connectionStatusDimensions.height
|
||||
)
|
||||
self.connectionStatusView.frame = connectionStatusFrame
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user