From f1c7f40bc37a1d03f7b0bbc8a0495bd4f330e3b0 Mon Sep 17 00:00:00 2001 From: Alexander Boriskov Date: Wed, 27 May 2020 16:21:53 +0300 Subject: [PATCH] [iOS] Downloader bottom panel: fixed style for night theme, added error state, removed ambiguous states https://jira.mail.ru/browse/MAPSME-13588 --- .../DownloadAllView/DownloadAllView.swift | 29 +++++++++++++++---- .../DownloadAllView/DownloadAllView.xib | 6 ++-- .../DownloadMapsViewController.swift | 28 +++++++++++++----- 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/iphone/Maps/UI/Downloader/DownloadAllView/DownloadAllView.swift b/iphone/Maps/UI/Downloader/DownloadAllView/DownloadAllView.swift index 4355f7d2e3..af136ce556 100644 --- a/iphone/Maps/UI/Downloader/DownloadAllView/DownloadAllView.swift +++ b/iphone/Maps/UI/Downloader/DownloadAllView/DownloadAllView.swift @@ -2,6 +2,7 @@ import UIKit protocol DownloadAllViewDelegate: AnyObject { func onDownloadButtonPressed() + func onRetryButtonPressed() func onCancelButtonPressed() func onStateChanged(state: DownloadAllView.State) } @@ -10,6 +11,7 @@ class DownloadAllView: UIView { enum State { case none case ready + case error case dowloading } enum Style { @@ -64,40 +66,57 @@ class DownloadAllView: UIView { weak var delegate: DownloadAllViewDelegate? @IBAction func onDownloadButtonPress(_ sender: Any) { - delegate?.onDownloadButtonPressed() + if state == .error { + delegate?.onRetryButtonPressed() + } else { + delegate?.onDownloadButtonPressed() + } } private func updateView() { let readyTitle: String let downloadingTitle: String - let buttonTitle: String + let readyButtonTitle: String + let errorTitle = L("country_status_download_failed") + let errorButtonTitle = L("downloader_retry") switch style { case .download: iconImageView.image = UIImage(named: "ic_download_all") readyTitle = L("downloader_download_all_button") downloadingTitle = L("downloader_loading_ios") - buttonTitle = L("download_button") + readyButtonTitle = L("download_button") case .update: iconImageView.image = UIImage(named: "ic_update_all") readyTitle = L("downloader_update_maps") downloadingTitle = L("downloader_updating_ios") - buttonTitle = L("downloader_update_all_button") + readyButtonTitle = L("downloader_update_all_button") } titleCenterConstraint.priority = isSizeHidden ? .defaultHigh : .defaultLow downloadSizeLabel.isHidden = isSizeHidden switch state { + case .error: + iconImageView.image = UIImage(named: "ic_download_error") + title.text = errorTitle + title.setStyleAndApply("redText") + downloadButton.setTitle(errorButtonTitle, for: .normal) + downloadButton.isHidden = false + stateWrapper.isHidden = true + progress.state = .spinner + downloadSizeLabel.isHidden = false case .ready: title.text = readyTitle - downloadButton.setTitle(buttonTitle, for: .normal) + title.setStyleAndApply("blackPrimaryText") + downloadButton.setTitle(readyButtonTitle, for: .normal) downloadButton.isHidden = false stateWrapper.isHidden = true progress.state = .spinner downloadSizeLabel.isHidden = false case .dowloading: title.text = downloadingTitle + title.setStyleAndApply("blackPrimaryText") downloadButton.isHidden = true stateWrapper.isHidden = false progress.state = .spinner diff --git a/iphone/Maps/UI/Downloader/DownloadAllView/DownloadAllView.xib b/iphone/Maps/UI/Downloader/DownloadAllView/DownloadAllView.xib index 99a4af018e..713263d0a3 100644 --- a/iphone/Maps/UI/Downloader/DownloadAllView/DownloadAllView.xib +++ b/iphone/Maps/UI/Downloader/DownloadAllView/DownloadAllView.xib @@ -32,8 +32,8 @@ -