added VDS initial extensions

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-01-25 13:04:19 -06:00
parent bfcd559ac4
commit e28cc4fc5b
4 changed files with 136 additions and 0 deletions

View File

@ -599,6 +599,9 @@
EA985C402970939A00F2FF2E /* TileletModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C3F2970939A00F2FF2E /* TileletModel.swift */; };
EA985C602970A3F000F2FF2E /* VDS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA985C5F2970A3F000F2FF2E /* VDS.framework */; };
EA985C642970A40E00F2FF2E /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA985C632970A40E00F2FF2E /* VDSTypographyTokens.xcframework */; };
EA985C852981AA9C00F2FF2E /* VDS-Enums+Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C842981AA9C00F2FF2E /* VDS-Enums+Codable.swift */; };
EA985C872981AB0F00F2FF2E /* VDS-Tilelet+Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C862981AB0F00F2FF2E /* VDS-Tilelet+Codable.swift */; };
EA985C892981AB7100F2FF2E /* VDS-TextStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C882981AB7100F2FF2E /* VDS-TextStyle.swift */; };
EAA0CFAF275E7D8000D65EB0 /* FormFieldEffectProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA0CFAE275E7D8000D65EB0 /* FormFieldEffectProtocol.swift */; };
EAA0CFB1275E823A00D65EB0 /* HideFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA0CFB0275E823A00D65EB0 /* HideFormFieldEffectModel.swift */; };
EAA0CFB3275E831E00D65EB0 /* DisableFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA0CFB2275E831E00D65EB0 /* DisableFormFieldEffectModel.swift */; };
@ -1206,6 +1209,9 @@
EA985C3F2970939A00F2FF2E /* TileletModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileletModel.swift; sourceTree = "<group>"; };
EA985C5F2970A3F000F2FF2E /* VDS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = VDS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EA985C632970A40E00F2FF2E /* VDSTypographyTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSTypographyTokens.xcframework; path = ../SharedFrameworks/VDSTypographyTokens.xcframework; sourceTree = "<group>"; };
EA985C842981AA9C00F2FF2E /* VDS-Enums+Codable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VDS-Enums+Codable.swift"; sourceTree = "<group>"; };
EA985C862981AB0F00F2FF2E /* VDS-Tilelet+Codable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VDS-Tilelet+Codable.swift"; sourceTree = "<group>"; };
EA985C882981AB7100F2FF2E /* VDS-TextStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VDS-TextStyle.swift"; sourceTree = "<group>"; };
EAA0CFAE275E7D8000D65EB0 /* FormFieldEffectProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormFieldEffectProtocol.swift; sourceTree = "<group>"; };
EAA0CFB0275E823A00D65EB0 /* HideFormFieldEffectModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HideFormFieldEffectModel.swift; sourceTree = "<group>"; };
EAA0CFB2275E831E00D65EB0 /* DisableFormFieldEffectModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisableFormFieldEffectModel.swift; sourceTree = "<group>"; };
@ -1617,6 +1623,9 @@
D2ED27E7254B0CE600A1C293 /* UIAlertControllerStyle+Extension.swift */,
D2E0FFF726AF68530085D696 /* UITableViewRowAnimation+Extension.swift */,
4457904D27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift */,
EA985C842981AA9C00F2FF2E /* VDS-Enums+Codable.swift */,
EA985C862981AB0F00F2FF2E /* VDS-Tilelet+Codable.swift */,
EA985C882981AB7100F2FF2E /* VDS-TextStyle.swift */,
);
path = Extensions;
sourceTree = "<group>";
@ -2752,6 +2761,7 @@
D253BB8A24574CC5002DE544 /* StackModel.swift in Sources */,
EAB14BC127D935F00012AB2C /* RuleCompareModelProtocol.swift in Sources */,
011D95A924057AC7000E3791 /* FormGroupWatcherFieldProtocol.swift in Sources */,
EA985C892981AB7100F2FF2E /* VDS-TextStyle.swift in Sources */,
BB2BF0EA2452A9BB001D0FC2 /* ListDeviceComplexButtonSmall.swift in Sources */,
D20C700B250BFDE40095B21C /* MVMCoreUITopAlertView+Extension.swift in Sources */,
D236E5B4241FEB1000C38625 /* ListTwoColumnPriceDescription.swift in Sources */,
@ -2776,6 +2786,7 @@
012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */,
BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */,
32D2609724C19E2100B56344 /* LockupsPlanSMLXLModel.swift in Sources */,
EA985C872981AB0F00F2FF2E /* VDS-Tilelet+Codable.swift in Sources */,
D2092351244F7BE80044AD09 /* ThreeLayerCenterTemplateModel.swift in Sources */,
D21B7F77243BB70700051ABF /* MoleculeCollectionItemModel.swift in Sources */,
AAB9C10A243496DD00151545 /* RadioSwatch.swift in Sources */,
@ -3103,6 +3114,7 @@
BB2FB3BB247E7EBC00DF73CD /* TagCollectionViewCell.swift in Sources */,
012A88C6238DA34000FE3DA1 /* ModuleMoleculeModel.swift in Sources */,
94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */,
EA985C852981AA9C00F2FF2E /* VDS-Enums+Codable.swift in Sources */,
AAB8549824DC01BD00477C40 /* ListThreeColumnBillHistoryDividerModel.swift in Sources */,
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */,
D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */,

