This commit is contained in:
Pfeil, Scott Robert 2021-02-12 14:21:37 -05:00
commit df030c24a5
8 changed files with 30 additions and 29 deletions

View File

@ -11,18 +11,18 @@ import UIKit
@objcMembers open class Link: Button { @objcMembers open class Link: Button {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Lifecycle // MARK: - Draw
//-------------------------------------------------- //--------------------------------------------------
open override func draw(_ rect: CGRect) { open override func draw(_ rect: CGRect) {
guard let textRect = titleLabel?.frame else { return } guard let textRect = titleLabel?.frame,
let context = UIGraphicsGetCurrentContext()
let context = UIGraphicsGetCurrentContext() else { return }
// Set line to the same color as the text // Set line to the same color as the text
if let color = titleLabel?.textColor?.cgColor { if let color = titleLabel?.textColor?.cgColor {
context?.setStrokeColor(color) context.setStrokeColor(color)
} }
// x should be according to the text, not the button // x should be according to the text, not the button
@ -31,9 +31,9 @@ import UIKit
// Line is 1 point below the text // Line is 1 point below the text
let y = textRect.origin.y + textRect.size.height + 1 let y = textRect.origin.y + textRect.size.height + 1
context?.move(to: CGPoint(x: x, y: y)) context.move(to: CGPoint(x: x, y: y))
context?.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) context.addLine(to: CGPoint(x: x + textRect.size.width, y: y))
context?.strokePath() context.strokePath()
} }
open override var intrinsicContentSize: CGSize { open override var intrinsicContentSize: CGSize {
@ -67,16 +67,12 @@ extension Link {
open override func updateView(_ size: CGFloat) { open override func updateView(_ size: CGFloat) {
super.updateView(size) super.updateView(size)
DispatchQueue.main.async { [weak self] in var width = size
guard let self = self else { return } if MVMCoreGetterUtility.fequal(a: Float.leastNormalMagnitude, b: Float(size)) {
width = MVMCoreUIUtility.getWidth()
var width = size
if MVMCoreGetterUtility.fequal(a: Float.leastNormalMagnitude, b: Float(size)) {
width = MVMCoreUIUtility.getWidth()
}
self.titleLabel?.font = MFStyler.fontB2(forWidth: width)
} }
titleLabel?.font = MFStyler.fontB2(forWidth: width)
} }
open override func setupView() { open override func setupView() {

View File

@ -14,9 +14,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
public class var identifier: String { public class var identifier: String { "link" }
return "link"
}
public var backgroundColor: Color? public var backgroundColor: Color?
public var accessibilityIdentifier: String? public var accessibilityIdentifier: String?

View File

@ -12,7 +12,7 @@ import AVFoundation
@objcMembers open class VideoDataManager: NSObject { @objcMembers open class VideoDataManager: NSObject {
/// The state of the video. /// The state of the video.
@objc public enum State: Int { @objc public enum VideoState: Int {
case none case none
case loading case loading
case loaded case loaded
@ -23,13 +23,13 @@ import AVFoundation
public var player: AVPlayer? public var player: AVPlayer?
// Thread Safe video state handling. // Thread Safe video state handling.
private var _videoState = State.none private var _videoState = VideoState.none
private let videoStatueQueue = DispatchQueue(label: "com.vzw.mvmcoreui.videoDataManager.state", attributes: .concurrent) private let videoStatueQueue = DispatchQueue(label: "com.vzw.mvmcoreui.videoDataManager.state", attributes: .concurrent)
/// The state of the video. Use KVO to listen for state changes. /// The state of the video. Use KVO to listen for state changes.
@objc public var videoState: State { @objc public var videoState: VideoState {
get { get {
var state = State.none var state = VideoState.none
videoStatueQueue.sync { videoStatueQueue.sync {
state = _videoState state = _videoState
} }

View File

@ -106,6 +106,7 @@ import Foundation
MoleculeObjectMapping.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self) MoleculeObjectMapping.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self)
MoleculeObjectMapping.shared()?.register(viewClass: WebView.self, viewModelClass: WebViewModel.self) MoleculeObjectMapping.shared()?.register(viewClass: WebView.self, viewModelClass: WebViewModel.self)
MoleculeObjectMapping.shared()?.register(viewClass: LoadingSpinner.self, viewModelClass: LoadingSpinnerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: LoadingSpinner.self, viewModelClass: LoadingSpinnerModel.self)
MoleculeObjectMapping.shared()?.register(viewClass: Video.self, viewModelClass: VideoModel.self)
// MARK:- Horizontal Combination Molecules // MARK:- Horizontal Combination Molecules
MoleculeObjectMapping.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self) MoleculeObjectMapping.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self)
@ -151,6 +152,7 @@ import Foundation
MoleculeObjectMapping.shared()?.register(viewClass: Scroller.self, viewModelClass: ScrollerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: Scroller.self, viewModelClass: ScrollerModel.self)
MoleculeObjectMapping.shared()?.register(viewClass: ModuleMolecule.self, viewModelClass: ModuleMoleculeModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ModuleMolecule.self, viewModelClass: ModuleMoleculeModel.self)
MoleculeObjectMapping.shared()?.register(viewClass: BGImageMolecule.self, viewModelClass: BGImageMoleculeModel.self) MoleculeObjectMapping.shared()?.register(viewClass: BGImageMolecule.self, viewModelClass: BGImageMoleculeModel.self)
MoleculeObjectMapping.shared()?.register(viewClass: BGVideoImageMolecule.self, viewModelClass: BGVideoImageMoleculeModel.self)
MoleculeObjectMapping.shared()?.register(viewClass: MoleculeSectionHeader.self, viewModelClass: MoleculeSectionHeaderModel.self) MoleculeObjectMapping.shared()?.register(viewClass: MoleculeSectionHeader.self, viewModelClass: MoleculeSectionHeaderModel.self)
MoleculeObjectMapping.shared()?.register(viewClass: MoleculeSectionFooter.self, viewModelClass: MoleculeSectionFooterModel.self) MoleculeObjectMapping.shared()?.register(viewClass: MoleculeSectionFooter.self, viewModelClass: MoleculeSectionFooterModel.self)

View File

@ -54,6 +54,7 @@
var tabs: [UITabBarItem] = [] var tabs: [UITabBarItem] = []
for (index, tab) in model.tabs.enumerated() { for (index, tab) in model.tabs.enumerated() {
let tabBarItem = UITabBarItem(title: tab.title, image: MVMCoreCache.shared()?.getImageFromRegisteredBundles(tab.image), tag: index) let tabBarItem = UITabBarItem(title: tab.title, image: MVMCoreCache.shared()?.getImageFromRegisteredBundles(tab.image), tag: index)
tabBarItem.accessibilityLabel = tab.accessibilityText
if #available(iOS 13.0, *) { if #available(iOS 13.0, *) {
} else { } else {
tabBarItem.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3) tabBarItem.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3)

View File

@ -63,11 +63,13 @@ public class TabBarItemModel: Codable {
var title: String? var title: String?
var image: String var image: String
var action: ActionModelProtocol var action: ActionModelProtocol
var accessibilityText: String?
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case title case title
case image case image
case action case action
case accessibilityText
} }
public init(with title: String?, image: String, action: ActionModelProtocol) { 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) title = try typeContainer.decodeIfPresent(String.self, forKey: .title)
image = try typeContainer.decode(String.self, forKey: .image) image = try typeContainer.decode(String.self, forKey: .image)
action = try typeContainer.decodeModel(codingKey: .action) action = try typeContainer.decodeModel(codingKey: .action)
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
} }
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
@ -88,5 +91,6 @@ public class TabBarItemModel: Codable {
try container.encodeIfPresent(title, forKey: .title) try container.encodeIfPresent(title, forKey: .title)
try container.encode(image, forKey: .image) try container.encode(image, forKey: .image)
try container.encodeModel(action, forKey: .action) try container.encodeModel(action, forKey: .action)
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
} }
} }

View File

@ -50,25 +50,25 @@ open class HeadlineBody: View {
} }
} }
func styleLandingPageHeader() { public func styleLandingPageHeader() {
headlineLabel.setFontStyle(.Title2XLarge) headlineLabel.setFontStyle(.Title2XLarge)
messageLabel.setFontStyle(.RegularBodySmall) messageLabel.setFontStyle(.RegularBodySmall)
spaceBetweenLabelsConstant = Padding.Two spaceBetweenLabelsConstant = Padding.Two
} }
func stylePageHeader() { public func stylePageHeader() {
headlineLabel.setFontStyle(.BoldTitleLarge) headlineLabel.setFontStyle(.BoldTitleLarge)
messageLabel.setFontStyle(.RegularBodySmall) messageLabel.setFontStyle(.RegularBodySmall)
spaceBetweenLabelsConstant = Padding.One spaceBetweenLabelsConstant = Padding.One
} }
func styleListItem() { public func styleListItem() {
headlineLabel.setFontStyle(.BoldBodySmall) headlineLabel.setFontStyle(.BoldBodySmall)
messageLabel.setFontStyle(.RegularBodySmall) messageLabel.setFontStyle(.RegularBodySmall)
spaceBetweenLabelsConstant = 0 spaceBetweenLabelsConstant = 0
} }
func styleListItemDivider() { public func styleListItemDivider() {
headlineLabel.setFontStyle(.BoldTitleMedium) headlineLabel.setFontStyle(.BoldTitleMedium)
messageLabel.setFontStyle(.RegularBodySmall) messageLabel.setFontStyle(.RegularBodySmall)
spaceBetweenLabelsConstant = 0 spaceBetweenLabelsConstant = 0

View File

@ -73,7 +73,7 @@ open class ScrollingViewController: ViewController {
scrollView.flashScrollIndicators() scrollView.flashScrollIndicators()
} }
public func scrollViewDidScroll(_ scrollView: UIScrollView) { open func scrollViewDidScroll(_ scrollView: UIScrollView) {
executeBehaviors { (behavior: PageScrolledBehavior) in executeBehaviors { (behavior: PageScrolledBehavior) in
behavior.pageScrolled(scrollView: scrollView) behavior.pageScrolled(scrollView: scrollView)
} }