mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 13:37:11 +00:00
Fix various warnings raised by sonarcloud
This commit is contained in:
parent
fd23649f95
commit
5fc10c26a8
@ -35,20 +35,20 @@ final class ActivityIndicatorPresenter: ActivityIndicatorPresenterType {
|
||||
private weak var presentingView: UIView?
|
||||
|
||||
var isPresenting: Bool {
|
||||
return self.activityIndicatorView != nil
|
||||
activityIndicatorView != nil
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
func presentActivityIndicator(on view: UIView, animated: Bool, completion: (() -> Void)? = nil) {
|
||||
if self.presentingView != nil {
|
||||
if presentingView != nil {
|
||||
if let completion = completion {
|
||||
completion()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
self.presentingView = view
|
||||
presentingView = view
|
||||
|
||||
view.isUserInteractionEnabled = false
|
||||
|
||||
@ -77,11 +77,11 @@ final class ActivityIndicatorPresenter: ActivityIndicatorPresenterType {
|
||||
}
|
||||
|
||||
if animated {
|
||||
UIView.animate(withDuration: Constants.animationDuration, animations: {
|
||||
UIView.animate(withDuration: Constants.animationDuration) {
|
||||
animationInstructions()
|
||||
}, completion: { _ in
|
||||
} completion: { _ in
|
||||
completion?()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
animationInstructions()
|
||||
completion?()
|
||||
@ -109,11 +109,11 @@ final class ActivityIndicatorPresenter: ActivityIndicatorPresenterType {
|
||||
}
|
||||
|
||||
if animated {
|
||||
UIView.animate(withDuration: Constants.animationDuration, animations: {
|
||||
UIView.animate(withDuration: Constants.animationDuration) {
|
||||
animationInstructions()
|
||||
}, completion: { _ in
|
||||
} completion: { _ in
|
||||
animationCompletionInstructions()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
animationInstructions()
|
||||
animationCompletionInstructions()
|
||||
@ -134,7 +134,7 @@ private extension UIView {
|
||||
|
||||
/// Add a subview matching parent view using autolayout
|
||||
@objc func vc_addSubViewMatchingParent(_ subView: UIView) {
|
||||
self.addSubview(subView)
|
||||
addSubview(subView)
|
||||
subView.translatesAutoresizingMaskIntoConstraints = false
|
||||
let views = ["view": subView]
|
||||
["H:|[view]|", "V:|[view]|"].forEach { vfl in
|
||||
|
@ -25,10 +25,10 @@ protocol ActivityIndicatorPresenterType {
|
||||
// `ActivityIndicatorPresenterType` default implementation
|
||||
extension ActivityIndicatorPresenterType {
|
||||
func presentActivityIndicator(on view: UIView, animated: Bool) {
|
||||
self.presentActivityIndicator(on: view, animated: animated, completion: nil)
|
||||
presentActivityIndicator(on: view, animated: animated, completion: nil)
|
||||
}
|
||||
|
||||
func removeCurrentActivityIndicator(animated: Bool) {
|
||||
self.removeCurrentActivityIndicator(animated: animated, completion: nil)
|
||||
removeCurrentActivityIndicator(animated: animated, completion: nil)
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ final class ActivityIndicatorView: UIView {
|
||||
// MARK: - Setup
|
||||
|
||||
private func commonInit() {
|
||||
self.activityIndicatorBackgroundView.layer.masksToBounds = true
|
||||
activityIndicatorBackgroundView.layer.masksToBounds = true
|
||||
}
|
||||
|
||||
convenience init() {
|
||||
@ -55,37 +55,37 @@ final class ActivityIndicatorView: UIView {
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
self.loadNibContent()
|
||||
self.commonInit()
|
||||
loadNibContent()
|
||||
commonInit()
|
||||
}
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
self.loadNibContent()
|
||||
self.commonInit()
|
||||
loadNibContent()
|
||||
commonInit()
|
||||
}
|
||||
|
||||
// MARK: - Overrides
|
||||
|
||||
override var intrinsicContentSize: CGSize {
|
||||
return CGSize(width: self.activityIndicatorView.intrinsicContentSize.width + Constants.activityIndicatorMargin.width,
|
||||
height: self.activityIndicatorView.intrinsicContentSize.height + Constants.activityIndicatorMargin.height)
|
||||
return CGSize(width: activityIndicatorView.intrinsicContentSize.width + Constants.activityIndicatorMargin.width,
|
||||
height: activityIndicatorView.intrinsicContentSize.height + Constants.activityIndicatorMargin.height)
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
self.activityIndicatorBackgroundView.layer.cornerRadius = Constants.cornerRadius
|
||||
activityIndicatorBackgroundView.layer.cornerRadius = Constants.cornerRadius
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
func startAnimating() {
|
||||
self.activityIndicatorView.startAnimating()
|
||||
activityIndicatorView.startAnimating()
|
||||
}
|
||||
|
||||
func stopAnimating() {
|
||||
self.activityIndicatorView.stopAnimating()
|
||||
activityIndicatorView.stopAnimating()
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ private extension UIView {
|
||||
let layoutAttributes: [NSLayoutConstraint.Attribute] = [.top, .leading, .bottom, .trailing]
|
||||
for case let view as UIView in type(of: self).nib.instantiate(withOwner: self, options: nil) {
|
||||
view.translatesAutoresizingMaskIntoConstraints = false
|
||||
self.addSubview(view)
|
||||
addSubview(view)
|
||||
NSLayoutConstraint.activate(layoutAttributes.map { attribute in
|
||||
NSLayoutConstraint(
|
||||
item: view, attribute: attribute,
|
||||
|
@ -52,7 +52,7 @@ final class LabelledActivityIndicatorView: UIView {
|
||||
}()
|
||||
|
||||
private let label: UILabel = {
|
||||
return UILabel()
|
||||
UILabel()
|
||||
}()
|
||||
|
||||
init(text: String) {
|
||||
|
@ -58,7 +58,7 @@ class RoundedToastView: UIView {
|
||||
}()
|
||||
|
||||
private let label: UILabel = {
|
||||
return UILabel()
|
||||
UILabel()
|
||||
}()
|
||||
|
||||
init(viewState: ToastViewState) {
|
||||
|
@ -37,6 +37,6 @@ public class StaticUserIndicatorPresentationContext: UserIndicatorPresentationCo
|
||||
public private(set) weak var indicatorPresentingViewController: UIViewController?
|
||||
|
||||
public init(viewController: UIViewController) {
|
||||
self.indicatorPresentingViewController = viewController
|
||||
indicatorPresentingViewController = viewController
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class UserIndicatorTypePresenter: UserIndicatorTypePresenterProtocol {
|
||||
|
||||
init(presentationContext: UserIndicatorPresentationContext) {
|
||||
self.presentationContext = presentationContext
|
||||
self.queue = UserIndicatorQueue()
|
||||
queue = UserIndicatorQueue()
|
||||
}
|
||||
|
||||
convenience init(presentingViewController: UIViewController) {
|
||||
|
@ -27,7 +27,7 @@ typealias UserIndicatorCancel = () -> Void
|
||||
|
||||
init(presenter: UserIndicatorTypePresenterProtocol) {
|
||||
self.presenter = presenter
|
||||
self.indicators = []
|
||||
indicators = []
|
||||
}
|
||||
|
||||
/// Present a new type of user indicator, such as loading spinner or success message.
|
||||
|
@ -64,7 +64,7 @@ final class TemplateSimpleScreenCoordinator: Coordinator, Presentable {
|
||||
}
|
||||
|
||||
func toPresentable() -> UIViewController {
|
||||
return self.templateSimpleScreenHostingController
|
||||
templateSimpleScreenHostingController
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
Loading…
x
Reference in New Issue
Block a user