mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-06 12:28:29 +00:00
Enable blank line rules. (#132)
This commit is contained in:
@@ -21,7 +21,6 @@ import UIKit
|
||||
/// It helps to isolate and reuse view controllers and pass dependencies down the navigation hierarchy.
|
||||
@MainActor
|
||||
protocol Coordinator: AnyObject {
|
||||
|
||||
/// Starts job of the coordinator.
|
||||
func start()
|
||||
|
||||
@@ -41,7 +40,6 @@ protocol Coordinator: AnyObject {
|
||||
|
||||
// `Coordinator` default implementation
|
||||
extension Coordinator {
|
||||
|
||||
func add(childCoordinator coordinator: Coordinator) {
|
||||
childCoordinators.append(coordinator)
|
||||
}
|
||||
|
||||
@@ -9,10 +9,8 @@
|
||||
import UIKit
|
||||
|
||||
class ElementNavigationController: UINavigationController {
|
||||
|
||||
override func viewWillLayoutSubviews() {
|
||||
super.viewWillLayoutSubviews()
|
||||
navigationBar.topItem?.backButtonDisplayMode = .minimal
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import SwiftUI
|
||||
|
||||
/// Store Element specific app settings.
|
||||
final class ElementSettings: ObservableObject {
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
public enum UserDefaultsKeys: String {
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
import Foundation
|
||||
|
||||
public extension Bundle {
|
||||
|
||||
/// Get an lproj language bundle from the receiver bundle.
|
||||
/// - Parameter language: The language to try to load.
|
||||
/// - Returns: The lproj bundle if found otherwise nil.
|
||||
@@ -46,5 +45,4 @@ public extension Bundle {
|
||||
.compactMap { $0 }
|
||||
.filter { set.insert($0).inserted }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import DTCoreText
|
||||
import Foundation
|
||||
|
||||
struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
||||
|
||||
private let temporaryBlockquoteMarkingColor = UIColor.magenta
|
||||
private let temporaryCodeBlockMarkingColor = UIColor.cyan
|
||||
private let linkColor = UIColor.blue
|
||||
@@ -159,7 +158,6 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
||||
}
|
||||
|
||||
private func addLinks(_ attributedString: NSMutableAttributedString) {
|
||||
|
||||
let string = attributedString.string
|
||||
let range = NSRange(location: 0, length: attributedString.string.count)
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ public extension DTHTMLElement {
|
||||
/// - imageHandler: An optional image handler to be run on `img` tags (if allowed) to update the `src` attribute.
|
||||
@objc func sanitize(font: UIFont) {
|
||||
if let name = name, !Self.allowedHTMLTags.contains(name) {
|
||||
|
||||
// This is an unsupported tag.
|
||||
// Remove any attachments to fix rendering.
|
||||
textAttachment = nil
|
||||
|
||||
@@ -15,7 +15,6 @@ enum ImageAnonymizerError: Error {
|
||||
}
|
||||
|
||||
enum ImageAnonymizer {
|
||||
|
||||
private static var allowedTextItems: [String] = [
|
||||
"#",
|
||||
"@",
|
||||
@@ -113,5 +112,4 @@ enum ImageAnonymizer {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import SwiftyBeaver
|
||||
|
||||
/// Various MXLog configuration options. Used in conjunction with `MXLog.configure()`
|
||||
@objc public class MXLogConfiguration: NSObject {
|
||||
|
||||
/// the desired log level. `.verbose` by default.
|
||||
@objc public var logLevel = MXLogLevel.verbose
|
||||
|
||||
@@ -58,7 +57,6 @@ private var logger: SwiftyBeaver.Type = {
|
||||
Please see `MXLog.h` for Objective-C options.
|
||||
*/
|
||||
@objc public class MXLog: NSObject {
|
||||
|
||||
/// Method used to customize MXLog's behavior.
|
||||
/// Called automatically when first accessing the logger with the default values.
|
||||
/// Please see `MXLogConfiguration` for all available options.
|
||||
|
||||
@@ -28,9 +28,7 @@ struct NavigationModule {
|
||||
// MARK: - CustomStringConvertible
|
||||
|
||||
extension NavigationModule: CustomStringConvertible {
|
||||
|
||||
var description: String {
|
||||
"NavigationModule: \(presentable), pop completion: \(String(describing: popCompletion))"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import UIKit
|
||||
|
||||
/// `NavigationRouter` is a concrete implementation of NavigationRouterType.
|
||||
final class NavigationRouter: NSObject, NavigationRouterType {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
@@ -117,7 +116,6 @@ final class NavigationRouter: NSObject, NavigationRouterType {
|
||||
}
|
||||
|
||||
func setModules(_ modules: [NavigationModule], hideNavigationBar: Bool, animated: Bool) {
|
||||
|
||||
MXLog.debug("[NavigationRouter] Set modules \(modules)")
|
||||
|
||||
let controllers = modules.map { module -> UIViewController in
|
||||
@@ -279,7 +277,6 @@ final class NavigationRouter: NSObject, NavigationRouterType {
|
||||
}
|
||||
|
||||
func contains(_ module: Presentable) -> Bool {
|
||||
|
||||
let controller = module.toPresentable()
|
||||
return navigationController.viewControllers.contains(controller)
|
||||
}
|
||||
@@ -293,7 +290,6 @@ final class NavigationRouter: NSObject, NavigationRouterType {
|
||||
// MARK: - Private
|
||||
|
||||
private func module(for viewController: UIViewController) -> Presentable {
|
||||
|
||||
guard let module = storedModules[viewController] as? Presentable else {
|
||||
return viewController
|
||||
}
|
||||
@@ -339,7 +335,6 @@ final class NavigationRouter: NSObject, NavigationRouterType {
|
||||
}
|
||||
|
||||
private func postNotification(withName name: Notification.Name, for viewController: UIViewController) {
|
||||
|
||||
let module = module(for: viewController)
|
||||
|
||||
let userInfo: [String: Any] = [
|
||||
@@ -354,14 +349,11 @@ final class NavigationRouter: NSObject, NavigationRouterType {
|
||||
// MARK: - UINavigationControllerDelegate
|
||||
|
||||
extension NavigationRouter: UINavigationControllerDelegate {
|
||||
|
||||
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
|
||||
|
||||
// Try to post `NavigationRouter.willPopModule` notification here
|
||||
}
|
||||
|
||||
func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
|
||||
|
||||
// Ensure the view controller is popping
|
||||
guard let poppedViewController = navigationController.transitionCoordinator?.viewController(forKey: .from),
|
||||
!navigationController.viewControllers.contains(poppedViewController) else {
|
||||
@@ -377,7 +369,6 @@ extension NavigationRouter: UINavigationControllerDelegate {
|
||||
// MARK: - NavigationRouter notification constants
|
||||
|
||||
extension NavigationRouter {
|
||||
|
||||
// MARK: Notification names
|
||||
|
||||
public static let willPushModule = Notification.Name("NavigationRouterWillPushModule")
|
||||
@@ -391,7 +382,6 @@ extension NavigationRouter {
|
||||
// MARK: Notification keys
|
||||
|
||||
public enum NotificationUserInfoKey {
|
||||
|
||||
/// The associated view controller (UIViewController).
|
||||
static let viewController = "viewController"
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import UIKit
|
||||
|
||||
/// `NavigationRouterStore` enables to get a NavigationRouter from a UINavigationController instance.
|
||||
class NavigationRouterStore: NavigationRouterStoreProtocol {
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
static let shared = NavigationRouterStore()
|
||||
@@ -39,7 +38,6 @@ class NavigationRouterStore: NavigationRouterStoreProtocol {
|
||||
// MARK: - Public
|
||||
|
||||
func navigationRouter(for navigationController: UINavigationController) -> NavigationRouterType {
|
||||
|
||||
if let existingNavigationRouter = findNavigationRouter(for: navigationController) {
|
||||
return existingNavigationRouter
|
||||
}
|
||||
@@ -64,7 +62,6 @@ class NavigationRouterStore: NavigationRouterStoreProtocol {
|
||||
}
|
||||
|
||||
@objc private func navigationRouterDidCreate(_ notification: Notification) {
|
||||
|
||||
guard let userInfo = notification.userInfo,
|
||||
let navigationRouter = userInfo[NavigationRouter.NotificationUserInfoKey.navigationRouter] as? NavigationRouterType,
|
||||
let navigationController = userInfo[NavigationRouter.NotificationUserInfoKey.navigationController] as? UINavigationController else {
|
||||
|
||||
@@ -19,7 +19,6 @@ import UIKit
|
||||
/// `NavigationRouterStoreProtocol` describes a structure that enables to get a NavigationRouter from a UINavigationController instance.
|
||||
@MainActor
|
||||
protocol NavigationRouterStoreProtocol {
|
||||
|
||||
/// Gets the existing navigation router for the supplied controller, creating a new one if it doesn't yet exist.
|
||||
/// Note: The store only holds a weak reference to the returned router. It is the caller's responsibility to retain it.
|
||||
func navigationRouter(for navigationController: UINavigationController) -> NavigationRouterType
|
||||
|
||||
@@ -20,7 +20,6 @@ import UIKit
|
||||
/// Routers are used to be passed between coordinators. They handles only `physical` navigation.
|
||||
@MainActor
|
||||
protocol NavigationRouterType: AnyObject, Presentable {
|
||||
|
||||
/// Present modally a view controller on the navigation controller
|
||||
///
|
||||
/// - Parameter module: The Presentable to present.
|
||||
@@ -91,7 +90,6 @@ protocol NavigationRouterType: AnyObject, Presentable {
|
||||
|
||||
// `NavigationRouterType` default implementation
|
||||
extension NavigationRouterType {
|
||||
|
||||
func setRootModule(_ module: Presentable) {
|
||||
setRootModule(module, hideNavigationBar: false, animated: false, popCompletion: nil)
|
||||
}
|
||||
@@ -107,13 +105,11 @@ extension NavigationRouterType {
|
||||
func setModules(_ modules: [Presentable], animated: Bool) {
|
||||
setModules(modules, hideNavigationBar: false, animated: animated)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Presentable <--> NavigationModule Transitive Methods
|
||||
|
||||
extension NavigationRouterType {
|
||||
|
||||
func setRootModule(_ module: NavigationModule) {
|
||||
setRootModule(module.presentable, popCompletion: module.popCompletion)
|
||||
}
|
||||
@@ -132,5 +128,4 @@ extension NavigationRouterType {
|
||||
push(modules.map { $0.toModule() },
|
||||
animated: animated)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,11 +29,9 @@ extension UIViewController: Presentable {
|
||||
}
|
||||
|
||||
extension Presentable {
|
||||
|
||||
/// Returns a new module from the presentable without a pop completion block
|
||||
/// - Returns: Module
|
||||
func toModule() -> NavigationModule {
|
||||
NavigationModule(presentable: self, popCompletion: nil)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import UIKit
|
||||
|
||||
/// `RootRouter` is a concrete implementation of RootRouterType.
|
||||
final class RootRouter: RootRouterType {
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
// `rootViewController` animation constants
|
||||
@@ -69,7 +68,6 @@ final class RootRouter: RootRouterType {
|
||||
// MARK: - Private methods
|
||||
|
||||
private func updateRootViewController(rootViewController: UIViewController?, animated: Bool, completion: (() -> Void)?) {
|
||||
|
||||
if animated {
|
||||
UIView.transition(with: window, duration: RootViewControllerUpdateAnimation.duration, options: RootViewControllerUpdateAnimation.options, animations: {
|
||||
let oldState: Bool = UIView.areAnimationsEnabled
|
||||
|
||||
@@ -20,7 +20,6 @@ import UIKit
|
||||
/// Routers are used to be passed between coordinators. They handles only `physical` navigation.
|
||||
@MainActor
|
||||
protocol RootRouterType: AnyObject {
|
||||
|
||||
/// Update the root view controller
|
||||
///
|
||||
/// - Parameter module: The new root view controller to set
|
||||
|
||||
@@ -73,7 +73,6 @@ class ViewModelContext<ViewState: BindableState, ViewAction>: ObservableObject {
|
||||
/// we can do it in this centralised place.
|
||||
@MainActor
|
||||
class StateStoreViewModel<State: BindableState, ViewAction> {
|
||||
|
||||
typealias Context = ViewModelContext<State, ViewAction>
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
@@ -10,7 +10,6 @@ import SwiftUI
|
||||
|
||||
/// A toggle style that uses a button, with a checked/unchecked image like a checkbox.
|
||||
struct ElementToggleStyle: ToggleStyle {
|
||||
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
Button { configuration.isOn.toggle() } label: {
|
||||
Image(systemName: configuration.isOn ? "checkmark.square.fill" : "square")
|
||||
|
||||
@@ -19,7 +19,6 @@ import UIKit
|
||||
|
||||
/// Used to present activity indicator on a view
|
||||
final class ActivityIndicatorPresenter: ActivityIndicatorPresenterType {
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
private enum Constants {
|
||||
@@ -131,7 +130,6 @@ final class ActivityIndicatorPresenter: ActivityIndicatorPresenterType {
|
||||
}
|
||||
|
||||
private extension UIView {
|
||||
|
||||
/// Add a subview matching parent view using autolayout
|
||||
@objc func vc_addSubViewMatchingParent(_ subView: UIView) {
|
||||
addSubview(subView)
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
import UIKit
|
||||
|
||||
final class ActivityIndicatorView: UIView {
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
private enum Constants {
|
||||
|
||||
@@ -18,7 +18,6 @@ import Foundation
|
||||
import UIKit
|
||||
|
||||
class RectangleToastView: UIView {
|
||||
|
||||
private enum Constants {
|
||||
static let padding = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
|
||||
static let cornerRadius: CGFloat = 8.0
|
||||
|
||||
@@ -70,7 +70,6 @@ class RoundedToastView: UIView {
|
||||
}
|
||||
|
||||
private func setup(viewState: ToastViewState) {
|
||||
|
||||
backgroundColor = .clear
|
||||
clipsToBounds = true
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
import Foundation
|
||||
|
||||
public struct WeakDictionary<Key: Hashable, Value: AnyObject> {
|
||||
|
||||
private var storage: [Key: WeakDictionaryReference<Value>]
|
||||
|
||||
public init() {
|
||||
@@ -48,7 +47,6 @@ public struct WeakDictionary<Key: Hashable, Value: AnyObject> {
|
||||
}
|
||||
|
||||
extension WeakDictionary: Collection {
|
||||
|
||||
public typealias Index = DictionaryIndex<Key, WeakDictionaryReference<Value>>
|
||||
|
||||
public var startIndex: Index {
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
import Foundation
|
||||
|
||||
public struct WeakDictionaryKey<Key: AnyObject & Hashable, Value: AnyObject>: Hashable {
|
||||
|
||||
private weak var baseKey: Key?
|
||||
private let hash: Int
|
||||
private var retainedValue: Value?
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
import Foundation
|
||||
|
||||
public struct WeakKeyDictionary<Key: AnyObject & Hashable, Value: AnyObject> {
|
||||
|
||||
private var storage: WeakDictionary<WeakDictionaryKey<Key, Value>, Value>
|
||||
private let valuesRetainedByKey: Bool
|
||||
|
||||
@@ -69,7 +68,6 @@ public struct WeakKeyDictionary<Key: AnyObject & Hashable, Value: AnyObject> {
|
||||
}
|
||||
|
||||
extension WeakKeyDictionary: Collection {
|
||||
|
||||
public typealias Index = DictionaryIndex<WeakDictionaryKey<Key, Value>, WeakDictionaryReference<Value>>
|
||||
|
||||
public var startIndex: Index {
|
||||
|
||||
Reference in New Issue
Block a user