decent state

This commit is contained in:
Kevin G Christiano 2020-04-01 17:03:03 -04:00
parent a8e411472f
commit 1758192edf
3 changed files with 39 additions and 170 deletions

View File

@ -89,6 +89,7 @@
0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */; };
0A6682AA2435125F00AD3CA1 /* Styler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A92435125F00AD3CA1 /* Styler.swift */; };
0A6682AC243531C300AD3CA1 /* Padding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682AB243531C300AD3CA1 /* Padding.swift */; };
0A6682AE243538DB00AD3CA1 /* VogueProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682AD243538DB00AD3CA1 /* VogueProtocol.swift */; };
0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */; };
0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */; };
0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; };
@ -476,6 +477,7 @@
0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleGuidelinesProtocol.swift; sourceTree = "<group>"; };
0A6682A92435125F00AD3CA1 /* Styler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Styler.swift; sourceTree = "<group>"; };
0A6682AB243531C300AD3CA1 /* Padding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Padding.swift; sourceTree = "<group>"; };
0A6682AD243538DB00AD3CA1 /* VogueProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VogueProtocol.swift; sourceTree = "<group>"; };
0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyRequiredModel.swift; sourceTree = "<group>"; };
0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseDropdownEntryField.swift; sourceTree = "<group>"; };
0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = "<group>"; };
@ -1472,6 +1474,7 @@
D29DF13921E68637003B2FB9 /* MFStyler.m */,
0A6682A92435125F00AD3CA1 /* Styler.swift */,
0A6682AB243531C300AD3CA1 /* Padding.swift */,
0A6682AD243538DB00AD3CA1 /* VogueProtocol.swift */,
);
path = Styles;
sourceTree = "<group>";
@ -2005,6 +2008,7 @@
AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */,
01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */,
011D9626240EBB16000E3791 /* RadioButtonLabelModel.swift in Sources */,
0A6682AE243538DB00AD3CA1 /* VogueProtocol.swift in Sources */,
AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */,
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */,
944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */,

View File

