From 62a58781f8b07e34795c6dc599060ea339412761 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Tue, 22 Feb 2022 11:54:31 +0000 Subject: [PATCH 1/2] Enable home activity indicator Signed-off-by: Andy Uhnak --- Config/BuildSettings.swift | 2 +- .../ActivityPresenters/ToastUserIndicatorPresenter.swift | 4 ++-- Riot/Modules/Common/Recents/RecentsViewController.m | 2 ++ Riot/Modules/Common/Toasts/RoundedToastView.swift | 1 + changelog.d/5663.change | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 changelog.d/5663.change diff --git a/Config/BuildSettings.swift b/Config/BuildSettings.swift index 035c49065b..d072b0e8cd 100644 --- a/Config/BuildSettings.swift +++ b/Config/BuildSettings.swift @@ -228,7 +228,7 @@ final class BuildSettings: NSObject { /// Whether a screen uses legacy local activity indicators or improved app-wide indicators static var useAppUserIndicators: Bool { #if DEBUG - return false + return true #else return false #endif diff --git a/Riot/Modules/Common/ActivityPresenters/ToastUserIndicatorPresenter.swift b/Riot/Modules/Common/ActivityPresenters/ToastUserIndicatorPresenter.swift index 6f7973b3d0..504b4600ce 100644 --- a/Riot/Modules/Common/ActivityPresenters/ToastUserIndicatorPresenter.swift +++ b/Riot/Modules/Common/ActivityPresenters/ToastUserIndicatorPresenter.swift @@ -43,8 +43,8 @@ class ToastUserIndicatorPresenter: UserIndicatorPresentable { view.translatesAutoresizingMaskIntoConstraints = false navigationController.view.addSubview(view) NSLayoutConstraint.activate([ - view.centerXAnchor.constraint(equalTo: navigationController.navigationBar.centerXAnchor), - view.topAnchor.constraint(equalTo: navigationController.navigationBar.bottomAnchor) + view.centerXAnchor.constraint(equalTo: navigationController.view.centerXAnchor), + view.topAnchor.constraint(equalTo: navigationController.navigationBar.safeAreaLayoutGuide.bottomAnchor) ]) view.alpha = 0 diff --git a/Riot/Modules/Common/Recents/RecentsViewController.m b/Riot/Modules/Common/Recents/RecentsViewController.m index 722b706a2a..10ef43a4c0 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -314,6 +314,8 @@ - (void)viewWillDisappear:(BOOL)animated [[NSNotificationCenter defaultCenter] removeObserver:kMXNotificationCenterDidUpdateRulesObserver]; kMXNotificationCenterDidUpdateRulesObserver = nil; } + + [self stopActivityIndicator]; } - (void)viewDidAppear:(BOOL)animated diff --git a/Riot/Modules/Common/Toasts/RoundedToastView.swift b/Riot/Modules/Common/Toasts/RoundedToastView.swift index 927c608f76..b5a46a51e1 100644 --- a/Riot/Modules/Common/Toasts/RoundedToastView.swift +++ b/Riot/Modules/Common/Toasts/RoundedToastView.swift @@ -49,6 +49,7 @@ class RoundedToastView: UIView, Themable { private let stackView: UIStackView = { let stack = UIStackView() stack.axis = .horizontal + stack.alignment = .center stack.spacing = 5 return stack }() diff --git a/changelog.d/5663.change b/changelog.d/5663.change new file mode 100644 index 0000000000..97878df12a --- /dev/null +++ b/changelog.d/5663.change @@ -0,0 +1 @@ +Enable activity indicators on the home screen From ab44f86e687061d8be0f42ea71c292bc896f5b2c Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Wed, 23 Feb 2022 09:18:32 +0000 Subject: [PATCH 2/2] Change shadow style in dark mode --- .../Common/Toasts/RoundedToastView.swift | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Riot/Modules/Common/Toasts/RoundedToastView.swift b/Riot/Modules/Common/Toasts/RoundedToastView.swift index b5a46a51e1..4774eadd00 100644 --- a/Riot/Modules/Common/Toasts/RoundedToastView.swift +++ b/Riot/Modules/Common/Toasts/RoundedToastView.swift @@ -19,13 +19,18 @@ import UIKit import DesignKit class RoundedToastView: UIView, Themable { + private struct ShadowStyle { + let offset: CGSize + let radius: CGFloat + let opacity: Float + } + private struct Constants { static let padding = UIEdgeInsets(top: 10, left: 12, bottom: 10, right: 12) static let activityIndicatorScale = CGFloat(0.75) static let imageViewSize = CGFloat(15) - static let shadowOffset = CGSize(width: 0, height: 4) - static let shadowRadius = CGFloat(12) - static let shadowOpacity = Float(0.1) + static let lightShadow = ShadowStyle(offset: .init(width: 0, height: 4), radius: 12, opacity: 0.1) + static let darkShadow = ShadowStyle(offset: .init(width: 0, height: 4), radius: 4, opacity: 0.2) } private lazy var activityIndicator: UIActivityIndicatorView = { @@ -68,7 +73,6 @@ class RoundedToastView: UIView, Themable { } private func setup(viewState: ToastViewState) { - setupLayer() setupStackView() stackView.addArrangedSubview(toastView(for: viewState.style)) stackView.addArrangedSubview(label) @@ -86,13 +90,6 @@ class RoundedToastView: UIView, Themable { ]) } - private func setupLayer() { - layer.shadowColor = UIColor.black.cgColor - layer.shadowOffset = Constants.shadowOffset - layer.shadowRadius = Constants.shadowRadius - layer.shadowOpacity = Constants.shadowOpacity - } - override func layoutSubviews() { super.layoutSubviews() layer.cornerRadius = layer.frame.height / 2 @@ -103,6 +100,12 @@ class RoundedToastView: UIView, Themable { stackView.arrangedSubviews.first?.tintColor = theme.colors.primaryContent label.font = theme.fonts.subheadline label.textColor = theme.colors.primaryContent + + let shadowStyle = theme.identifier == ThemeIdentifier.dark.rawValue ? Constants.darkShadow : Constants.lightShadow + layer.shadowColor = UIColor.black.cgColor + layer.shadowOffset = shadowStyle.offset + layer.shadowRadius = shadowStyle.radius + layer.shadowOpacity = shadowStyle.opacity } private func toastView(for style: ToastViewState.Style) -> UIView {