Skip to content

Commit

Permalink
Merge pull request #5665 from vector-im/andy/5663_enable_indicator
Browse files Browse the repository at this point in the history
Enable home activity indicator
  • Loading branch information
Anderas authored Feb 25, 2022
2 parents c7985e5 + ab44f86 commit bcbc97d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Riot/Modules/Common/Recents/RecentsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ - (void)viewWillDisappear:(BOOL)animated
[[NSNotificationCenter defaultCenter] removeObserver:kMXNotificationCenterDidUpdateRulesObserver];
kMXNotificationCenterDidUpdateRulesObserver = nil;
}

[self stopActivityIndicator];
}

- (void)viewDidAppear:(BOOL)animated
Expand Down
26 changes: 15 additions & 11 deletions Riot/Modules/Common/Toasts/RoundedToastView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -49,6 +54,7 @@ class RoundedToastView: UIView, Themable {
private let stackView: UIStackView = {
let stack = UIStackView()
stack.axis = .horizontal
stack.alignment = .center
stack.spacing = 5
return stack
}()
Expand All @@ -67,7 +73,6 @@ class RoundedToastView: UIView, Themable {
}

private func setup(viewState: ToastViewState) {
setupLayer()
setupStackView()
stackView.addArrangedSubview(toastView(for: viewState.style))
stackView.addArrangedSubview(label)
Expand All @@ -85,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
Expand All @@ -102,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 {
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5663.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enable activity indicators on the home screen

0 comments on commit bcbc97d

Please sign in to comment.