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

Fix issues with quick connect tile

Clean plain database
Refactor
parent 78d70d21
This diff is collapsed.
......@@ -225,9 +225,14 @@ class AppPreferences {
func reset() {
piaSocketType = nil
favoriteServerIdentifiers = []
transitionTheme(to: .light)
}
func clean() {
favoriteServerIdentifiers = []
}
// + (void)eraseForTesting;
func transitionTheme(to code: ThemeCode) {
......
......@@ -15,6 +15,10 @@ private let log = SwiftyBeaver.self
class DashboardViewController: AutolayoutViewController {
private enum TileSize: CGFloat {
case standard = 89.0
}
private enum Cells: Int, EnumsBuilder {
case region = 0
......@@ -109,6 +113,7 @@ class DashboardViewController: AutolayoutViewController {
nc.addObserver(self, selector: #selector(vpnStatusDidChange(notification:)), name: .PIADaemonsDidUpdateVPNStatus, object: nil)
nc.addObserver(self, selector: #selector(viewHasRotated), name: .UIDeviceOrientationDidChange, object: nil)
nc.addObserver(self, selector: #selector(updateCurrentStatus), name: .PIAThemeDidChange, object: nil)
nc.addObserver(self, selector: #selector(updateTiles), name: .PIATilesDidChange, object: nil)
#if !TARGET_IPHONE_SIMULATOR
let types: UIUserNotificationType = [.alert, .badge, .sound]
......@@ -308,6 +313,10 @@ class DashboardViewController: AutolayoutViewController {
updateCurrentStatusWithUserInfo(nil)
}
@objc private func updateTiles() {
collectionView.reloadData()
}
@objc private func updateCurrentStatusWithUserInfo(_ userInfo: [AnyHashable: Any]?) {
currentStatus = Client.providers.vpnProvider.vpnStatus
......@@ -465,7 +474,8 @@ extension DashboardViewController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: collectionView.frame.width, height: 89)
return CGSize(width: collectionView.frame.width,
height: TileSize.standard.rawValue)
}
func collectionView(_ collectionView: UICollectionView,
......
......@@ -285,7 +285,7 @@ class MenuViewController: AutolayoutViewController {
sheet.addDestructiveAction(L10n.Menu.Logout.confirm) {
self.dismiss(animated: true) {
log.debug("Account: Logging out...")
AppPreferences.shared.clean()
Client.providers.accountProvider.logout(nil)
}
}
......
......@@ -31,8 +31,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()
......@@ -58,6 +58,6 @@ class IPTileCollectionViewCell: UICollectionViewCell, TileableCell {
visibleTiles.append(tileType)
Client.providers.tileProvider.visibleTiles = visibleTiles
}
Macros.postNotification(.PIAThemeDidChange)
Macros.postNotification(.PIATilesDidChange)
}
}
......@@ -31,8 +31,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()
......@@ -58,6 +58,6 @@ class QuickConnectTileCollectionViewCell: UICollectionViewCell, TileableCell {
visibleTiles.append(tileType)
Client.providers.tileProvider.visibleTiles = visibleTiles
}
Macros.postNotification(.PIAThemeDidChange)
Macros.postNotification(.PIATilesDidChange)
}
}
......@@ -39,7 +39,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()
......@@ -78,7 +78,7 @@ class RegionTileCollectionViewCell: UICollectionViewCell, TileableCell {
visibleTiles.append(tileType)
Client.providers.tileProvider.visibleTiles = visibleTiles
}
Macros.postNotification(.PIAThemeDidChange)
Macros.postNotification(.PIATilesDidChange)
}
}
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