diff --git a/Riot/Modules/Common/ActivityIndicator/FullscreenActivityIndicatorPresenter.swift b/Riot/Modules/Common/ActivityIndicator/FullscreenActivityIndicatorPresenter.swift index bf8722202..b5f7cfb14 100644 --- a/Riot/Modules/Common/ActivityIndicator/FullscreenActivityIndicatorPresenter.swift +++ b/Riot/Modules/Common/ActivityIndicator/FullscreenActivityIndicatorPresenter.swift @@ -21,7 +21,7 @@ import UIKit /// Presenter which displays fullscreen loading spinners, and conforming to legacy `ActivityIndicatorPresenterType`, /// but interally wrapping an `UserIndicatorPresenter` which is used in conjuction with `UserIndicator` and `UserIndicatorQueue`. /// -/// Note: clients can skip using `FullscreenActivityIndicatorPresenter` and instead coordiinate with `AppNavigatorProtocol` directly. +/// Note: clients can skip using `FullscreenActivityIndicatorPresenter` and instead coordinate with `AppNavigatorProtocol` directly. /// The presenter exists mostly as a transition for view controllers already using `ActivityIndicatorPresenterType` and / or view controllers /// written in objective-c. @objc final class FullscreenActivityIndicatorPresenter: NSObject, ActivityIndicatorPresenterType { diff --git a/Riot/Modules/Common/ActivityPresenters/ToastUserIndicatorPresenter.swift b/Riot/Modules/Common/ActivityPresenters/ToastUserIndicatorPresenter.swift index f975cd651..281bb92af 100644 --- a/Riot/Modules/Common/ActivityPresenters/ToastUserIndicatorPresenter.swift +++ b/Riot/Modules/Common/ActivityPresenters/ToastUserIndicatorPresenter.swift @@ -22,11 +22,11 @@ import MatrixSDK /// A `UserIndicatorPresentable` responsible for showing / hiding a toast view for loading spinners or success messages. /// It is managed by an `UserIndicator`, meaning the `present` and `dismiss` methods will be called when the parent `UserIndicator` starts or completes. class ToastUserIndicatorPresenter: UserIndicatorPresentable { - private let viewState: RoundedToastView.ViewState + private let viewState: ToastViewState private weak var navigationController: UINavigationController? private weak var view: UIView? - init(viewState: RoundedToastView.ViewState, navigationController: UINavigationController) { + init(viewState: ToastViewState, navigationController: UINavigationController) { self.viewState = viewState self.navigationController = navigationController } diff --git a/Riot/Modules/Common/Toasts/RoundedToastView.swift b/Riot/Modules/Common/Toasts/RoundedToastView.swift index 49aacb6bf..927c608f7 100644 --- a/Riot/Modules/Common/Toasts/RoundedToastView.swift +++ b/Riot/Modules/Common/Toasts/RoundedToastView.swift @@ -35,13 +35,13 @@ class RoundedToastView: UIView, Themable { return indicator }() - private lazy var imagView: UIImageView = { + private lazy var imageView: UIImageView = { let imageView = UIImageView() imageView.contentMode = .scaleAspectFit imageView.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ imageView.widthAnchor.constraint(equalToConstant: Constants.imageViewSize), - imageView.heightAnchor.constraint(equalToConstant: Constants.imageViewSize), + imageView.heightAnchor.constraint(equalToConstant: Constants.imageViewSize) ]) return imageView }() @@ -57,7 +57,7 @@ class RoundedToastView: UIView, Themable { return UILabel() }() - init(viewState: ViewState) { + init(viewState: ToastViewState) { super.init(frame: .zero) setup(viewState: viewState) } @@ -66,7 +66,7 @@ class RoundedToastView: UIView, Themable { fatalError("init(coder:) has not been implemented") } - private func setup(viewState: ViewState) { + private func setup(viewState: ToastViewState) { setupLayer() setupStackView() stackView.addArrangedSubview(toastView(for: viewState.style)) @@ -104,24 +104,13 @@ class RoundedToastView: UIView, Themable { label.textColor = theme.colors.primaryContent } - private func toastView(for style: Style) -> UIView { + private func toastView(for style: ToastViewState.Style) -> UIView { switch style { case .loading: return activityIndicator case .success: - imagView.image = Asset.Images.checkmark.image - return imagView + imageView.image = Asset.Images.checkmark.image + return imageView } } } - -extension RoundedToastView { - enum Style { - case loading - case success - } - struct ViewState { - let style: Style - let label: String - } -} diff --git a/Riot/Modules/Common/Toasts/ToastViewState.swift b/Riot/Modules/Common/Toasts/ToastViewState.swift new file mode 100644 index 000000000..e241d4645 --- /dev/null +++ b/Riot/Modules/Common/Toasts/ToastViewState.swift @@ -0,0 +1,27 @@ +// +// Copyright 2021 New Vector Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import Foundation + +struct ToastViewState { + enum Style { + case loading + case success + } + + let style: Style + let label: String +}