This commit is contained in:
Pfeil, Scott Robert 2020-01-08 14:27:11 -05:00
parent 74f7826e4b
commit e2885b0f78
2 changed files with 35 additions and 0 deletions

View File

@ -159,6 +159,7 @@
D282AAB82240342D00C46919 /* NSNumber+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB72240342D00C46919 /* NSNumber+Extension.swift */; };
D2DEDCB723C63F3B00C44CC4 /* Clamping.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2DEDCB623C63F3B00C44CC4 /* Clamping.swift */; };
D2DEDCB923C6400600C44CC4 /* UnitInterval.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2DEDCB823C6400600C44CC4 /* UnitInterval.swift */; };
D2DEDCBB23C65BC300C44CC4 /* Percent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2DEDCBA23C65BC300C44CC4 /* Percent.swift */; };
D2E1FAD92260C3E400AEFD8C /* DelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FAD82260C3E400AEFD8C /* DelegateObject.swift */; };
/* End PBXBuildFile section */
@ -309,6 +310,7 @@
D282AAB72240342D00C46919 /* NSNumber+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSNumber+Extension.swift"; sourceTree = "<group>"; };
D2DEDCB623C63F3B00C44CC4 /* Clamping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Clamping.swift; sourceTree = "<group>"; };
D2DEDCB823C6400600C44CC4 /* UnitInterval.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnitInterval.swift; sourceTree = "<group>"; };
D2DEDCBA23C65BC300C44CC4 /* Percent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Percent.swift; sourceTree = "<group>"; };
D2E1FAD82260C3E400AEFD8C /* DelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DelegateObject.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -688,6 +690,7 @@
children = (
D2DEDCB623C63F3B00C44CC4 /* Clamping.swift */,
D2DEDCB823C6400600C44CC4 /* UnitInterval.swift */,
D2DEDCBA23C65BC300C44CC4 /* Percent.swift */,
);
path = PropertyWrappers;
sourceTree = "<group>";
@ -930,6 +933,7 @@
946EE1B4237B619D0036751F /* Encoder.swift in Sources */,
AFBB96941FBA3A9A0008D868 /* MVMCorePresentAnimationOperation.m in Sources */,
AF43A5841FBB66DE008E9347 /* MVMCoreConstants.m in Sources */,
D2DEDCBB23C65BC300C44CC4 /* Percent.swift in Sources */,
AFBB966A1FBA3A570008D868 /* MVMCoreLoadRequestOperation.m in Sources */,
8876D5F31FB50AB000EB2E3D /* UIFont+MFSpacing.m in Sources */,
D282AAB82240342D00C46919 /* NSNumber+Extension.swift in Sources */,

View File

@ -0,0 +1,31 @@
//
// Progress.swift
// MVMCore
//
// Created by Scott Pfeil on 1/8/20.
// Copyright © 2020 myverizon. All rights reserved.
//
import Foundation
@propertyWrapper
public struct Percent {
@Clamping(range: 0...100)
public var wrappedValue: CGFloat
public init(wrappedValue value: CGFloat) {
self.wrappedValue = value
}
}
extension Percent: Codable {
public init(from decoder: Decoder) throws {
let typeContainer = try decoder.singleValueContainer()
self.wrappedValue = try typeContainer.decode(CGFloat.self)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(wrappedValue)
}
}