missing file move

This commit is contained in:
Pfeil, Scott Robert 2020-03-24 12:50:45 -04:00
parent 7a86b0356b
commit 438277b37f
4 changed files with 93 additions and 39 deletions

View File

@ -1005,6 +1005,7 @@
0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */,
D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */,
D202AFE5242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift */,
013F801823FB4A8E00AD8013 /* UIContentMode+Extension.swift */,
);
path = Extensions;
sourceTree = "<group>";
@ -1401,7 +1402,6 @@
D29DF11021E6805F003B2FB9 /* Categories */ = {
isa = PBXGroup;
children = (
013F801823FB4A8E00AD8013 /* UIContentMode+Extension.swift */,
D29DF11121E6805F003B2FB9 /* UIColor+MFConvenience.h */,
D29DF11321E6805F003B2FB9 /* UIColor+MFConvenience.m */,
D29DF11221E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h */,

View File

@ -0,0 +1,89 @@
//
// NSTextAlignment+Extension.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 3/24/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
/**
When using this class in codable for a String value from server.
Example use case....
var alignment: NSTextAlignment
enum CodingKeys: String, CodingKey {
case alignment
}
required public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let word = try container.decode(String.self, forKey: .alignment)
alignment = NSTextAlignment(rawValue: word)!
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(alignment.rawValueString, forKey: .alignment)
}
*/
enum TextAlignmentError: Error {
case notAnAlignment
}
extension NSTextAlignment: RawRepresentable {
init?(rawValue: String) {
switch rawValue {
case "left":
self = .left
case "center":
self = .center
case "right":
self = .right
case "justified":
self = .justified
case "natural":
self = .natural
default:
return nil
}
}
var rawValueString: String {
switch self {
case .left:
return "left"
case .center:
return "center"
case .right:
return "right"
case .justified:
return "justified"
case .natural:
return "natural"
@unknown default:
return ""
}
}
}
extension NSTextAlignment: Codable {
public init(from decoder: Decoder) throws {
let typeContainer = try decoder.singleValueContainer()
let string = try typeContainer.decode(String.self)
guard let alignment = NSTextAlignment(rawValue: string) else {
throw TextAlignmentError.notAnAlignment
}
self = alignment
}
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(rawValueString)
}
}

View File

@ -8,43 +8,8 @@
import Foundation
@objcMembers public class StackCenteredPageTemplateModel: MVMControllerModelProtocol {
public var formRules: [FormGroupRule]?
public var formValidator: FormValidator?
public static var identifier: String = "stackCenterTemplate"
public var pageType: String
public var screenHeading: String?
public var isAtomicTabs: Bool?
public var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)?
public init(pageType: String) {
self.pageType = pageType
}
private enum CodingKeys: String, CodingKey {
case pageType
case template
case screenHeading
case isAtomicTabs
case formRules
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
pageType = try typeContainer.decode(String.self, forKey: .pageType)
screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading)
isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs)
formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(pageType, forKey: .pageType)
try container.encode(template, forKey: .template)
try container.encodeIfPresent(screenHeading, forKey: .screenHeading)
try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs)
try container.encodeIfPresent(formRules, forKey: .formRules)
@objcMembers public class StackCenteredPageTemplateModel: StackPageTemplateModel {
public override class var identifier: String {
return "stackCenterTemplate"
}
}