Commit d8570884 authored by Jose Blaya's avatar Jose Blaya
Browse files

wip

parent 6bea24d3
This diff is collapsed.
......@@ -20,12 +20,14 @@ class DashboardViewController: AutolayoutViewController {
case region = 0
case quickConnect
case ipTile
case subscription
var identifier: String {
switch self {
case .ipTile: return "IPTileCell"
case .quickConnect: return "QuickConnectTileCell"
case .region: return "RegionTileCell"
case .subscription: return "SubscriptionTileCell"
}
}
......@@ -34,6 +36,7 @@ class DashboardViewController: AutolayoutViewController {
case .ipTile: return "IPTileCollectionViewCell"
case .quickConnect: return "QuickConnectTileCollectionViewCell"
case .region: return "RegionTileCollectionViewCell"
case .subscription: return "SubscriptionTileCollectionViewCell"
}
}
}
......@@ -67,16 +70,7 @@ class DashboardViewController: AutolayoutViewController {
override func viewDidLoad() {
super.viewDidLoad()
collectionView.register(UINib(nibName: Cells.ipTile.className,
bundle: nil),
forCellWithReuseIdentifier: Cells.ipTile.identifier)
collectionView.register(UINib(nibName: Cells.quickConnect.className,
bundle: nil),
forCellWithReuseIdentifier: Cells.quickConnect.identifier)
collectionView.register(UINib(nibName: Cells.region.className,
bundle: nil),
forCellWithReuseIdentifier: Cells.region.identifier)
collectionView.backgroundColor = .clear
setupCollectionView()
navigationItem.leftBarButtonItem = UIBarButtonItem(
image: Asset.itemMenu.image,
......@@ -181,6 +175,22 @@ class DashboardViewController: AutolayoutViewController {
}
// MARK: Actions
private func setupCollectionView() {
collectionView.register(UINib(nibName: Cells.ipTile.className,
bundle: nil),
forCellWithReuseIdentifier: Cells.ipTile.identifier)
collectionView.register(UINib(nibName: Cells.quickConnect.className,
bundle: nil),
forCellWithReuseIdentifier: Cells.quickConnect.identifier)
collectionView.register(UINib(nibName: Cells.region.className,
bundle: nil),
forCellWithReuseIdentifier: Cells.region.identifier)
collectionView.register(UINib(nibName: Cells.subscription.className,
bundle: nil),
forCellWithReuseIdentifier: Cells.subscription.identifier)
collectionView.backgroundColor = .clear
}
private func updateTileLayout() {
UIView.animate(withDuration: AppConfiguration.Animations.duration, animations: {
self.toggleConnection.alpha = self.tileModeStatus == .normal ? 1 : 0
......
......@@ -501,6 +501,10 @@ internal enum L10n {
/// VPN Server
internal static let title = L10n.tr("Localizable", "tiles.region.title")
}
internal enum Subscription {
/// Subscription
internal static let title = L10n.tr("Localizable", "tiles.subscription.title")
}
}
internal enum VpnPermission {
......
......@@ -29,8 +29,8 @@ class IPTileCollectionViewCell: UICollectionViewCell, TileableCell {
self.tileLeftConstraint.constant = 0
self.tileRightConstraint.constant = 0
case .edit:
self.tileLeftConstraint.constant = 34
self.tileRightConstraint.constant = 40
self.tileLeftConstraint.constant = self.leftConstraintValue
self.tileRightConstraint.constant = self.rightConstraintValue
self.setupVisibilityButton()
}
self.layoutIfNeeded()
......
......@@ -29,8 +29,8 @@ class QuickConnectTileCollectionViewCell: UICollectionViewCell, TileableCell {
self.tileLeftConstraint.constant = 0
self.tileRightConstraint.constant = 0
case .edit:
self.tileLeftConstraint.constant = 34
self.tileRightConstraint.constant = 40
self.tileLeftConstraint.constant = self.leftConstraintValue
self.tileRightConstraint.constant = self.rightConstraintValue
self.setupVisibilityButton()
}
self.layoutIfNeeded()
......
......@@ -37,7 +37,7 @@ class RegionTileCollectionViewCell: UICollectionViewCell, TileableCell {
self.tileLeftConstraint.constant = 0
case .edit:
self.accessoryImageRight.image = Theme.current.dragDropImage()
self.tileLeftConstraint.constant = 34
self.tileLeftConstraint.constant = self.leftConstraintValue
self.setupVisibilityButton()
}
self.layoutIfNeeded()
......
//
// SubscriptionTile.swift
// PIA VPN
//
// Created by Jose Antonio Blaya Garcia on 14/01/2019.
// Copyright © 2019 London Trust Media. All rights reserved.
//
import UIKit
import PIALibrary
class SubscriptionTile: UIView, Tileable {
var view: UIView!
var detailSegueIdentifier: String!
var status: TileStatus = .normal
@IBOutlet private weak var subscriptionTitle: UILabel!
@IBOutlet private weak var subscriptionValue: 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(viewShouldRestyle), name: .PIAThemeDidChange, object: nil)
nc.addObserver(self, selector: #selector(displayAccountInformation), name: .PIAAccountDidRefresh, object: nil)
viewShouldRestyle()
self.subscriptionTitle.text = L10n.Tiles.Subscription.title.uppercased()
displayAccountInformation()
}
@objc private func viewShouldRestyle() {
subscriptionTitle.style(style: TextStyle.textStyle21)
Theme.current.applySubtitle(subscriptionValue)
Theme.current.applySolidLightBackground(self)
}
@objc private func displayAccountInformation() {
let currentUser = Client.providers.accountProvider.currentUser
if let userInfo = currentUser?.info {
if userInfo.isExpired {
self.subscriptionValue.text = L10n.Account.ExpiryDate.expired
} else {
self.subscriptionValue.text = L10n.Account.ExpiryDate.information(userInfo.humanReadableExpirationDate())
}
Theme.current.makeSmallLabelToStandOut(self.subscriptionValue,
withTextToStandOut: userInfo.humanReadableExpirationDate())
}
}
}
<?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="SubscriptionTile" customModule="PIA_VPN" customModuleProvider="target">
<connections>
<outlet property="subscriptionTitle" destination="cIz-i0-fhA" id="XIt-ep-bqJ"/>
<outlet property="subscriptionValue" destination="kcM-dW-3t2" id="53m-1O-uFO"/>
</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="375" height="89"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cIz-i0-fhA">
<rect key="frame" x="25" y="25" width="325" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kcM-dW-3t2">
<rect key="frame" x="25" y="43" width="325" 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="cIz-i0-fhA" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="25" id="Lml-9m-EoE"/>
<constraint firstItem="cIz-i0-fhA" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="25" id="bwQ-Rn-2Uj"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="kcM-dW-3t2" secondAttribute="bottom" constant="25" id="maK-pK-gfN"/>
<constraint firstItem="kcM-dW-3t2" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="25" id="p2M-PL-nP1"/>
<constraint firstAttribute="trailing" secondItem="cIz-i0-fhA" secondAttribute="trailing" constant="25" id="qpK-fQ-mz3"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="kcM-dW-3t2" secondAttribute="trailing" constant="25" id="t7X-uf-Ncd"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
</view>
</objects>
</document>
//
// SubscriptionTileCollectionViewCell.swift
// PIA VPN
//
// Created by Jose Antonio Blaya Garcia on 14/01/2019.
// Copyright © 2019 London Trust Media. All rights reserved.
//
import UIKit
import PIALibrary
class SubscriptionTileCollectionViewCell: UICollectionViewCell, TileableCell {
var tileType: AvailableTiles = .subscription
typealias Entity = IPTile
@IBOutlet private weak var tile: Entity!
@IBOutlet private weak var accessoryImageRight: UIImageView!
@IBOutlet private weak var accessoryButtonLeft: UIButton!
@IBOutlet weak var tileLeftConstraint: NSLayoutConstraint!
@IBOutlet weak var tileRightConstraint: NSLayoutConstraint!
func setupCellForStatus(_ status: TileStatus) {
self.accessoryImageRight.image = Theme.current.dragDropImage()
tile.status = status
UIView.animate(withDuration: AppConfiguration.Animations.duration, animations: {
switch status {
case .normal:
self.tileLeftConstraint.constant = 0
self.tileRightConstraint.constant = 0
case .edit:
self.tileLeftConstraint.constant = self.leftConstraintValue
self.tileRightConstraint.constant = self.rightConstraintValue
self.setupVisibilityButton()
}
self.layoutIfNeeded()
})
}
private func setupVisibilityButton() {
if Client.providers.tileProvider.visibleTiles.contains(tileType) {
accessoryButtonLeft.setImage(Asset.Piax.Global.eyeActive.image, for: .normal)
accessoryButtonLeft.setImage(Asset.Piax.Global.eyeInactive.image, for: .highlighted)
} else {
accessoryButtonLeft.setImage(Asset.Piax.Global.eyeInactive.image, for: .normal)
accessoryButtonLeft.setImage(Asset.Piax.Global.eyeActive.image, for: .highlighted)
}
}
@IBAction private func changeTileVisibility() {
var visibleTiles = Client.providers.tileProvider.visibleTiles
if Client.providers.tileProvider.visibleTiles.contains(tileType) {
let tiles = visibleTiles.filter { $0 != tileType }
Client.providers.tileProvider.visibleTiles = tiles
} else {
visibleTiles.append(tileType)
Client.providers.tileProvider.visibleTiles = visibleTiles
}
Macros.postNotification(.PIAThemeDidChange)
}
}
<?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"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="SubscriptionTileCell" id="gTV-IL-0wX" customClass="SubscriptionTileCollectionViewCell" customModule="PIA_VPN" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="358" height="74"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="358" height="74"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="I3K-sb-IrO">
<rect key="frame" x="15" y="26" width="19" height="22"/>
<state key="normal" image="eye-active"/>
<connections>
<action selector="changeTileVisibility" destination="gTV-IL-0wX" eventType="touchUpInside" id="iTO-De-9xK"/>
</connections>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="open-tile-details" translatesAutoresizingMaskIntoConstraints="NO" id="UYN-GG-OrW">
<rect key="frame" x="331" y="31" width="12" height="12"/>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ycm-Q1-Aix" customClass="SubscriptionTile" customModule="PIA_VPN" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="358" height="74"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
</subviews>
</view>
<constraints>
<constraint firstItem="UYN-GG-OrW" firstAttribute="centerY" secondItem="gTV-IL-0wX" secondAttribute="centerY" id="5MO-qV-Z9R"/>
<constraint firstAttribute="bottom" secondItem="ycm-Q1-Aix" secondAttribute="bottom" id="7L5-v4-RPz"/>
<constraint firstItem="I3K-sb-IrO" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="15" id="7xY-Ic-LPI"/>
<constraint firstAttribute="trailing" secondItem="UYN-GG-OrW" secondAttribute="trailing" constant="15" id="OcH-Mi-Xi4"/>
<constraint firstItem="I3K-sb-IrO" firstAttribute="centerY" secondItem="gTV-IL-0wX" secondAttribute="centerY" id="QkY-YL-ZJE"/>
<constraint firstItem="ycm-Q1-Aix" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="Rwi-Ni-pBH"/>
<constraint firstAttribute="trailing" secondItem="ycm-Q1-Aix" secondAttribute="trailing" id="U5l-A3-Wkf"/>
<constraint firstItem="UYN-GG-OrW" firstAttribute="width" secondItem="UYN-GG-OrW" secondAttribute="height" multiplier="1:1" id="kaS-8m-Yhr"/>
<constraint firstItem="ycm-Q1-Aix" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="y6d-q6-sEV"/>
</constraints>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<size key="customSize" width="358" height="74"/>
<connections>
<outlet property="accessoryButtonLeft" destination="I3K-sb-IrO" id="qZ1-v2-lC4"/>
<outlet property="accessoryImageRight" destination="UYN-GG-OrW" id="Vf8-pp-JAP"/>
<outlet property="tile" destination="ycm-Q1-Aix" id="sCu-mn-xCi"/>
<outlet property="tileLeftConstraint" destination="Rwi-Ni-pBH" id="YJj-fW-qAn"/>
<outlet property="tileRightConstraint" destination="U5l-A3-Wkf" id="qaC-9s-Cya"/>
</connections>
<point key="canvasLocation" x="384" y="142.1289355322339"/>
</collectionViewCell>
</objects>
<resources>
<image name="eye-active" width="19" height="10"/>
<image name="open-tile-details" width="12" height="12"/>
</resources>
</document>
......@@ -211,3 +211,4 @@
// TILES
"tiles.quick.connect.title" = "Quick connect";
"tiles.region.title" = "VPN Server";
"tiles.subscription.title" = "Subscription";
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment