Skip to content

Commit

Permalink
- Coding style changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pablocarmu committed Oct 30, 2018
1 parent 7019762 commit dd48a48
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
28 changes: 14 additions & 14 deletions ownCloud/UI Elements/DownloadFileProgressHUDViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import UIKit

class DownloadFileProgressHUDViewController: UIViewController {

private let PROGRESSVIEW_SIDES_CONSTRAINT_CONSTANT: CGFloat = 20
private let CANCELBUTTON_TOP_ANCHOR_CONSTANT: CGFloat = 10
private let CANCELBUTTON_HEIGHT_CONSTRAINT_CONSTANT: CGFloat = 40
private let INFOLABEL_BOTTOM_ANCHOR_CONSTANT: CGFloat = 10
private let INFOLABEL_HEIGHT_CONSTRAINT_CONSTANT: CGFloat = 20
private let ROOT_VIEW_BACKGROUND_WHITE: CGFloat = 0.0
private let ROOT_VIEW_BACKGROUND_ALPHA: CGFloat = 0.7
private let progressViewSidesConstraintConstant: CGFloat = 20
private let cancelButtonTopAnchor: CGFloat = 10
private let cancelButtonHeightConstraintConstant: CGFloat = 40
private let infoLabelBottomAnchor: CGFloat = 10
private let infoLabelHeightConstraintConstant: CGFloat = 20
private let rootViewBackgroundWhite: CGFloat = 0.0
private let rootViewBackgroundAlpha: CGFloat = 0.7

// MARK: - Instance variables.
private var progressView: UIProgressView {
Expand Down Expand Up @@ -64,27 +64,27 @@ class DownloadFileProgressHUDViewController: UIViewController {
override func loadView() {
super.loadView()

view.backgroundColor = UIColor.init(white: ROOT_VIEW_BACKGROUND_WHITE, alpha: ROOT_VIEW_BACKGROUND_ALPHA)
view.backgroundColor = UIColor.init(white: rootViewBackgroundWhite, alpha: rootViewBackgroundAlpha)

// Progress view
progressView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(progressView)
NSLayoutConstraint.activate([
progressView.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor),
progressView.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor),
progressView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor, constant: PROGRESSVIEW_SIDES_CONSTRAINT_CONSTANT),
progressView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor, constant: -PROGRESSVIEW_SIDES_CONSTRAINT_CONSTANT)
progressView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor, constant: progressViewSidesConstraintConstant),
progressView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor, constant: -progressViewSidesConstraintConstant)
])

// Cancel button
cancelButton.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(cancelButton)
NSLayoutConstraint.activate([
cancelButton.centerXAnchor.constraint(equalTo: progressView.centerXAnchor),
cancelButton.topAnchor.constraint(equalTo: progressView.bottomAnchor, constant: CANCELBUTTON_TOP_ANCHOR_CONSTANT),
cancelButton.topAnchor.constraint(equalTo: progressView.bottomAnchor, constant: cancelButtonTopAnchor),
cancelButton.leftAnchor.constraint(equalTo: progressView.leftAnchor),
cancelButton.rightAnchor.constraint(equalTo: progressView.rightAnchor),
cancelButton.heightAnchor.constraint(equalToConstant: CANCELBUTTON_HEIGHT_CONSTRAINT_CONSTANT)
cancelButton.heightAnchor.constraint(equalToConstant: cancelButtonHeightConstraintConstant)
])
cancelButton.setTitle("Cancel".localized, for: .normal)

Expand All @@ -93,10 +93,10 @@ class DownloadFileProgressHUDViewController: UIViewController {
view.addSubview(infoLabel)
NSLayoutConstraint.activate([
infoLabel.centerXAnchor.constraint(equalTo: progressView.centerXAnchor),
infoLabel.bottomAnchor.constraint(equalTo: progressView.topAnchor, constant: -INFOLABEL_BOTTOM_ANCHOR_CONSTANT),
infoLabel.bottomAnchor.constraint(equalTo: progressView.topAnchor, constant: -infoLabelBottomAnchor),
infoLabel.leftAnchor.constraint(equalTo: progressView.leftAnchor),
infoLabel.rightAnchor.constraint(equalTo: progressView.rightAnchor),
infoLabel.heightAnchor.constraint(equalToConstant: INFOLABEL_HEIGHT_CONSTRAINT_CONSTANT)
infoLabel.heightAnchor.constraint(equalToConstant: infoLabelHeightConstraintConstant)
])

infoLabel.text = "Downloading".localized
Expand Down
10 changes: 5 additions & 5 deletions ownCloud/Viewer/DisplayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protocol DisplayViewEditingDelegate: class {

class DisplayViewController: UIViewController {

private let ICON_IMAGE_SIZE: CGSize = CGSize(width: 200.0, height: 200.0)
private let iconImageSize: CGSize = CGSize(width: 200.0, height: 200.0)

private var interactionController: UIDocumentInteractionController?

Expand Down Expand Up @@ -156,7 +156,7 @@ class DisplayViewController: UIViewController {
NSLayoutConstraint.activate([
iconImageView.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor),
iconImageView.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor, constant: -60),
iconImageView.heightAnchor.constraint(equalToConstant: ICON_IMAGE_SIZE.height),
iconImageView.heightAnchor.constraint(equalToConstant: iconImageSize.height),
iconImageView.widthAnchor.constraint(equalTo: iconImageView.heightAnchor),

metadataInfoLabel!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor),
Expand All @@ -182,11 +182,11 @@ class DisplayViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

iconImageView.image = item.icon(fitInSize:ICON_IMAGE_SIZE)
iconImageView.image = item.icon(fitInSize:iconImageSize)

if item.thumbnailAvailability != .none {
let displayThumbnail = { (thumbnail: OCItemThumbnail?) in
_ = thumbnail?.requestImage(for: self.ICON_IMAGE_SIZE, scale: 0, withCompletionHandler: { (thumbnail, error, _, image) in
_ = thumbnail?.requestImage(for: self.iconImageSize, scale: 0, withCompletionHandler: { (thumbnail, error, _, image) in
if error == nil,
image != nil,
self.item.itemVersionIdentifier == thumbnail?.itemVersionIdentifier {
Expand All @@ -202,7 +202,7 @@ class DisplayViewController: UIViewController {
if let thumbnail = item.thumbnail {
displayThumbnail(thumbnail)
} else {
_ = core?.retrieveThumbnail(for: item, maximumSize: ICON_IMAGE_SIZE, scale: 0, retrieveHandler: { (_, _, _, thumbnail, _, _) in
_ = core?.retrieveThumbnail(for: item, maximumSize: iconImageSize, scale: 0, retrieveHandler: { (_, _, _, thumbnail, _, _) in
displayThumbnail(thumbnail)
})
}
Expand Down

0 comments on commit dd48a48

Please sign in to comment.