Commit 27661b66 authored by Jose Blaya's avatar Jose Blaya
Browse files

Refactor Dashboard

IP Tile
parent d48c4b63
......@@ -162,12 +162,20 @@
DD1C138121E6075B004004B3 /* AvailableTiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C137F21E6075B004004B3 /* AvailableTiles.swift */; };
DD1C138321E60792004004B3 /* Tileable.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C138221E60792004004B3 /* Tileable.swift */; };
DD1C138421E60792004004B3 /* Tileable.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C138221E60792004004B3 /* Tileable.swift */; };
DD1C138621E60BAE004004B3 /* PowerTile.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C138521E60BAE004004B3 /* PowerTile.swift */; };
DD1C138721E60BAE004004B3 /* PowerTile.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C138521E60BAE004004B3 /* PowerTile.swift */; };
DD1C138921E60C63004004B3 /* PowerTile.xib in Resources */ = {isa = PBXBuildFile; fileRef = DD1C138821E60C63004004B3 /* PowerTile.xib */; };
DD1C138A21E60C63004004B3 /* PowerTile.xib in Resources */ = {isa = PBXBuildFile; fileRef = DD1C138821E60C63004004B3 /* PowerTile.xib */; };
DD1C138621E60BAE004004B3 /* IPTile.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C138521E60BAE004004B3 /* IPTile.swift */; };
DD1C138721E60BAE004004B3 /* IPTile.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C138521E60BAE004004B3 /* IPTile.swift */; };
DD1C138921E60C63004004B3 /* IPTile.xib in Resources */ = {isa = PBXBuildFile; fileRef = DD1C138821E60C63004004B3 /* IPTile.xib */; };
DD1C138A21E60C63004004B3 /* IPTile.xib in Resources */ = {isa = PBXBuildFile; fileRef = DD1C138821E60C63004004B3 /* IPTile.xib */; };
DD1C138C21E61797004004B3 /* EnumsBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C138B21E61797004004B3 /* EnumsBuilder.swift */; };
DD1C138D21E61797004004B3 /* EnumsBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C138B21E61797004004B3 /* EnumsBuilder.swift */; };
DD1C139921E65F90004004B3 /* IPTileCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C139721E65F90004004B3 /* IPTileCollectionViewCell.swift */; };
DD1C139A21E65F90004004B3 /* IPTileCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C139721E65F90004004B3 /* IPTileCollectionViewCell.swift */; };
DD1C139B21E65F90004004B3 /* IPTileCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DD1C139821E65F90004004B3 /* IPTileCollectionViewCell.xib */; };
DD1C139C21E65F90004004B3 /* IPTileCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DD1C139821E65F90004004B3 /* IPTileCollectionViewCell.xib */; };
DD1C139E21E6623D004004B3 /* XIBSetup.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C139D21E6623D004004B3 /* XIBSetup.swift */; };
DD1C139F21E6623D004004B3 /* XIBSetup.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C139D21E6623D004004B3 /* XIBSetup.swift */; };
DD1C13A421E6743F004004B3 /* TileFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C13A321E6743F004004B3 /* TileFlowLayout.swift */; };
DD1C13A521E6743F004004B3 /* TileFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C13A321E6743F004004B3 /* TileFlowLayout.swift */; };
DD58F4B821AD579A00D043F7 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = DD58F4B721AD579A00D043F7 /* GoogleService-Info.plist */; };
DD58F4BF21B12CFE00D043F7 /* PIAConnectionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD58F4BE21B12CFE00D043F7 /* PIAConnectionButton.swift */; };
DD58F4C021B12CFE00D043F7 /* PIAConnectionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD58F4BE21B12CFE00D043F7 /* PIAConnectionButton.swift */; };
......@@ -433,9 +441,13 @@
DD1AA4952180AD92005116D7 /* CustomDNSSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomDNSSettingsViewController.swift; sourceTree = "<group>"; };
DD1C137F21E6075B004004B3 /* AvailableTiles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvailableTiles.swift; sourceTree = "<group>"; };
DD1C138221E60792004004B3 /* Tileable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tileable.swift; sourceTree = "<group>"; };
DD1C138521E60BAE004004B3 /* PowerTile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PowerTile.swift; sourceTree = "<group>"; };
DD1C138821E60C63004004B3 /* PowerTile.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PowerTile.xib; sourceTree = "<group>"; };
DD1C138521E60BAE004004B3 /* IPTile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPTile.swift; sourceTree = "<group>"; };
DD1C138821E60C63004004B3 /* IPTile.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = IPTile.xib; sourceTree = "<group>"; };
DD1C138B21E61797004004B3 /* EnumsBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnumsBuilder.swift; sourceTree = "<group>"; };
DD1C139721E65F90004004B3 /* IPTileCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPTileCollectionViewCell.swift; sourceTree = "<group>"; };
DD1C139821E65F90004004B3 /* IPTileCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = IPTileCollectionViewCell.xib; sourceTree = "<group>"; };
DD1C139D21E6623D004004B3 /* XIBSetup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XIBSetup.swift; sourceTree = "<group>"; };
DD1C13A321E6743F004004B3 /* TileFlowLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileFlowLayout.swift; sourceTree = "<group>"; };
DD58F4B721AD579A00D043F7 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
DD58F4BE21B12CFE00D043F7 /* PIAConnectionButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PIAConnectionButton.swift; sourceTree = "<group>"; };
DD6DC5C121B6C27F00F9D538 /* pia-spinner.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "pia-spinner.json"; sourceTree = "<group>"; };
......@@ -620,6 +632,7 @@
0EFDC1D61FE46177007C0B9B /* SensitiveOperation.swift */,
DDD271EF21D6718F00B6D20F /* RegionFilter.swift */,
DD1C138B21E61797004004B3 /* EnumsBuilder.swift */,
DD1C139D21E6623D004004B3 /* XIBSetup.swift */,
);
name = Utils;
sourceTree = "<group>";
......@@ -845,8 +858,11 @@
children = (
DD1C137F21E6075B004004B3 /* AvailableTiles.swift */,
DD1C138221E60792004004B3 /* Tileable.swift */,
DD1C138521E60BAE004004B3 /* PowerTile.swift */,
DD1C138821E60C63004004B3 /* PowerTile.xib */,
DD1C138521E60BAE004004B3 /* IPTile.swift */,
DD1C138821E60C63004004B3 /* IPTile.xib */,
DD1C139721E65F90004004B3 /* IPTileCollectionViewCell.swift */,
DD1C139821E65F90004004B3 /* IPTileCollectionViewCell.xib */,
DD1C13A321E6743F004004B3 /* TileFlowLayout.swift */,
);
path = Tiles;
sourceTree = "<group>";
......@@ -1116,7 +1132,7 @@
0ED66BD020A9918000333B35 /* staging.endpoint in Resources */,
DD6DC5C321B6C27F00F9D538 /* pia-spinner.json in Resources */,
0E0715E7201CBB7100D6F666 /* Flags-dev.plist in Resources */,
DD1C138A21E60C63004004B3 /* PowerTile.xib in Resources */,
DD1C138A21E60C63004004B3 /* IPTile.xib in Resources */,
DD58F4B821AD579A00D043F7 /* GoogleService-Info.plist in Resources */,
DD746958217F070700B7BD73 /* DNS.plist in Resources */,
0E7EC046209326E30029811E /* Localizable.strings in Resources */,
......@@ -1125,6 +1141,7 @@
0ED984201FC48C6500542EE6 /* Roboto-Medium.ttf in Resources */,
0ED984211FC48C6500542EE6 /* Roboto-Regular.ttf in Resources */,
0E3C9A5E20EC004E00B199F9 /* custom.servers in Resources */,
DD1C139C21E65F90004004B3 /* IPTileCollectionViewCell.xib in Resources */,
0EFDC1D51FE4607D007C0B9B /* Images.xcassets in Resources */,
0ED9841F1FC48C6500542EE6 /* Roboto-Light.ttf in Resources */,
0EE2206A1F4EF307002805AE /* Components.plist in Resources */,
......@@ -1161,7 +1178,7 @@
files = (
0ED9841B1FC48C6000542EE6 /* Roboto-Medium.ttf in Resources */,
0ECB08201D61D2A900043852 /* Launch Screen.storyboard in Resources */,
DD1C138921E60C63004004B3 /* PowerTile.xib in Resources */,
DD1C138921E60C63004004B3 /* IPTile.xib in Resources */,
0E7EC045209326E30029811E /* Localizable.strings in Resources */,
0ED9841D1FC48C6000542EE6 /* Roboto-Regular.ttf in Resources */,
291C6398183EBC210039EC03 /* Images.xcassets in Resources */,
......@@ -1172,6 +1189,7 @@
291C6393183EBC210039EC03 /* Main.storyboard in Resources */,
DD6DC5C221B6C27F00F9D538 /* pia-spinner.json in Resources */,
DD746957217F070700B7BD73 /* DNS.plist in Resources */,
DD1C139B21E65F90004004B3 /* IPTileCollectionViewCell.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -1473,6 +1491,7 @@
0E94529A1FDB4DF500891948 /* GradientView.swift in Sources */,
0E7361E91FD98C3400706BFF /* AccountViewController.swift in Sources */,
0E94529D1FDB534000891948 /* ConnectionInfoCell.swift in Sources */,
DD1C13A521E6743F004004B3 /* TileFlowLayout.swift in Sources */,
0EE14D161FF15626008D9AC2 /* UINavigationController+StatusBar.swift in Sources */,
0E1F318720176A6300FC1000 /* Theme+DarkPalette.swift in Sources */,
0ECC1E3F1FDB3F2F0039891D /* RegionsViewController.swift in Sources */,
......@@ -1501,13 +1520,14 @@
0E7361EC1FD99A1000706BFF /* MenuViewController.swift in Sources */,
0EB966781FDF11B80086ABC2 /* Server+UI.swift in Sources */,
DD1C138421E60792004004B3 /* Tileable.swift in Sources */,
DD1C139A21E65F90004004B3 /* IPTileCollectionViewCell.swift in Sources */,
0E9452AC1FDB5EF600891948 /* UINavigationItem+Shortcuts.swift in Sources */,
0E2215CD2008C01D00F5FB4D /* SwiftGen+Assets.swift in Sources */,
0E7361A11FD86F8300706BFF /* AccountObserver.swift in Sources */,
0ECC1E351FDB32470039891D /* WalkthroughViewController.swift in Sources */,
0EFDC1E71FE4ABAA007C0B9B /* Notification+App.swift in Sources */,
0ECC1E3C1FDB3BD50039891D /* WalkthroughPageView.swift in Sources */,
DD1C138721E60BAE004004B3 /* PowerTile.swift in Sources */,
DD1C138721E60BAE004004B3 /* IPTile.swift in Sources */,
0E9452971FDB4C5800891948 /* AboutComponentCell.swift in Sources */,
DD1C138D21E61797004004B3 /* EnumsBuilder.swift in Sources */,
0E53A83C1FE5A156000C2A18 /* AccountProvider+Refresh.swift in Sources */,
......@@ -1517,6 +1537,7 @@
0E492C681FE60907007F23DF /* Flags.swift in Sources */,
0EE14D191FF15812008D9AC2 /* ModalNavigationSegue.swift in Sources */,
0E3A352D1FD9CDC5000B0F99 /* Theme+App.swift in Sources */,
DD1C139F21E6623D004004B3 /* XIBSetup.swift in Sources */,
0E9AEA6320683FDF00B6E59A /* AboutComponent.swift in Sources */,
DD74695B217F07AC00B7BD73 /* DNSList.swift in Sources */,
0E9452AF1FDB5F7A00891948 /* PIAPageControl.swift in Sources */,
......@@ -1565,6 +1586,7 @@
0EFDC1DA1FE4640C007C0B9B /* DNSResolver.swift in Sources */,
0E9452991FDB4DF500891948 /* GradientView.swift in Sources */,
0E7361E81FD98C3400706BFF /* AccountViewController.swift in Sources */,
DD1C13A421E6743F004004B3 /* TileFlowLayout.swift in Sources */,
0E94529C1FDB534000891948 /* ConnectionInfoCell.swift in Sources */,
0EE14D151FF15626008D9AC2 /* UINavigationController+StatusBar.swift in Sources */,
0E1F318620176A5F00FC1000 /* Theme+DarkPalette.swift in Sources */,
......@@ -1593,13 +1615,14 @@
0E441E312055B8A7007528D5 /* Theme+Extension.swift in Sources */,
0E7361EB1FD99A1000706BFF /* MenuViewController.swift in Sources */,
DD1C138321E60792004004B3 /* Tileable.swift in Sources */,
DD1C139921E65F90004004B3 /* IPTileCollectionViewCell.swift in Sources */,
0EB966771FDF11B80086ABC2 /* Server+UI.swift in Sources */,
0E9452AB1FDB5EF600891948 /* UINavigationItem+Shortcuts.swift in Sources */,
0E2215CC2008BF8300F5FB4D /* SwiftGen+Assets.swift in Sources */,
0E7361A01FD86F8300706BFF /* AccountObserver.swift in Sources */,
0ECC1E341FDB32470039891D /* WalkthroughViewController.swift in Sources */,
0EFDC1E61FE4ABAA007C0B9B /* Notification+App.swift in Sources */,
DD1C138621E60BAE004004B3 /* PowerTile.swift in Sources */,
DD1C138621E60BAE004004B3 /* IPTile.swift in Sources */,
0ECC1E3B1FDB3BD50039891D /* WalkthroughPageView.swift in Sources */,
DD1C138C21E61797004004B3 /* EnumsBuilder.swift in Sources */,
0E9452961FDB4C5800891948 /* AboutComponentCell.swift in Sources */,
......@@ -1609,6 +1632,7 @@
0E492C671FE60907007F23DF /* Flags.swift in Sources */,
0EE14D181FF15812008D9AC2 /* ModalNavigationSegue.swift in Sources */,
0E3A352C1FD9CDC5000B0F99 /* Theme+App.swift in Sources */,
DD1C139E21E6623D004004B3 /* XIBSetup.swift in Sources */,
0E9AEA6220683FDF00B6E59A /* AboutComponent.swift in Sources */,
DD74695A217F07AC00B7BD73 /* DNSList.swift in Sources */,
0E9452AE1FDB5F7A00891948 /* PIAPageControl.swift in Sources */,
......
......@@ -18,7 +18,7 @@ struct AppConfiguration {
}
struct About {
static let copyright = "2014-2018"
static let copyright = "2014-2019"
static let companyName = "London Trust Media, Inc."
}
......
......@@ -14,8 +14,10 @@ import SwiftyBeaver
private let log = SwiftyBeaver.self
class DashboardViewController: AutolayoutViewController {
private struct Cells {
static let info = "InfoCell"
static let tile = "IPTileCell"
static let tileCellClass = "IPTileCollectionViewCell"
}
@IBOutlet private weak var viewContent: UIView!
......@@ -28,7 +30,7 @@ class DashboardViewController: AutolayoutViewController {
@IBOutlet private weak var viewRows: UIView!
@IBOutlet private weak var tableRows: UITableView!
@IBOutlet private weak var collectionView: UICollectionView!
// iPad only
......@@ -62,6 +64,11 @@ class DashboardViewController: AutolayoutViewController {
override func viewDidLoad() {
super.viewDidLoad()
collectionView.register(UINib(nibName: Cells.tileCellClass,
bundle: nil),
forCellWithReuseIdentifier: Cells.tile)
collectionView.backgroundColor = .clear
navigationItem.leftBarButtonItem = UIBarButtonItem(
image: Asset.itemMenu.image,
......@@ -356,7 +363,7 @@ class DashboardViewController: AutolayoutViewController {
}
// non-iPad bottom table
tableRows.reloadData()
collectionView.reloadData()
}
@objc private func updateCurrentIP() {
......@@ -383,7 +390,7 @@ class DashboardViewController: AutolayoutViewController {
}
// non-iPad bottom table
tableRows.reloadData()
collectionView.reloadData()
}
// MARK: Restylable
......@@ -404,8 +411,9 @@ class DashboardViewController: AutolayoutViewController {
Theme.current.applyTextButton(buttonChangeRegion)
// XXX: emulate native UITableView separator
Theme.current.applyDividerToSeparator(tableRows)
tableRows.reloadData()
//Theme.current.applyDividerToSeparator(tableRows)
collectionView.collectionViewLayout.invalidateLayout()
collectionView.reloadData()
}
private func resetNavigationBar() {
......@@ -475,48 +483,72 @@ extension DashboardViewController: MenuViewControllerDelegate {
}
}
extension DashboardViewController: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: Cells.info, for: indexPath) as! ConnectionInfoCell
switch indexPath.row {
case 0:
let server = Client.preferences.displayedServer
cell.fill(
withTitle: L10n.Dashboard.Connection.Region.caption,
server: server,
status: currentStatus
)
cell.accessoryType = .disclosureIndicator
cell.selectionStyle = .gray
cell.accessibilityIdentifier = "uitests.main.pick_region"
case 1:
cell.fill(
withTitle: L10n.Dashboard.Connection.Ip.caption,
description: currentIP
)
cell.accessoryType = .none
cell.selectionStyle = .none
default:
fatalError("Unexpected cell row")
}
return cell
extension DashboardViewController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath) -> CGSize {
/*
let paddingSpace = (sectionInsets.left) * (CGFloat(itemsPerRow) + 1)
let availableWidth = view.frame.width - paddingSpace - (UIDevice.current.orientation == UIDeviceOrientation.portrait ? 0 : safeAreaMargin)
var widthPerItem = availableWidth / CGFloat(itemsPerRow)
if let itemSize = self.itemSize {
widthPerItem = itemSize.width
}
let actualSize = CGSize(width: widthPerItem, height: widthPerItem)
if let sizingCell = UINib(nibName: cellClass,
bundle: nil).instantiate(withOwner: nil,
options: nil).first as? ValueChartLegendCollectionViewCell {
sizingCell.autoresizingMask = [.flexibleWidth, .flexibleHeight]
sizingCell.frame.size = actualSize
switch indexPath.row {
case 0:
sizingCell.displayContentWith(dataset: ValueChartLegendContributionDataset())
case 1:
sizingCell.displayContentWith(dataset: ValueChartLegendValueDataset())
default:
sizingCell.displayContentWith(dataset: ValueChartLegendSimpleReturnDataset())
}
return sizingCell.contentView.systemLayoutSizeFitting(actualSize,
withHorizontalFittingPriority: UILayoutPriority.required,
verticalFittingPriority: UILayoutPriority.defaultLow)
}
*/
return CGSize(width: collectionView.frame.width, height: 89)
}
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets.zero
}
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
extension DashboardViewController: UICollectionViewDelegate, UICollectionViewDataSource {
switch (indexPath.row) {
case 0:
selectRegion(animated: true)
default:
break
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: Cells.tile, for: indexPath) as! IPTileCollectionViewCell
return cell
}
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return AvailableTiles.countCases()
}
}
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "triangleRightCopy.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -68,6 +68,9 @@ enum Asset {
static let darkSplash = ImageAsset(name: "dark-splash")
static let lightSplash = ImageAsset(name: "light-splash")
}
enum Tiles {
static let ipTriangle = ImageAsset(name: "ip-triangle")
}
}
static let accessoryExpire = ImageAsset(name: "accessory-expire")
static let accessorySelected = ImageAsset(name: "accessory-selected")
......@@ -342,6 +345,7 @@ enum Asset {
Piax.Regions.noResultsLight,
Piax.Splash.darkSplash,
Piax.Splash.lightSplash,
Piax.Tiles.ipTriangle,
accessoryExpire,
accessorySelected,
buttonBackgroundToggleConnected,
......
......@@ -8,15 +8,6 @@
import Foundation
enum TileSections: Int, EnumsBuilder {
case power
case tiles
}
enum AvailablePowerTiles: Int, EnumsBuilder {
case power
}
enum AvailableTiles: Int, EnumsBuilder {
case regions
case ip
......
//
// IPTile.swift
// PIA VPN
//
// Created by Jose Antonio Blaya Garcia on 09/01/2019.
// Copyright © 2019 London Trust Media. All rights reserved.
//
import UIKit
import PIALibrary
class IPTile: UIView, Tileable {
var detailViewAction: Func!
var view: UIView!
var detailSegueIdentifier: String!
@IBOutlet private weak var localIpTitle: UILabel!
@IBOutlet private weak var localIpValue: UILabel!
@IBOutlet private weak var vpnIpTitle: UILabel!
@IBOutlet private weak var vpnIpValue: UILabel!
override init(frame: CGRect) {
super.init(frame: frame)
self.xibSetup()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.xibSetup()
self.setupView()
}
deinit {
NotificationCenter.default.removeObserver(self)
}
private func setupView() {
let nc = NotificationCenter.default
nc.addObserver(self, selector: #selector(updateCurrentIP), name: .PIADaemonsDidUpdateConnectivity, object: nil)
nc.addObserver(self, selector: #selector(viewShouldRestyle), name: .PIAThemeDidChange, object: nil)
viewShouldRestyle()
self.detailViewAction = {}
self.localIpTitle.text = "IP"
self.vpnIpTitle.text = "VPN IP"
self.localIpValue.text = "---"
self.vpnIpValue.text = "---"
}
@objc private func viewShouldRestyle() {
Theme.current.applySubtitle(localIpTitle)
Theme.current.applySubtitle(vpnIpTitle)
Theme.current.applySubtitle(localIpValue)
Theme.current.applySettingsCellTitle(vpnIpValue, appearance: .dark)
Theme.current.applyLightBackground(self)
}
@objc private func updateCurrentIP() {
self.localIpValue.text = Client.daemons.publicIP
let vpn = Client.providers.vpnProvider
if (vpn.vpnStatus == .connected) {
self.vpnIpValue.text = Client.daemons.vpnIP
self.localIpValue.text = Client.daemons.publicIP
} else if (!Client.daemons.isInternetReachable && (vpn.vpnStatus == .disconnected)) {
self.vpnIpValue.text = L10n.Dashboard.Connection.Ip.unreachable
self.localIpValue.text = "---"
} else {
self.vpnIpValue.text = "---"
self.localIpValue.text = "---"
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="IPTile" customModule="PIA_VPN" customModuleProvider="target">
<connections>
<outlet property="localIpTitle" destination="jwP-tn-mQv" id="CXr-Wt-eRL"/>
<outlet property="localIpValue" destination="xR4-ef-XuZ" id="wgZ-if-UNN"/>
<outlet property="vpnIpTitle" destination="ltV-Wi-R5o" id="1DD-vd-o3W"/>
<outlet property="vpnIpValue" destination="Eay-Yz-Xzw" id="3TH-9b-cOv"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="365" height="89"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jwP-tn-mQv">
<rect key="frame" x="25" y="25" width="142.5" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xR4-ef-XuZ">
<rect key="frame" x="25" y="43" width="142.5" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ip-triangle" translatesAutoresizingMaskIntoConstraints="NO" id="tN8-Zr-Ghy">
<rect key="frame" x="177.5" y="34.5" width="10" height="20"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ltV-Wi-R5o">
<rect key="frame" x="212.5" y="25" width="42" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Eay-Yz-Xzw">
<rect key="frame" x="212.5" y="43" width="42" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="xR4-ef-XuZ" secondAttribute="bottom" constant="25" id="8tV-FJ-mfh"/>
<constraint firstItem="tN8-Zr-Ghy" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="9RF-ve-FfN"/>
<constraint firstItem="tN8-Zr-Ghy" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="BKS-cA-to7"/>
<constraint firstItem="tN8-Zr-Ghy" firstAttribute="leading" secondItem="xR4-ef-XuZ" secondAttribute="trailing" constant="10" id="D1I-SK-pbS"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="ltV-Wi-R5o" secondAttribute="trailing" constant="25" id="Lcj-VC-5XS"/>
<constraint firstItem="ltV-Wi-R5o" firstAttribute="leading" secondItem="tN8-Zr-Ghy" secondAttribute="trailing" constant="25" id="QXM-eK-hsL"/>
<constraint firstItem="xR4-ef-XuZ" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="25" id="VJC-nl-WDP"/>
<constraint firstItem="jwP-tn-mQv" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="25" id="Ztt-W7-0Lm"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="Eay-Yz-Xzw" secondAttribute="trailing" constant="25" id="aNJ-H3-D8Y"/>
<constraint firstItem="Eay-Yz-Xzw" firstAttribute="leading" secondItem="tN8-Zr-Ghy" secondAttribute="trailing" constant="25" id="f4S-Uh-IWi"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="Eay-Yz-Xzw" secondAttribute="bottom" constant="25" id="hwQ-GU-FEE"/>
<constraint firstItem="tN8-Zr-Ghy" firstAttribute="leading" secondItem="jwP-tn-mQv" secondAttribute="trailing" constant="10" id="kQA-aY-eE4"/>
<constraint firstItem="ltV-Wi-R5o" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="25" id="wB5-JM-g0c"/>
<constraint firstItem="jwP-tn-mQv" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="25" id="wcu-HH-Nfl"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<point key="canvasLocation" x="264.80000000000001" y="-654.87256371814101"/>
</view>
</objects>
<resources>
<image name="ip-triangle" width="10" height="20"/>
</resources>
</document>
//
// IPTileCollectionViewCell.swift
// PIA VPN
//
// Created by Jose Antonio Blaya Garcia on 09/01/2019.
// Copyright © 2019 London Trust Media. All rights reserved.
//
import UIKit
import PIALibrary
class IPTileCollectionViewCell: UICollectionViewCell {
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
}
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>