Commit 0337dd93 authored by Jose Blaya's avatar Jose Blaya
Browse files

- Add edit tile icon

- Fix autolayout in dashboard
parent e90f6edb
This diff is collapsed.
......@@ -38,12 +38,11 @@ class DashboardViewController: AutolayoutViewController {
}
}
@IBOutlet private weak var viewContent: UIView!
@IBOutlet private weak var viewConnectionArea: UIView!
private var viewContentHeight: CGFloat = 0
@IBOutlet weak var viewContentHeightConstraint: NSLayoutConstraint!
@IBOutlet weak var viewContentLandscapeHeightConstraint: NSLayoutConstraint!
@IBOutlet private weak var viewConnection: UIView!
@IBOutlet private weak var viewContent: UIView!
@IBOutlet private weak var toggleConnection: PIAConnectionButton!
@IBOutlet private weak var viewRows: UIView!
......@@ -54,6 +53,13 @@ class DashboardViewController: AutolayoutViewController {
private var currentStatus: VPNStatus = .disconnected
private var tileModeStatus: TileStatus = .normal {
didSet {
collectionView.reloadData()
self.updateTileLayout()
}
}
deinit {
NotificationCenter.default.removeObserver(self)
}
......@@ -80,6 +86,14 @@ class DashboardViewController: AutolayoutViewController {
)
navigationItem.leftBarButtonItem?.accessibilityLabel = L10n.Menu.Accessibility.item
navigationItem.rightBarButtonItem = UIBarButtonItem(
image: Asset.Piax.Global.iconEditTile.image,
style: .plain,
target: self,
action: #selector(updateEditTileStatus(_:))
)
navigationItem.leftBarButtonItem?.accessibilityLabel = L10n.Menu.Accessibility.Edit.tile
viewContent.isHidden = true
viewRows.isHidden = true
......@@ -107,6 +121,7 @@ class DashboardViewController: AutolayoutViewController {
Client.providers.accountProvider.refreshAndLogoutUnauthorized()
}
self.viewContentHeight = self.viewContentHeightConstraint.constant
}
override func viewWillAppear(_ animated: Bool) {
......@@ -166,6 +181,14 @@ class DashboardViewController: AutolayoutViewController {
}
// MARK: Actions
private func updateTileLayout() {
UIView.animate(withDuration: AppConfiguration.Animations.duration, animations: {
self.toggleConnection.alpha = self.tileModeStatus == .normal ? 1 : 0
self.viewContentHeightConstraint.constant = self.tileModeStatus == .normal ? self.viewContentHeight : 0
self.viewContentLandscapeHeightConstraint.constant = self.tileModeStatus == .normal ? self.viewContentHeight : 0
self.view.layoutIfNeeded()
})
}
private func showWalkthrough() {
perform(segue: StoryboardSegue.Main.walkthroughSegueIdentifier)
......@@ -198,6 +221,15 @@ class DashboardViewController: AutolayoutViewController {
perform(segue: StoryboardSegue.Main.menuSegueIdentifier)
}
@objc private func updateEditTileStatus(_ sender: Any?) {
switch self.tileModeStatus { //change the status
case .normal:
self.tileModeStatus = .edit
case .edit:
self.tileModeStatus = .normal
}
}
@IBAction func vpnButtonClicked(_ sender: Any?) {
if !toggleConnection.isOn {
Client.providers.vpnProvider.connect(nil)
......@@ -265,6 +297,7 @@ class DashboardViewController: AutolayoutViewController {
@objc private func viewHasRotated() {
updateCurrentStatus()
updateTileLayout()
}
@objc private func accountDidLogout(notification: Notification) {
......@@ -346,11 +379,6 @@ class DashboardViewController: AutolayoutViewController {
// labelStatus.text = L10n.Dashboard.Vpn.changingRegion
}
// XXX hack to suppress "ellipsis"
//viewConnectionArea.accessibilityLabel = labelStatus.text
viewConnectionArea.accessibilityLabel = viewConnectionArea.accessibilityLabel?.replacingOccurrences(of: "...", with: "")
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, viewConnectionArea)
// non-iPad bottom table
collectionView.reloadData()
}
......@@ -499,6 +527,9 @@ extension DashboardViewController: UICollectionViewDelegate, UICollectionViewDat
let identifier = Cells.objectIdentifyBy(index: indexPath.row).identifier
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier,
for: indexPath)
if let cell = cell as? EditableTileCell {
cell.setupCellForStatus(self.tileModeStatus)
}
Theme.current.applySolidLightBackground(cell)
return cell
}
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "iconOrganise.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -17,9 +17,9 @@ private struct PIAConnectionButtonSettings {
static let animatedShapeWidth: CGFloat = 4.0
static let startAngle: CGFloat = -0.25 * 2 * .pi
static let endAngle: CGFloat = PIAConnectionButtonSettings.startAngle + 2 * .pi
static let udpateColorAnimationDuration = 0.3
static let udpateColorAnimationDuration = AppConfiguration.Animations.duration
static let shapeAnimationDuration = 2
static let shapeEndAnimationDuration = 0.3
static let shapeEndAnimationDuration = AppConfiguration.Animations.duration
static let timingFunction = CAMediaTimingFunction(controlPoints: 0.2, 0.88, 0.09, 0.99)
}
......
......@@ -88,7 +88,7 @@ class RegionCell: UITableViewCell, Restylable {
}
private func animateFavoriteImage() {
UIView.animate(withDuration: 0.3, animations: {
UIView.animate(withDuration: AppConfiguration.Animations.duration, animations: {
self.favoriteImageView.transform = CGAffineTransform(scaleX: 1.2, y: 1.2)
}, completion: { (finished) in
UIView.animate(withDuration: 0.2, animations: {
......
......@@ -109,6 +109,7 @@ enum Asset {
static let favoriteUnselectedDark = ImageAsset(name: "favorite-unselected-dark")
static let favoriteUnselected = ImageAsset(name: "favorite-unselected")
static let iconBack = ImageAsset(name: "icon-back")
static let iconEditTile = ImageAsset(name: "icon-edit-tile")
static let iconFilter = ImageAsset(name: "icon-filter")
static let pagecontrolSelectedDot = ImageAsset(name: "pagecontrol-selected-dot")
static let pagecontrolUnselectedDot = ImageAsset(name: "pagecontrol-unselected-dot")
......@@ -501,6 +502,7 @@ enum Asset {
Piax.Global.favoriteUnselectedDark,
Piax.Global.favoriteUnselected,
Piax.Global.iconBack,
Piax.Global.iconEditTile,
Piax.Global.iconFilter,
Piax.Global.pagecontrolSelectedDot,
Piax.Global.pagecontrolUnselectedDot,
......
......@@ -204,6 +204,10 @@ internal enum L10n {
internal static func loggedAs(_ p1: String) -> String {
return L10n.tr("Localizable", "menu.accessibility.logged_as", p1)
}
internal enum Edit {
/// Edit
internal static let tile = L10n.tr("Localizable", "menu.accessibility.edit.tile")
}
}
internal enum Expiration {
/// %d days
......
......@@ -19,7 +19,7 @@ class IPTileCollectionViewCell: UICollectionViewCell, TileableCell {
@IBOutlet weak var tileRightConstraint: NSLayoutConstraint!
func setupCellForStatus(_ status: TileStatus) {
UIView.animate(withDuration: 0.3, animations: {
UIView.animate(withDuration: AppConfiguration.Animations.duration, animations: {
switch status {
case .normal:
self.tileLeftConstraint.constant = 0
......
......@@ -18,7 +18,7 @@ class QuickConnectTileCollectionViewCell: UICollectionViewCell, TileableCell {
@IBOutlet weak var tileRightConstraint: NSLayoutConstraint!
func setupCellForStatus(_ status: TileStatus) {
UIView.animate(withDuration: 0.3, animations: {
UIView.animate(withDuration: AppConfiguration.Animations.duration, animations: {
switch status {
case .normal:
self.tileLeftConstraint.constant = 0
......
......@@ -56,7 +56,7 @@ class RegionTile: UIView, Tileable {
}
@objc private func updateServer() {
let effectiveServer = Client.providers.vpnProvider.profileServer ?? Client.providers.serverProvider.targetServer
let effectiveServer = Client.preferences.displayedServer
let vpn = Client.providers.vpnProvider
self.serverName.text = effectiveServer.name(forStatus: vpn.vpnStatus)
self.mapImageView.image = UIImage(named: Theme.current.mapImageByServerName(effectiveServer.name))
......
......@@ -26,7 +26,7 @@ class RegionTileCollectionViewCell: UICollectionViewCell, TileableCell {
}
func setupCellForStatus(_ status: TileStatus) {
UIView.animate(withDuration: 0.3, animations: {
UIView.animate(withDuration: AppConfiguration.Animations.duration, animations: {
switch status {
case .normal:
self.tileLeftConstraint.constant = 0
......
......@@ -47,7 +47,7 @@
"renewal.failure.message" = "Your purchase receipt couldn't be submitted, please retry at a later time.";
// MENU
"menu.accessibility.edit.tile" = "Edit";
"menu.accessibility.item" = "Menu";
"menu.accessibility.logged_as" = "Logged in as %@";
"menu.expiration.expires_in" = "Subscription expires in";
......
This diff is collapsed.
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