From 6af01f17fb18460a722cbe3302a7fe9aa80e5d9b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 1 Feb 2023 13:14:35 -0600 Subject: [PATCH] added 5g Signed-off-by: Matt Bruce --- .../JSONCreator.xcodeproj/project.pbxproj | 8 +- .../JSONCreator/5G/BGThreeLayerTemplate.swift | 66 ++++++ JSONCreator_iOS/JSONCreator/AppDelegate.swift | 5 +- JSONCreator_iOS/JSONCreator/TestToggle.swift | 211 ------------------ 4 files changed, 74 insertions(+), 216 deletions(-) create mode 100644 JSONCreator_iOS/JSONCreator/5G/BGThreeLayerTemplate.swift delete mode 100644 JSONCreator_iOS/JSONCreator/TestToggle.swift diff --git a/JSONCreator_iOS/JSONCreator.xcodeproj/project.pbxproj b/JSONCreator_iOS/JSONCreator.xcodeproj/project.pbxproj index ec1f6d1..fcc07ad 100644 --- a/JSONCreator_iOS/JSONCreator.xcodeproj/project.pbxproj +++ b/JSONCreator_iOS/JSONCreator.xcodeproj/project.pbxproj @@ -88,7 +88,7 @@ EA5B696F2866BC1000B17D2E /* MVMCore.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EA5B696C2866BC1000B17D2E /* MVMCore.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; EA5B69702866BC1000B17D2E /* MVMCoreUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA5B696D2866BC1000B17D2E /* MVMCoreUI.framework */; }; EA5B69712866BC1000B17D2E /* MVMCoreUI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EA5B696D2866BC1000B17D2E /* MVMCoreUI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - EA797B2C2902D4BB00DBAFE6 /* TestToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA797B2B2902D4BB00DBAFE6 /* TestToggle.swift */; }; + EA985CC2298AED7000F2FF2E /* BGThreeLayerTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985CC1298AED7000F2FF2E /* BGThreeLayerTemplate.swift */; }; EAA658152875FA5E00484A7D /* VDSFormControlsTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA658142875FA5E00484A7D /* VDSFormControlsTokens.xcframework */; }; EAA658162875FA5E00484A7D /* VDSFormControlsTokens.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EAA658142875FA5E00484A7D /* VDSFormControlsTokens.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; EACA5E5E2853DBC900CBA65B /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EACA5E5D2853DBC900CBA65B /* VDSColorTokens.xcframework */; }; @@ -176,9 +176,9 @@ EA3361FA2891D54A0071C351 /* VDSTypographyTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSTypographyTokens.xcframework; path = ../SharedFrameworks/VDSTypographyTokens.xcframework; sourceTree = ""; }; EA5B696C2866BC1000B17D2E /* MVMCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MVMCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; EA5B696D2866BC1000B17D2E /* MVMCoreUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MVMCoreUI.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - EA797B2B2902D4BB00DBAFE6 /* TestToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestToggle.swift; sourceTree = ""; }; EA7E676927582F2200ABF773 /* MVMCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MVMCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; EA7E676A27582F2200ABF773 /* MVMCoreUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MVMCoreUI.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + EA985CC1298AED7000F2FF2E /* BGThreeLayerTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGThreeLayerTemplate.swift; sourceTree = ""; }; EAA658142875FA5E00484A7D /* VDSFormControlsTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSFormControlsTokens.xcframework; path = ../SharedFrameworks/VDSFormControlsTokens.xcframework; sourceTree = ""; }; EACA5E5D2853DBC900CBA65B /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = ""; }; /* End PBXFileReference section */ @@ -241,7 +241,6 @@ D2B1E3FB22F4A6930065F95C /* Assets.xcassets */, D2B1E3FD22F4A6930065F95C /* LaunchScreen.storyboard */, D2B1E40022F4A6930065F95C /* Info.plist */, - EA797B2B2902D4BB00DBAFE6 /* TestToggle.swift */, ); path = JSONCreator; sourceTree = ""; @@ -289,6 +288,7 @@ EA09CD9A282C3F6B00A7835F /* 5G */ = { isa = PBXGroup; children = ( + EA985CC1298AED7000F2FF2E /* BGThreeLayerTemplate.swift */, EA09CE04282C45C200A7835F /* BluetoothPairBehavior.swift */, EA09CE02282C44A100A7835F /* MFFGHSUtility.swift */, EA09CE00282C43E800A7835F /* KeyedDecodingContainer+Decode.swift */, @@ -514,7 +514,7 @@ D2FC4FB025897ACB00061EA4 /* OrderTracker.swift in Sources */, EA09CDD8282C40CC00A7835F /* GMFGBLEHandlerProtocol.swift in Sources */, EA09CDDC282C40CC00A7835F /* GMFGFotaHandler.swift in Sources */, - EA797B2C2902D4BB00DBAFE6 /* TestToggle.swift in Sources */, + EA985CC2298AED7000F2FF2E /* BGThreeLayerTemplate.swift in Sources */, EA09CDD6282C40CC00A7835F /* GMFGConstant.swift in Sources */, D27564C925939E91003CA713 /* Links.swift in Sources */, EA09CDE6282C416C00A7835F /* BluetoothDebuggableProtocol.swift in Sources */, diff --git a/JSONCreator_iOS/JSONCreator/5G/BGThreeLayerTemplate.swift b/JSONCreator_iOS/JSONCreator/5G/BGThreeLayerTemplate.swift new file mode 100644 index 0000000..4cbc1cb --- /dev/null +++ b/JSONCreator_iOS/JSONCreator/5G/BGThreeLayerTemplate.swift @@ -0,0 +1,66 @@ +// +// BGThreeLayerTemplate.swift +// JSONCreator +// +// Created by Matt Bruce on 2/1/23. +// Copyright © 2023 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCoreUI + +@objcMembers public class BGThreeLayerPageTemplateModel: ThreeLayerPageTemplateModel { + public override class var identifier: String { "bgThreeLayer" } + public var backgroundImage: ImageViewModel + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case backgroundImage + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + backgroundImage = try typeContainer.decode(ImageViewModel.self, forKey: .backgroundImage) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeModelIfPresent(backgroundImage, forKey: .backgroundImage) + } +} + +@objcMembers open class BGThreeLayerTemplate: ThreeLayerTemplate { + + open var backgroundImage: LoadImageView? + + open override func loadView() { + super.loadView() + if let contentView { + let imageView = LoadImageView(pinnedEdges: .all) + imageView.translatesAutoresizingMaskIntoConstraints = false + backgroundImage = imageView + scrollView.insertSubview(imageView, belowSubview: contentView) + imageView.pinTop(view.topAnchor) + imageView.pinBottom(view.bottomAnchor) + imageView.pinLeading(view.leadingAnchor) + imageView.pinTrailing(view.trailingAnchor) + } + } + + open override func handleNewData() { + super.handleNewData() + if let model = templateModel { + backgroundImage?.set(with: model.backgroundImage, nil, nil) + } + } + +} diff --git a/JSONCreator_iOS/JSONCreator/AppDelegate.swift b/JSONCreator_iOS/JSONCreator/AppDelegate.swift index 02f7b84..26f5d70 100644 --- a/JSONCreator_iOS/JSONCreator/AppDelegate.swift +++ b/JSONCreator_iOS/JSONCreator/AppDelegate.swift @@ -122,6 +122,9 @@ extension AppDelegate: MVMCoreGlobalTopAlertDelegateProtocol { extension AppDelegate { func register(){ - ModelRegistry.register(handler: TestToggle.self, for: TestToggleModel.self) + if let mapper = CoreUIObject.sharedInstance()?.viewControllerMapping { + print(mapper) + //mapper.register(template: BGThreeLayerTemplate.self) + } } } diff --git a/JSONCreator_iOS/JSONCreator/TestToggle.swift b/JSONCreator_iOS/JSONCreator/TestToggle.swift deleted file mode 100644 index 92f92f4..0000000 --- a/JSONCreator_iOS/JSONCreator/TestToggle.swift +++ /dev/null @@ -1,211 +0,0 @@ -// -// TestToggle.swift -// JSONCreator -// -// Created by Matt Bruce on 10/21/22. -// Copyright © 2022 Verizon Wireless. All rights reserved. -// - -import Foundation -import MVMCore -import MVMCoreUI -import UIKit -import VDS - -/** - A custom implementation of Apple's UISwitch. - - By default this class begins in the off state. - - Container: The background of the toggle control. - Knob: The circular indicator that slides on the container. - */ -open class TestToggle: ToggleBase, VDSMoleculeViewProtocol { - //-------------------------------------------------- - // MARK: - Properties - //-------------------------------------------------- - public var viewModel: TestToggleModel! - public var delegateObject: MVMCoreUIDelegateObject? - public var additionalData: [AnyHashable: Any]? - - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - public override func initialSetup() { - super.initialSetup() - - publisher(for: .touchUpInside) - .sink {[weak self] toggle in - guard let self = self else { return } - self.toggle() - }.store(in: &subscribers) - - publisher(for: .valueChanged) - .sink {[weak self] toggle in - guard let self = self else { return } - self.valueChanged(isOn: toggle.isOn) - }.store(in: &subscribers) - - accessibilityLabelEnabled = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") - accessibilityLabelDisabled = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") - accessibilityHintEnabled = MVMCoreUIUtility.hardcodedString(withKey: "AccToggleHint") - accessibilityHintDisabled = MVMCoreUIUtility.hardcodedString(withKey: "AccDisabled") - accessibilityValueEnabled = MVMCoreUIUtility.hardcodedString(withKey: "AccOn") - accessibilityValueDisabled = MVMCoreUIUtility.hardcodedString(withKey: "AccOff") - } - - // MARK:- MVMCoreViewProtocol - open func updateView(_ size: CGFloat) {} - - open func viewModelDidUpdate() { - guard let viewModel else { return } - - additionalData = additionalData.dictionaryAdding(key: KeySourceModel, value: viewModel) - } - - private func valueChanged(isOn: Bool){ - guard let viewModel else { return } - //sync the value on the viewModel - viewModel.selected = isOn - - //tell the form you changed - _ = FormValidator.validate(delegate: self.delegateObject?.formHolderDelegate) - - if viewModel.action != nil || viewModel.alternateAction != nil { - var action: ActionModelProtocol? - if isOn { - action = viewModel.action - } else { - action = viewModel.alternateAction ?? viewModel.action - } - if let action { - MVMCoreUIActionHandler.performActionUnstructured(with: action, - sourceModel: viewModel, - additionalData: additionalData, - delegateObject: delegateObject) - } - } - - print("toggle value changed to: \(isOn)") - print("viewModel server value: \(viewModel.formFieldServerValue()!)") - } - - public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 44 - } - - private typealias ActionDefinition = (model: ActionModelProtocol, - sourceModel: MoleculeModelProtocol?) - - private func performActionUnstructured(definition: ActionDefinition) { - MVMCoreUIActionHandler.performActionUnstructured(with: definition.model, - sourceModel: definition.sourceModel, - additionalData: additionalData, - delegateObject: delegateObject) - } -} -// MARK: - MVMCoreUIViewConstrainingProtocol -extension TestToggle { - - public func needsToBeConstrained() -> Bool { true } - - public func horizontalAlignment() -> UIStackView.Alignment { .trailing } -} - -public class TestToggleModel: MoleculeModelProtocol, FormFieldProtocol { - //-------------------------------------------------- - // MARK: - Properties - //-------------------------------------------------- - - public static var identifier: String = "testToggle" - public var backgroundColor: Color? //not used - - public var selected: Bool = false - public var enabled: Bool = true - public var readOnly: Bool = false - public var action: ActionModelProtocol? - public var alternateAction: ActionModelProtocol? - public var accessibilityText: String? - public var fieldKey: String? - public var groupName: String = FormValidator.defaultGroupName - public var baseValue: AnyHashable? - - //-------------------------------------------------- - // MARK: - Keys - //-------------------------------------------------- - - private enum CodingKeys: String, CodingKey { - case moleculeName - case state - case enabled - case readOnly - case action - case accessibilityIdentifier - case alternateAction - case accessibilityText - case fieldKey - case groupName - } - - //-------------------------------------------------- - // MARK: - Form Valdiation - //-------------------------------------------------- - - public func formFieldValue() -> AnyHashable? { - guard enabled else { return nil } - return selected - } - - //-------------------------------------------------- - // MARK: - Server Value - //-------------------------------------------------- - open func formFieldServerValue() -> AnyHashable? { - return formFieldValue() - } - - //-------------------------------------------------- - // MARK: - Initializer - //-------------------------------------------------- - - public init(_ state: Bool) { - selected = state - baseValue = state - } - - //-------------------------------------------------- - // MARK: - Codec - //-------------------------------------------------- - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - - if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) { - selected = state - } - action = try typeContainer.decodeModelIfPresent(codingKey: .action) - alternateAction = try typeContainer.decodeModelIfPresent(codingKey: .alternateAction) - accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) - baseValue = selected - fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) - if let gName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { - groupName = gName - } - enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) ?? true - readOnly = try typeContainer.decodeIfPresent(Bool.self, forKey: .readOnly) ?? false - - - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) - try container.encodeModelIfPresent(action, forKey: .action) - try container.encodeModelIfPresent(alternateAction, forKey: .alternateAction) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(selected, forKey: .state) - try container.encode(enabled, forKey: .enabled) - try container.encodeIfPresent(fieldKey, forKey: .fieldKey) - try container.encodeIfPresent(groupName, forKey: .groupName) - try container.encode(readOnly, forKey: .readOnly) - } -}