diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 9ced5f5a..04140d6e 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -11,18 +11,18 @@ import UIKit @objcMembers open class Link: Button { //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Draw //-------------------------------------------------- open override func draw(_ rect: CGRect) { - guard let textRect = titleLabel?.frame else { return } - - let context = UIGraphicsGetCurrentContext() + guard let textRect = titleLabel?.frame, + let context = UIGraphicsGetCurrentContext() + else { return } // Set line to the same color as the text if let color = titleLabel?.textColor?.cgColor { - context?.setStrokeColor(color) + context.setStrokeColor(color) } // x should be according to the text, not the button @@ -31,9 +31,9 @@ import UIKit // Line is 1 point below the text let y = textRect.origin.y + textRect.size.height + 1 - context?.move(to: CGPoint(x: x, y: y)) - context?.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) - context?.strokePath() + context.move(to: CGPoint(x: x, y: y)) + context.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) + context.strokePath() } open override var intrinsicContentSize: CGSize { @@ -67,16 +67,12 @@ extension Link { open override func updateView(_ size: CGFloat) { super.updateView(size) - DispatchQueue.main.async { [weak self] in - guard let self = self else { return } - - var width = size - if MVMCoreGetterUtility.fequal(a: Float.leastNormalMagnitude, b: Float(size)) { - width = MVMCoreUIUtility.getWidth() - } - - self.titleLabel?.font = MFStyler.fontB2(forWidth: width) + var width = size + if MVMCoreGetterUtility.fequal(a: Float.leastNormalMagnitude, b: Float(size)) { + width = MVMCoreUIUtility.getWidth() } + + titleLabel?.font = MFStyler.fontB2(forWidth: width) } open override func setupView() { diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 4519b030..f3b48bd4 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -14,9 +14,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode // MARK: - Properties //-------------------------------------------------- - public class var identifier: String { - return "link" - } + public class var identifier: String { "link" } public var backgroundColor: Color? public var accessibilityIdentifier: String? diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift index 14b7cf94..4a6e3ca7 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift @@ -54,6 +54,7 @@ var tabs: [UITabBarItem] = [] for (index, tab) in model.tabs.enumerated() { let tabBarItem = UITabBarItem(title: tab.title, image: MVMCoreCache.shared()?.getImageFromRegisteredBundles(tab.image), tag: index) + tabBarItem.accessibilityLabel = tab.accessibilityText if #available(iOS 13.0, *) { } else { tabBarItem.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift index 581b890e..fc3e9449 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift @@ -63,11 +63,13 @@ public class TabBarItemModel: Codable { var title: String? var image: String var action: ActionModelProtocol + var accessibilityText: String? private enum CodingKeys: String, CodingKey { case title case image case action + case accessibilityText } public init(with title: String?, image: String, action: ActionModelProtocol) { @@ -81,6 +83,7 @@ public class TabBarItemModel: Codable { title = try typeContainer.decodeIfPresent(String.self, forKey: .title) image = try typeContainer.decode(String.self, forKey: .image) action = try typeContainer.decodeModel(codingKey: .action) + accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) } public func encode(to encoder: Encoder) throws { @@ -88,5 +91,6 @@ public class TabBarItemModel: Codable { try container.encodeIfPresent(title, forKey: .title) try container.encode(image, forKey: .image) try container.encodeModel(action, forKey: .action) + try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) } }