View File

@ -0,0 +1,18 @@
//
// VDS-Enums+Codable.swift
// MVMCoreUI
//
// Created by Matt Bruce on 1/25/23.
// Copyright © 2023 Verizon Wireless. All rights reserved.
//
import Foundation
import VDS
extension Surface: Codable {}
extension Badge.FillColor: Codable {}
extension Icon.Name: Codable {}
extension Icon.Size: Codable {}
extension TileContainer.BackgroundColor: Codable {}
extension TileContainer.Padding: Codable {}
extension TileContainer.AspectRatio: Codable {}

View File

@ -0,0 +1,31 @@
//
// VDS-TextStyle.swift
// MVMCoreUI
//
// Created by Matt Bruce on 1/25/23.
// Copyright © 2023 Verizon Wireless. All rights reserved.
//
import Foundation
import VDS
extension Styler.Font {
//Converts Legacy Font to a VDS.TextStyle
public func vdsTextStyle() -> VDS.TextStyle? {
let updatedRaw = rawValue.replacingOccurrences(of: "Regular", with: "")
let newRaw = updatedRaw.prefix(1).lowercased() + updatedRaw.dropFirst()
guard let style = VDS.TextStyle(rawValue: newRaw) else { return nil }
return style
}
public func vdsSubsetStyle<T: EnumSubset>() -> T? {
guard let style = vdsTextStyle() else { return nil }
guard let rawValue = style.rawValue as? T.RawValue,
let found = T(rawValue: rawValue) else {
print("Style: \(style.rawValue) is not in enum \(T.self)\ronly these cases exist:\r\(T.allCases)")
return nil
}
return found
}
}

View File

@ -0,0 +1,75 @@
//
// VDS-Tilelet+Codable.swift
// MVMCoreUI
//
// Created by Matt Bruce on 1/25/23.
// Copyright © 2023 Verizon Wireless. All rights reserved.
//
import Foundation
import VDS
extension Tilelet.BadgeModel: Codable {
private enum CodingKeys: String, CodingKey {
case text, fillColor, surface, numberOfLines, maxWidth
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let text = try container.decode(String.self, forKey: .text)
let fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red
let surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .light
let numberOfLines = try container.decodeIfPresent(Int.self, forKey: .numberOfLines) ?? 0
let maxWidth = try container.decodeIfPresent(CGFloat.self, forKey: .maxWidth)
self.init(text: text, fillColor: fillColor, surface: surface, numberOfLines: numberOfLines, maxWidth: maxWidth)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(fillColor, forKey: .fillColor)
try container.encode(surface, forKey: .surface)
try container.encode(numberOfLines, forKey: .numberOfLines)
try container.encodeIfPresent(maxWidth, forKey: .maxWidth)
}
}
extension Tilelet.DescriptiveIcon: Codable {
private enum CodingKeys: String, CodingKey {
case name, size, surface
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let name = try container.decode(Icon.Name.self, forKey: .name)
let size = try container.decodeIfPresent(Icon.Size.self, forKey: .size) ?? .medium
let surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .dark
self.init(name: name, size: size, surface: surface)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(name, forKey: .name)
try container.encode(size, forKey: .size)
try container.encode(surface, forKey: .surface)
}
}
extension Tilelet.DirectionalIcon: Codable {
private enum CodingKeys: String, CodingKey {
case size, surface
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let size = try container.decodeIfPresent(Icon.Size.self, forKey: .size) ?? .medium
let surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .dark
self.init(size: size, surface: surface)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(size, forKey: .size)
try container.encode(surface, forKey: .surface)
}
}