Move GraphSize to a higher level for common use.
This commit is contained in:
parent
5cbd472a2d
commit
29466e4e33
@ -155,6 +155,7 @@
|
|||||||
4B002ACA2BD855EC009BC9C1 /* DateDropdownEntryFieldModel+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B002AC92BD855EC009BC9C1 /* DateDropdownEntryFieldModel+Extension.swift */; };
|
4B002ACA2BD855EC009BC9C1 /* DateDropdownEntryFieldModel+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B002AC92BD855EC009BC9C1 /* DateDropdownEntryFieldModel+Extension.swift */; };
|
||||||
4B3408A22C3873B0003BFABF /* CircularProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B3408A12C3873B0003BFABF /* CircularProgressBarModel.swift */; };
|
4B3408A22C3873B0003BFABF /* CircularProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B3408A12C3873B0003BFABF /* CircularProgressBarModel.swift */; };
|
||||||
4B3408A42C3873E8003BFABF /* CircularProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B3408A32C3873E8003BFABF /* CircularProgressBar.swift */; };
|
4B3408A42C3873E8003BFABF /* CircularProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B3408A32C3873E8003BFABF /* CircularProgressBar.swift */; };
|
||||||
|
4B53AF7B2C45BBBA00274685 /* GraphSizeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B53AF7A2C45BBBA00274685 /* GraphSizeProtocol.swift */; };
|
||||||
522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; };
|
522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; };
|
||||||
522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */; };
|
522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */; };
|
||||||
52267A0723FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */; };
|
52267A0723FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */; };
|
||||||
@ -774,6 +775,7 @@
|
|||||||
4B002AC92BD855EC009BC9C1 /* DateDropdownEntryFieldModel+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DateDropdownEntryFieldModel+Extension.swift"; sourceTree = "<group>"; };
|
4B002AC92BD855EC009BC9C1 /* DateDropdownEntryFieldModel+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DateDropdownEntryFieldModel+Extension.swift"; sourceTree = "<group>"; };
|
||||||
4B3408A12C3873B0003BFABF /* CircularProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularProgressBarModel.swift; sourceTree = "<group>"; };
|
4B3408A12C3873B0003BFABF /* CircularProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularProgressBarModel.swift; sourceTree = "<group>"; };
|
||||||
4B3408A32C3873E8003BFABF /* CircularProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularProgressBar.swift; sourceTree = "<group>"; };
|
4B3408A32C3873E8003BFABF /* CircularProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularProgressBar.swift; sourceTree = "<group>"; };
|
||||||
|
4B53AF7A2C45BBBA00274685 /* GraphSizeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GraphSizeProtocol.swift; sourceTree = "<group>"; };
|
||||||
522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = "<group>"; };
|
522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = "<group>"; };
|
||||||
522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinksModel.swift; sourceTree = "<group>"; };
|
522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinksModel.swift; sourceTree = "<group>"; };
|
||||||
52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinks.swift; sourceTree = "<group>"; };
|
52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinks.swift; sourceTree = "<group>"; };
|
||||||
@ -2313,6 +2315,7 @@
|
|||||||
94C2D9822386F3E30006CF46 /* Label */,
|
94C2D9822386F3E30006CF46 /* Label */,
|
||||||
31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */,
|
31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */,
|
||||||
0A7BAFA2232BE63400FB8E22 /* CheckboxLabel.swift */,
|
0A7BAFA2232BE63400FB8E22 /* CheckboxLabel.swift */,
|
||||||
|
4B53AF7A2C45BBBA00274685 /* GraphSizeProtocol.swift */,
|
||||||
D28A838223CCBD3F00DFE4FC /* WheelModel.swift */,
|
D28A838223CCBD3F00DFE4FC /* WheelModel.swift */,
|
||||||
943784F3236B77BB006A1E82 /* Wheel.swift */,
|
943784F3236B77BB006A1E82 /* Wheel.swift */,
|
||||||
4B3408A12C3873B0003BFABF /* CircularProgressBarModel.swift */,
|
4B3408A12C3873B0003BFABF /* CircularProgressBarModel.swift */,
|
||||||
@ -3109,6 +3112,7 @@
|
|||||||
D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */,
|
D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */,
|
||||||
D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */,
|
D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */,
|
||||||
C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */,
|
C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */,
|
||||||
|
4B53AF7B2C45BBBA00274685 /* GraphSizeProtocol.swift in Sources */,
|
||||||
BB2C968F24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift in Sources */,
|
BB2C968F24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift in Sources */,
|
||||||
D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */,
|
D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */,
|
||||||
EA7D81622B2B6E7F00D29F9E /* IconModel.swift in Sources */,
|
EA7D81622B2B6E7F00D29F9E /* IconModel.swift in Sources */,
|
||||||
|
|||||||
@ -10,17 +10,12 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public class CircularProgressBarModel: MoleculeModelProtocol {
|
public class CircularProgressBarModel: GraphSizeBase, MoleculeModelProtocol {
|
||||||
|
|
||||||
public static var identifier: String = "circularProgress"
|
public static var identifier: String = "circularProgress"
|
||||||
public var id: String = UUID().uuidString
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var percent: Int = 0
|
public var percent: Int = 0
|
||||||
public var size: GraphSize? = .small {
|
|
||||||
didSet {
|
|
||||||
updateSize()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public var diameter: CGFloat? = 64
|
public var diameter: CGFloat? = 64
|
||||||
public var lineWidth: CGFloat? = 4
|
public var lineWidth: CGFloat? = 4
|
||||||
public var duration : Double? = 1.0
|
public var duration : Double? = 1.0
|
||||||
@ -29,7 +24,8 @@ public class CircularProgressBarModel: MoleculeModelProtocol {
|
|||||||
public var drawText: Bool? = true
|
public var drawText: Bool? = true
|
||||||
public var backgroundColor: Color? = Color(uiColor: UIColor.clear)
|
public var backgroundColor: Color? = Color(uiColor: UIColor.clear)
|
||||||
|
|
||||||
public init() {
|
public override init() {
|
||||||
|
super.init()
|
||||||
updateSize()
|
updateSize()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +44,8 @@ public class CircularProgressBarModel: MoleculeModelProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
|
|
||||||
|
super.init()
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
|
|
||||||
@ -102,7 +100,7 @@ public class CircularProgressBarModel: MoleculeModelProtocol {
|
|||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateSize() {
|
public override func updateSize() {
|
||||||
switch size {
|
switch size {
|
||||||
case .small:
|
case .small:
|
||||||
diameter = MFSizeObject(standardSize: 64)?.getValueBasedOnApplicationWidth() ?? 64
|
diameter = MFSizeObject(standardSize: 64)?.getValueBasedOnApplicationWidth() ?? 64
|
||||||
@ -116,8 +114,6 @@ public class CircularProgressBarModel: MoleculeModelProtocol {
|
|||||||
diameter = MFSizeObject(standardSize: 124)?.getValueBasedOnApplicationWidth() ?? 124
|
diameter = MFSizeObject(standardSize: 124)?.getValueBasedOnApplicationWidth() ?? 124
|
||||||
lineWidth = MFSizeObject(standardSize: 4)?.getValueBasedOnApplicationWidth() ?? 4
|
lineWidth = MFSizeObject(standardSize: 4)?.getValueBasedOnApplicationWidth() ?? 4
|
||||||
break
|
break
|
||||||
case .none:
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
29
MVMCoreUI/Atomic/Atoms/Views/GraphSizeProtocol.swift
Normal file
29
MVMCoreUI/Atomic/Atoms/Views/GraphSizeProtocol.swift
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
//
|
||||||
|
// GraphSizeProtocol.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Xi Zhang on 7/15/24.
|
||||||
|
// Copyright © 2024 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public enum GraphSize: String, Codable {
|
||||||
|
case small, medium, large
|
||||||
|
}
|
||||||
|
|
||||||
|
public protocol GraphSizeProtocol {
|
||||||
|
var size: GraphSize { get set }
|
||||||
|
func updateSize()
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GraphSizeBase: GraphSizeProtocol {
|
||||||
|
public var size: GraphSize = .small {
|
||||||
|
didSet {
|
||||||
|
updateSize()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func updateSize() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,15 +8,11 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
public enum GraphSize: String, Codable {
|
|
||||||
case small, medium, large
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum GraphStyle: String, Codable {
|
public enum GraphStyle: String, Codable {
|
||||||
case unlimited, safetyMode
|
case unlimited, safetyMode
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WheelModel: MoleculeModelProtocol {
|
public class WheelModel: GraphSizeBase, MoleculeModelProtocol {
|
||||||
|
|
||||||
public static var identifier: String = "wheel"
|
public static var identifier: String = "wheel"
|
||||||
public var id: String = UUID().uuidString
|
public var id: String = UUID().uuidString
|
||||||
@ -27,11 +23,6 @@ public class WheelModel: MoleculeModelProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public var size: GraphSize = .small {
|
|
||||||
didSet {
|
|
||||||
updateSize()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public var diameter: CGFloat = 24
|
public var diameter: CGFloat = 24
|
||||||
public var lineWidth: CGFloat = 5
|
public var lineWidth: CGFloat = 5
|
||||||
public var clockwise: Bool = true
|
public var clockwise: Bool = true
|
||||||
@ -39,7 +30,8 @@ public class WheelModel: MoleculeModelProtocol {
|
|||||||
public var colors = [Color]()
|
public var colors = [Color]()
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
public init() {
|
public override init() {
|
||||||
|
super.init()
|
||||||
updateStyle()
|
updateStyle()
|
||||||
updateSize()
|
updateSize()
|
||||||
}
|
}
|
||||||
@ -58,6 +50,7 @@ public class WheelModel: MoleculeModelProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
|
super.init()
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
|
|
||||||
@ -123,7 +116,7 @@ public class WheelModel: MoleculeModelProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateSize() {
|
public override func updateSize() {
|
||||||
switch size {
|
switch size {
|
||||||
case .small:
|
case .small:
|
||||||
diameter = MFSizeObject(standardSize: 20)?.getValueBasedOnApplicationWidth() ?? 20
|
diameter = MFSizeObject(standardSize: 20)?.getValueBasedOnApplicationWidth() ?? 20
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user