Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download percentage added #356

Merged
merged 2 commits into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ class DownloadsBaseCollectionCell: SwipeCollectionViewCell{
}


func updateProgress(offlineFile: OfflineFile, progressView: UIProgressView, brokenIndicator: UIImageView, iconImageView: UIImageView){
func updateProgress(offlineFile: OfflineFile, progressView: UIProgressView, brokenIndicator: UIImageView, iconImageView: UIImageView, dateSizeLabel: UILabel? = nil){
setupProgressView(offlineFile: offlineFile, progressView: progressView)

if let dateSizeLabel = dateSizeLabel {
setUpPercentagelabel(offlineFile: offlineFile, dateSizeLabel: dateSizeLabel)
}

if offlineFile.stateEnum == .downloading {
if let remoteUrl = offlineFile.remoteFileURL() {
let keyExists = DownloadService.shared.activeDownloads[remoteUrl] != nil
Expand Down Expand Up @@ -111,5 +115,20 @@ class DownloadsBaseCollectionCell: SwipeCollectionViewCell{
}
}

func setUpPercentagelabel(offlineFile: OfflineFile, dateSizeLabel: UILabel) {
let size = offlineFile.getFileSize()
let date = offlineFile.downloadDate?.asString ?? ""
let progress = offlineFile.progress * 100
let dateSizeText = "\(Int(progress))% | \(size), \(date)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. I would suggest a change to this line for the following reasons:

  • The date does not matter much while downloading
  • The line keeps on moving because the % is variable font and has variable digits
  • The | keeps it a little busy

I would suggest

let dateSizeText = "\(size) · \(Int(progress))%"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpg Thanks for your valuable feedback

1 I will not append the date while downloading.
2 I will add the percentage in last
3 i will add "." instead of "|"

Is this right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a precise suggestion of change for one line. If you like it, do it, if not, explain why and suggest otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpg I liked your suggestion.
I am doing that way.

if dateSizeText != dateSizeLabel.text {
dateSizeLabel.text = dateSizeText
}

if progress == 100.0 {
dateSizeLabel.text = "\(size), \(date)"
}

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class DownloadsListCollectionCell: DownloadsBaseCollectionCell{
}

func updateProgress(offlineFile: OfflineFile){
updateProgress(offlineFile: offlineFile, progressView: progressView, brokenIndicator: brokenIndicatorImageView, iconImageView: iconImageView)
updateProgress(offlineFile: offlineFile, progressView: progressView, brokenIndicator: brokenIndicatorImageView, iconImageView: iconImageView, dateSizeLabel: sizeDateLabel)
}

}