@ -7,39 +7,14 @@
//
import Foundation
import MVMCore
public protocol VogueProtocol {
}
public protocol VogueViewProtocol {
}
public protocol VogueTextProtocol: VogueProtocol {
func styleFont(_ font: UIFont)
func styleTextColor(_ textColor: UIColor)
}
open class Styler {
//--------------------------------------------------
// MARK: - Enums
//--------------------------------------------------
enum MFViewBorder: Int {
case top
case left
case bottom
case right
}
public enum FontStyle: String {
public enum Font: String {
case Title2XLarge
case TitleXLarge
case BoldTitleLarge
@ -53,7 +28,7 @@ open class Styler {
case BoldMicro
case RegularMicro
func pointSize() -> CGFloat {
public func pointSize() -> CGFloat {
switch self {
case .Title2XLarge:
return 36
@ -82,7 +57,7 @@ open class Styler {
}
}
func isBold() -> Bool {
public func isBold() -> Bool {
switch self {
case .Title2XLarge,
@ -103,39 +78,24 @@ open class Styler {
}
}
func getFont(_ genericScaling: Bool = true) -> UIFont? {
public func getFont(_ genericScaling: Bool = true) -> UIFont? {
let size = genericScaling ? sizeFontGeneric(forCurrentDevice: pointSize()) : pointSize()
return getMVA3FontSize(size, bold: isBold())
}
func styleLabel(_ label: UILabel, genericScaling: Bool = true) {
public func styleLabel(_ label: UILabel, genericScaling: Bool = true) {
label.font = getFont(genericScaling)
label.textColor = .black
}
}
public enum Tier {
case primary
case secondary
case ternary
case quaternary
}
//--------------------------------------------------
// MARK: - Functions
//--------------------------------------------------
class func splitTextFieldWidth() -> CGFloat {
return splitTextFieldWidth(forViewWidth: MVMCoreUISplitViewController.getDetailViewWidth())
}
class func splitTextFieldWidth(forViewWidth width: CGFloat) -> CGFloat {
return (width - CGFloat(PaddingOne)) / 2 - Padding.Default.HorizontalPaddingForApplicationWidth
}
class func sizeObjectGeneric(forCurrentDevice size: CGFloat) -> MFSizeObject? {
open class func sizeObjectGeneric(forCurrentDevice size: CGFloat) -> MFSizeObject? {
let sizeObject = MFSizeObject(standardSize: size, standardiPadPortraitSize: size * 1.3)
sizeObject?.addLargerThanCustomSize(size * 1.4, forThreshold: MFSizeStandardiPadLandscapeThreshold)
@ -143,7 +103,7 @@ open class Styler {
return sizeObject
}
class func sizeFontGeneric(forCurrentDevice size: CGFloat) -> CGFloat {
open class func sizeFontGeneric(forCurrentDevice size: CGFloat) -> CGFloat {
return sizeObjectGeneric(forCurrentDevice: size)?.getValueBasedOnApplicationWidth() ?? 0
}
@ -151,7 +111,7 @@ open class Styler {
// MARK: - Spacing
//--------------------------------------------------
class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat, horizontal: Bool = true, vertical: Bool = false) {
open class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat, horizontal: Bool = true, vertical: Bool = false) {
let horizontalPadding: CGFloat = horizontal ? Padding.Default.horizontalPadding(forSize: size) : 0
let verticalPadding: CGFloat = vertical ? PaddingDefaultVerticalSpacing3 : 0
@ -161,7 +121,7 @@ open class Styler {
}
}
class func setMarginsFor(_ view: UIView?, size: CGFloat, defaultHorizontal horizontal: Bool, top: CGFloat, bottom: CGFloat) {
open class func setMarginsFor(_ view: UIView?, size: CGFloat, defaultHorizontal horizontal: Bool, top: CGFloat, bottom: CGFloat) {
let horizontalPadding: CGFloat = horizontal ? Padding.Default.horizontalPadding(forSize: size) : 0
@ -169,12 +129,8 @@ open class Styler {
MVMCoreUIUtility.setMarginsFor(view, leading: horizontalPadding, top: top, trailing: horizontalPadding, bottom: bottom)
}
}
//--------------------------------------------------
// MARK: - 3.0 fonts
//--------------------------------------------------
class func getMVA3FontSize(_ size: CGFloat, bold isBold: Bool) -> UIFont {
open class func getMVA3FontSize(_ size: CGFloat, bold isBold: Bool) -> UIFont {
if isBold {
return size >= 15 ? MFFonts.mfFontDSBold(size) : MFFonts.mfFontTXBold(size)
@ -183,118 +139,4 @@ open class Styler {
return size >= 15 ? MFFonts.mfFontDSRegular(size) : MFFonts.mfFontTXRegular(size)
}
}
//--------------------------------------------------
// MARK: - Styles
//--------------------------------------------------
class func styleGetAlignCenteredAttrituedString(_ string: inout NSMutableAttributedString?) {
if let string = string, string.length > 0 {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .center
string.addAttribute(.paragraphStyle,
value: paragraphStyle,
range: NSRange(location: 0, length: string.length))
}
}
class func styleGetBoldString(with inputFont: UIFont?, from inputString: String?) -> NSAttributedString? {
let openingRange = (inputString as NSString?)?.range(of: "{")
let closingRange = (inputString as NSString?)?.range(of: "}")
let attrString = NSMutableAttributedString(string: inputString ?? "")
if openingRange?.location != NSNotFound && closingRange?.location != NSNotFound {
let boldLength = (closingRange?.location ?? 0) - (openingRange?.location ?? 0)
if let inputFont = inputFont {
attrString.setAttributes([NSAttributedString.Key.font: inputFont],
range: NSRange(location: openingRange?.location ?? 0,
length: boldLength))
}
if let closingRange = closingRange {
attrString.replaceCharacters(in: closingRange, with: "")
}
if let openingRange = openingRange {
attrString.replaceCharacters(in: openingRange, with: "")
}
}
return attrString
}
//--------------------------------------------------
// MARK: - Gradient Colors
//--------------------------------------------------
class func gradientSpecialTicketGold() -> [AnyHashable] {
return [UIColor(red: 0.72, green: 0.6, blue: 0.33, alpha: 1),
UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1),
UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1),
UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1),
UIColor(red: 0.6, green: 0.42, blue: 0.07, alpha: 1)]
}
class func gradientSpecialTicketGoldCGColor() -> [AnyHashable] {
return [UIColor(red: 0.72, green: 0.6, blue: 0.33, alpha: 1).cgColor,
UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1).cgColor,
UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1).cgColor,
UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1).cgColor,
UIColor(red: 0.6, green: 0.42, blue: 0.07, alpha: 1).cgColor].compactMap { $0 }
}
class func styleGetLowCaseSpace(_ inputString: String?) -> String? {
if (inputString?.count ?? 0) > 0 {
let trimmedString = inputString?.lowercased().trimmingCharacters(in: .whitespacesAndNewlines)
return trimmedString
}
return ""
}
class func labelStrokeAttributes(_ color: UIColor?) -> [AnyHashable: Any]? {
guard let color = color else { return nil }
return [NSAttributedString.Key.strokeColor: color,
NSAttributedString.Key.strokeWidth: -1.0]
}
//--------------------------------------------------
// MARK: - Custom Styling Views
//--------------------------------------------------
class func styleView(_ view: UIView, show border: MFViewBorder, with color: UIColor?, borderLineWidth: CGFloat, borderLineLength borderLineLengh: CGFloat) {
let borderLine = UIView(frame: .zero)
borderLine.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(borderLine)
switch border {
case .top:
NSLayoutConstraint.constraintPinSubview(borderLine, pinTop: true, pinBottom: false, pinLeft: false, pinRight: false)
NSLayoutConstraint.constraintPinView(borderLine, heightConstraint: true, heightConstant: borderLineWidth, widthConstraint: true, widthConstant: borderLineLengh)
NSLayoutConstraint.constraintPinSubview(borderLine, pinCenterX: true, pinCenterY: false)
case .left:
NSLayoutConstraint.constraintPinSubview(borderLine, pinTop: false, pinBottom: false, pinLeft: true, pinRight: false)
NSLayoutConstraint.constraintPinView(borderLine, heightConstraint: true, heightConstant: borderLineLengh, widthConstraint: true, widthConstant: borderLineWidth)
NSLayoutConstraint.constraintPinSubview(borderLine, pinCenterX: false, pinCenterY: true)
case .bottom:
NSLayoutConstraint.constraintPinSubview(borderLine, pinTop: false, pinBottom: true, pinLeft: false, pinRight: false)
NSLayoutConstraint.constraintPinView(borderLine, heightConstraint: true, heightConstant: borderLineWidth, widthConstraint: true, widthConstant: borderLineLengh)
NSLayoutConstraint.constraintPinSubview(borderLine, pinCenterX: true, pinCenterY: false)
case .right:
NSLayoutConstraint.constraintPinSubview(borderLine, pinTop: false, pinBottom: false, pinLeft: false, pinRight: true)
NSLayoutConstraint.constraintPinView(borderLine, heightConstraint: true, heightConstant: borderLineLengh, widthConstraint: true, widthConstant: borderLineWidth)
NSLayoutConstraint.constraintPinSubview(borderLine, pinCenterX: false, pinCenterY: true)
}
borderLine.backgroundColor = color
}
}

View File

@ -0,0 +1,23 @@
//
// VogueProtocol.swift
// MVMCoreUI
//
// Created by Kevin Christiano on 4/1/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol VogueProtocol {
}
public protocol VogueViewProtocol {
}
public protocol VogueTextProtocol: VogueProtocol {
func styleFont(_ font: UIFont)
func styleTextColor(_ textColor: UIColor)
}