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

Improvements

parent 0337dd93
......@@ -188,6 +188,7 @@ class DashboardViewController: AutolayoutViewController {
self.viewContentLandscapeHeightConstraint.constant = self.tileModeStatus == .normal ? self.viewContentHeight : 0
self.view.layoutIfNeeded()
})
collectionView.reloadData()
}
private func showWalkthrough() {
......@@ -379,8 +380,6 @@ class DashboardViewController: AutolayoutViewController {
// labelStatus.text = L10n.Dashboard.Vpn.changingRegion
}
// non-iPad bottom table
collectionView.reloadData()
}
......@@ -392,11 +391,11 @@ class DashboardViewController: AutolayoutViewController {
navigationItem.titleView = NavigationLogoView()
Theme.current.applySolidLightBackground(view)
Theme.current.applySolidLightBackground(viewContainer!)
Theme.current.applySolidLightBackground(viewContent)
Theme.current.applySolidLightBackground(viewRows)
Theme.current.applyLightNavigationBar(navigationController!.navigationBar)
// XXX: emulate native UITableView separator
//Theme.current.applyDividerToSeparator(tableRows)
collectionView.collectionViewLayout.invalidateLayout()
collectionView.reloadData()
}
......@@ -473,36 +472,6 @@ 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)
}
......@@ -550,4 +519,22 @@ extension DashboardViewController: UICollectionViewDelegate, UICollectionViewDat
performSegue(withIdentifier: segueIdentifier, sender: nil)
}
}
func collectionView(_ collectionView: UICollectionView, didHighlightItemAt indexPath: IndexPath) {
if let cell = collectionView.cellForItem(at: indexPath) as? DetailedTileCell,
cell.hasDetailView() {
UIView.animate(withDuration: 0.1, animations: {
cell.highlightCell()
})
}
}
func collectionView(_ collectionView: UICollectionView, didUnhighlightItemAt indexPath: IndexPath) {
if let cell = collectionView.cellForItem(at: indexPath) as? DetailedTileCell,
cell.hasDetailView() {
UIView.animate(withDuration: 0.1, animations: {
cell.unhighlightCell()
})
}
}
}
......@@ -65,8 +65,8 @@ class RegionCell: UITableViewCell, Restylable {
func viewShouldRestyle() {
self.backgroundColor = Theme.current.palette.lightBackground
self.contentView.backgroundColor = Theme.current.palette.lightBackground
self.backgroundColor = Theme.current.palette.solidLightBackground
self.contentView.backgroundColor = Theme.current.palette.solidLightBackground
Theme.current.applySettingsCellTitle(labelRegion, appearance: .dark)
Theme.current.applyTag(labelPingTime, appearance: .dark)
......
......@@ -270,7 +270,7 @@ extension RegionsViewController: UITableViewDataSource, UITableViewDelegate {
let isSelected = (server.identifier == selectedServer.identifier)
cell.fill(withServer: server, isSelected: isSelected)
return cell
}
}
......
......@@ -19,14 +19,15 @@ class IPTileCollectionViewCell: UICollectionViewCell, TileableCell {
@IBOutlet weak var tileRightConstraint: NSLayoutConstraint!
func setupCellForStatus(_ status: TileStatus) {
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 = 55
self.tileRightConstraint.constant = 55
self.tileLeftConstraint.constant = 30
self.tileRightConstraint.constant = 30
}
self.layoutIfNeeded()
})
......
This diff is collapsed.
......@@ -18,14 +18,15 @@ class QuickConnectTileCollectionViewCell: UICollectionViewCell, TileableCell {
@IBOutlet weak var tileRightConstraint: NSLayoutConstraint!
func setupCellForStatus(_ status: TileStatus) {
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 = 55
self.tileRightConstraint.constant = 55
self.tileLeftConstraint.constant = 30
self.tileRightConstraint.constant = 30
}
self.layoutIfNeeded()
})
......
......@@ -22,24 +22,24 @@
<rect key="frame" x="0.0" y="0.0" width="265" height="89"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Light-Map-AU Melbourne" translatesAutoresizingMaskIntoConstraints="NO" id="Dez-a8-UVo">
<rect key="frame" x="122.5" y="15" width="117.5" height="59"/>
<constraints>
<constraint firstAttribute="width" secondItem="Dez-a8-UVo" secondAttribute="height" multiplier="403:202" id="smP-Nh-qbj"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lOm-Af-4Gm">
<rect key="frame" x="25" y="15" 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" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="h3Z-eW-74s">
<rect key="frame" x="25" y="40" width="42" height="21"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="h3Z-eW-74s">
<rect key="frame" x="25" y="40" width="42" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Light-Map-AU Melbourne" translatesAutoresizingMaskIntoConstraints="NO" id="Dez-a8-UVo">
<rect key="frame" x="122.5" y="15" width="117.5" height="59"/>
<constraints>
<constraint firstAttribute="width" secondItem="Dez-a8-UVo" secondAttribute="height" multiplier="403:202" id="smP-Nh-qbj"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
......
......@@ -7,6 +7,7 @@
//
import UIKit
import PIALibrary
class RegionTileCollectionViewCell: UICollectionViewCell, TileableCell {
......@@ -26,15 +27,26 @@ class RegionTileCollectionViewCell: UICollectionViewCell, TileableCell {
}
func setupCellForStatus(_ status: TileStatus) {
tile.status = status
UIView.animate(withDuration: AppConfiguration.Animations.duration, animations: {
switch status {
case .normal:
self.tileLeftConstraint.constant = 0
case .edit:
self.tileLeftConstraint.constant = 55
self.tileLeftConstraint.constant = 30
}
self.layoutIfNeeded()
})
}
func highlightCell() {
Theme.current.applyLightBackground(tile)
Theme.current.applyLightBackground(self)
}
func unhighlightCell() {
Theme.current.applySolidLightBackground(tile)
Theme.current.applySolidLightBackground(self)
}
}
......@@ -34,14 +34,14 @@
</constraints>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jZJ-xb-NWP" customClass="RegionTile" customModule="PIA_VPN" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="429" height="117"/>
<rect key="frame" x="0.0" y="0.0" width="454" height="117"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<viewLayoutGuide key="safeArea" id="Jn8-5q-PKh"/>
</view>
</subviews>
</view>
<constraints>
<constraint firstItem="WyC-xZ-KKf" firstAttribute="leading" secondItem="jZJ-xb-NWP" secondAttribute="trailing" constant="25" id="3uU-Ru-UpS"/>
<constraint firstItem="WyC-xZ-KKf" firstAttribute="leading" secondItem="jZJ-xb-NWP" secondAttribute="trailing" id="3uU-Ru-UpS"/>
<constraint firstItem="Npc-wO-bht" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="18" id="5aK-OK-8ev"/>
<constraint firstAttribute="trailing" secondItem="WyC-xZ-KKf" secondAttribute="trailing" constant="18" id="MxK-Nk-OL3"/>
<constraint firstItem="jZJ-xb-NWP" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="gfm-k5-z57"/>
......
......@@ -7,6 +7,7 @@
//
import Foundation
import PIALibrary
public protocol EditableTileCell {
......@@ -18,7 +19,9 @@ public protocol DetailedTileCell: EditableTileCell {
func hasDetailView() -> Bool
func segueIdentifier() -> String?
func highlightCell()
func unhighlightCell()
}
public protocol TileableCell: DetailedTileCell {
......@@ -36,5 +39,12 @@ extension TileableCell where Entity: Tileable {
func segueIdentifier() -> String? {
return nil
}
func highlightCell() {
}
func unhighlightCell() {
}
}
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