Commit 4b7b2479 authored by Kristjan Pirnpuu's avatar Kristjan Pirnpuu
Browse files

Merge branch 'bugfix/COVAPP-398' into 'develop'

COVAPP-398 Don't animate infected state, wrap MyContactView label

Closes COVAPP-398

See merge request hoia/dp3t-app-ios!105
parents cc042719 7f1f9e9b
......@@ -172,7 +172,7 @@ private extension HomeView {
// MARK: - Public
extension HomeView {
func update(header: HeaderModel) {
func update(header: HeaderModel, animated: Bool) {
var components: [HeaderView.Component] = [.title(text: header.title)]
if let subtitle = header.subtitle {
......@@ -184,6 +184,12 @@ extension HomeView {
contentView.update(fill: header.backgroundColor)
headerStack.backgroundColor = header.backgroundColor
if !animated {
headerView.setup(icon: header.icon, title: header.title)
return
}
headerView.update(components: components,
statusIcon: header.icon,
loadingTitle: L10n.Home.Status.loading)
......
......@@ -72,7 +72,7 @@ private extension HomeViewController {
}
}
// // MARK: Actions
// MARK: Actions
@objc
func debugAction() {
......@@ -109,12 +109,12 @@ extension HomeViewController: HomeViewModelView {
homeView.updateAppStatus(model: model)
}
func updateHeaderStatus(model: HomeView.HeaderModel) {
func updateHeaderStatus(model: HomeView.HeaderModel, animated: Bool) {
if navigationController?.viewControllers.last == self {
navigationController?.navigationBar.barTintColor = model.backgroundColor
}
barTintColor = model.backgroundColor
homeView.update(header: model)
homeView.update(header: model, animated: animated)
}
func scrollToTop() {
......
import Foundation
protocol HomeViewModelView: AnyObject {
func updateHeaderStatus(model: HomeView.HeaderModel)
func updateHeaderStatus(model: HomeView.HeaderModel, animated: Bool)
func myDataStatusChanged(model: HomeView.CardModel)
func infectedInAbroad(model: HomeView.CardModel)
func infectedInEstonia(model: HomeView.CardModel)
......@@ -103,16 +103,15 @@ private extension HomeViewModel {
}
}
func updateHeader(_ contactState: UIStateModel.Homescreen.Meldungen, forced: Bool = false) {
func updateHeader(_ contactState: UIStateModel.Homescreen.Meldungen) {
let lastState = lastState?.homescreen.meldungen.meldung
/*
Update header to indicate 'loading' in following cases
1) forced - user returns from infection confirmation
2) isLastContactCheckOutdated - enough time have passed from last update
3) contactState.meldung - contact state is changed compared to last update
a) enough time have passed from last update
b) current contact state is changed compared to last state
*/
guard forced || isLastContactCheckOutdated || lastState != contactState.meldung else {
guard isLastContactCheckOutdated || lastState != contactState.meldung else {
return
}
......@@ -120,7 +119,7 @@ private extension HomeViewModel {
switch contactState.meldung {
case .noMeldung:
view?.updateHeaderStatus(model: .init(state: .noInfection))
view?.updateHeaderStatus(model: .init(state: .noInfection), animated: true)
case .exposed:
let action = HomeView.HeaderModel.Action(title: L10n.Home.Button.moreInfo, callback: { [weak self] in
self?.coordinator.showMyContacts()
......@@ -132,9 +131,9 @@ private extension HomeViewModel {
}
let state: HomeView.HeaderModel.State = .exposed(count: contactState.count, isolationEnd: endDate)
let model = HomeView.HeaderModel(state: state, action: action)
view?.updateHeaderStatus(model: model)
view?.updateHeaderStatus(model: model, animated: true)
case .infected:
view?.updateHeaderStatus(model: .init(state: .infection))
view?.updateHeaderStatus(model: .init(state: .infection), animated: false)
}
}
......@@ -221,13 +220,11 @@ extension HomeViewModel {
lastState = state
}
/** Trigger loading animation to indicate something is happening */
/**
User may have scrolled down to access infection confirmation button.
Scroll to top when returning from this flow so that new state is visible without manual scrolling.
*/
func didConfirmInfection() {
guard let lastState = lastState?.homescreen.meldungen else {
return
}
view?.scrollToTop()
updateHeader(lastState, forced: true)
}
}
......@@ -92,14 +92,21 @@ class MyContactsView: UIView {
closeContactInfoButton.setTitleColor(Asset.liivi.color, for: .highlighted)
closeContactInfoButton.titleLabel?.font = .ainoBold(size: LinkStyle.FontSize.medium)
closeContactInfoButton.setTitle(Strings.contactsInfoPageLink, for: .normal)
healthboardThankYouLabel.attributedText = Strings.healthBoardThankYou.withAttributes(
.font(.ainoBold(size: SubLabelStyle.FontSize.medium)),
.lineHeightMultiple(SubLabelStyle.lineHeightMultiple),
.minimumLineHeight(SubLabelStyle.minimumLineHeight),
.color(.black),
.alignment(.center)
)
descriptionLabel.text = Strings.description
healthboardThankYouLabel.adjust {
$0.numberOfLines = 0
$0.attributedText = Strings.healthBoardThankYou.withAttributes(
.font(.ainoBold(size: SubLabelStyle.FontSize.medium)),
.lineHeightMultiple(SubLabelStyle.lineHeightMultiple),
.minimumLineHeight(SubLabelStyle.minimumLineHeight),
.color(.black),
.alignment(.center)
)
}
descriptionLabel.adjust {
$0.numberOfLines = 0
descriptionLabel.text = Strings.description
}
}
// swiftlint:disable:next function_body_length
......
......@@ -58,7 +58,7 @@ private extension UpdateOSView {
HeaderView().adjust {
vStack.addArrangedSubview($0)
$0.setup(statusIcon: Asset.phone.image,
$0.setup(icon: Asset.phone.image,
title: Strings.Header.title)
}
......
......@@ -6,8 +6,8 @@ final class HeaderView: CustomView {
private typealias Margins = Style.General.Layout.Margin
private typealias StackStyle = Style.General.Object.StackView
private var loadingIndicator: LoadingIndicator!
private var loadingTextLabel: UILabel!
private var iconView: LoadingIndicator!
private var titleLabel: UILabel!
private var vStack: UIStackView!
private var vStackTop: NSLayoutConstraint!
private var topSpacing: CGFloat {
......@@ -53,33 +53,33 @@ private extension HeaderView {
relation: .equal)
vStack = $0
}
}
LoadingIndicator().adjust {
func createDefaultViews(for icon: UIImage, title: String) -> [UIView] {
let indicator = LoadingIndicator().adjust {
$0.setup(with: icon)
$0.contentMode = .scaleAspectFit
$0.widthAnchor.constraint(equalToConstant: 68).isActive = true
$0.heightAnchor.constraint(equalTo: $0.widthAnchor, multiplier: 1).isActive = true
loadingIndicator = $0
iconView = $0
}
UILabel().adjust {
let label = UILabel().adjust {
$0.text = title
$0.font = .ainoHeadline(size: 26)
$0.textColor = .white
$0.numberOfLines = 0
$0.textAlignment = .center
loadingTextLabel = $0
titleLabel = $0
}
return [indicator, label]
}
func createViews(for components: [Component], icon: UIImage, title: String) {
vStack.removeAllArrangedSubviews()
loadingIndicator.adjust {
$0.setup(with: icon)
vStack.addArrangedSubview($0)
}
loadingTextLabel.adjust {
$0.text = title
createDefaultViews(for: icon, title: title).forEach {
vStack.addArrangedSubview($0)
}
......@@ -121,8 +121,8 @@ private extension HeaderView {
}
func startLoading() {
loadingTextLabel.isHidden = false
loadingIndicator.animate {
titleLabel.isHidden = false
iconView.animate {
self.loadingFinished()
}
}
......@@ -130,7 +130,7 @@ private extension HeaderView {
func loadingFinished() {
UIView.animate(withDuration: 0.3) {
self.vStack.arrangedSubviews.forEach { $0.isHidden = false }
self.loadingTextLabel.isHidden = true
self.titleLabel.isHidden = true
}
}
}
......@@ -145,8 +145,8 @@ extension HeaderView {
case action(title: String, callback: () -> Void)
}
func setup(components: [Component] = [], statusIcon: UIImage, title: String) {
createViews(for: components, icon: statusIcon, title: title)
func setup(icon: UIImage, title: String) {
createViews(for: [], icon: icon, title: title)
}
func update(components: [Component], statusIcon: UIImage, loadingTitle: String) {
......
Supports Markdown
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