Provided an alternative means to provide Codable StackView.Alignment string.
This commit is contained in:
parent
ce1559dc15
commit
77e2269062
@ -46,6 +46,7 @@
|
||||
01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368D23609801006832FA /* HeadlineBodyModel.swift */; };
|
||||
0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; };
|
||||
0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */; };
|
||||
0A209CD323A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */; };
|
||||
0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; };
|
||||
0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; };
|
||||
0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; };
|
||||
@ -281,6 +282,7 @@
|
||||
01EB368C23609801006832FA /* HeaderModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderModel.swift; sourceTree = "<group>"; };
|
||||
01EB368D23609801006832FA /* HeadlineBodyModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyModel.swift; sourceTree = "<group>"; };
|
||||
0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = "<group>"; };
|
||||
0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackViewAlignment+Extension.swift"; sourceTree = "<group>"; };
|
||||
0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = "<group>"; };
|
||||
0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = "<group>"; };
|
||||
0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = "<group>"; };
|
||||
@ -860,6 +862,7 @@
|
||||
D29DF2A721E7B2F9003B2FB9 /* MVMCoreUIConstants.h */,
|
||||
D29DF2A821E7B2F9003B2FB9 /* MVMCoreUIConstants.m */,
|
||||
0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */,
|
||||
0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */,
|
||||
);
|
||||
path = Utility;
|
||||
sourceTree = "<group>";
|
||||
@ -1240,6 +1243,7 @@
|
||||
D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */,
|
||||
D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */,
|
||||
D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */,
|
||||
0A209CD323A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift in Sources */,
|
||||
01004F3022721C3800991ECC /* RadioButton.swift in Sources */,
|
||||
D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */,
|
||||
017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */,
|
||||
|
||||
72
MVMCoreUI/Utility/UIStackViewAlignment+Extension.swift
Normal file
72
MVMCoreUI/Utility/UIStackViewAlignment+Extension.swift
Normal file
@ -0,0 +1,72 @@
|
||||
//
|
||||
// UIStackViewAlignment+Extension.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Kevin Christiano on 12/16/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
When using this class in codable for a String value from server.
|
||||
|
||||
Example use case....
|
||||
|
||||
var alignment: UIStackView.Alignment
|
||||
|
||||
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 = UIStackView.Alignment(rawValue: word)!
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(alignment.rawValueString, forKey: .alignment)
|
||||
}
|
||||
*/
|
||||
extension UIStackView.Alignment: RawRepresentable {
|
||||
|
||||
init?(rawValue: String) {
|
||||
switch rawValue {
|
||||
case "fill":
|
||||
self = .fill
|
||||
case "leading":
|
||||
self = .leading
|
||||
case "firstBaseline":
|
||||
self = .firstBaseline
|
||||
case "center":
|
||||
self = .center
|
||||
case "trailing":
|
||||
self = .trailing
|
||||
case "lastBaseline":
|
||||
self = .lastBaseline
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var rawValueString: String {
|
||||
switch self {
|
||||
case .fill:
|
||||
return "fill"
|
||||
case .leading:
|
||||
return "leading"
|
||||
case .firstBaseline:
|
||||
return "firstBaseline"
|
||||
case .center:
|
||||
return "center"
|
||||
case .trailing:
|
||||
return "trailing"
|
||||
case .lastBaseline:
|
||||
return "lastBaseline"
|
||||
@unknown default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user