diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 03263971..a82a4675 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -18,6 +18,8 @@ 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */; }; 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */; }; 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; + B8200E152280C4CF007245F4 /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8200E142280C4CF007245F4 /* ProgressBar.swift */; }; + B8200E192281DC1A007245F4 /* ProgressBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8200E182281DC1A007245F4 /* ProgressBarView.swift */; }; D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; @@ -184,6 +186,8 @@ 01CA51B4229716F60071A6EE /* Switch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Switch.swift; sourceTree = ""; }; 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = ""; }; 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = ""; }; + B8200E142280C4CF007245F4 /* ProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = ""; }; + B8200E182281DC1A007245F4 /* ProgressBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarView.swift; sourceTree = ""; }; D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = ""; }; D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUINavigationController.m; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; @@ -465,6 +469,8 @@ D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */, D274CA322236A78900B01B62 /* StandardFooterView.swift */, D2E1FADC2268B25E00AEFD8C /* MoleculeTableViewCell.swift */, + B8200E142280C4CF007245F4 /* ProgressBar.swift */, + B8200E182281DC1A007245F4 /* ProgressBarView.swift */, ); path = Molecules; sourceTree = ""; @@ -918,6 +924,7 @@ D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */, + B8200E152280C4CF007245F4 /* ProgressBar.swift in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, @@ -972,6 +979,7 @@ D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */, D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */, + B8200E192281DC1A007245F4 /* ProgressBarView.swift in Sources */, D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */, 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */, D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, diff --git a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.h b/MVMCoreUI/Atoms/TextFields/MFDigitTextField.h index 936ed017..4be970da 100644 --- a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.h +++ b/MVMCoreUI/Atoms/TextFields/MFDigitTextField.h @@ -8,6 +8,7 @@ #import +@class MFDigitTextBox; @interface MFDigitTextField : MFTextField + (nullable instancetype)mfDigitTextFieldWithNumberOfDigits:(NSUInteger)numberOfDigits; @@ -18,4 +19,6 @@ - (void)setAsSecureTextEntry:(BOOL)secureTextEntry; +@property (nullable, nonatomic, strong) NSArray *textFields; +//Be careful when using this directly. There's a possiblity that you may break the view. @end diff --git a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.m b/MVMCoreUI/Atoms/TextFields/MFDigitTextField.m index d04cd56c..084ba338 100644 --- a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFDigitTextField.m @@ -29,7 +29,7 @@ @property (nullable, nonatomic, weak) IBOutlet NSLayoutConstraint *messageToTextFieldPin; @property (nullable, nonatomic, weak) IBOutlet NSLayoutConstraint *labelToTextFieldPin; -@property (nullable, nonatomic, strong) NSArray *textFields; + @property (nonatomic) BOOL switchedAutomatically; @end diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 4bdbc8d3..95a85ff5 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -576,7 +576,7 @@ - (BOOL)isValidField { - return self.valid; + return self.isValid; } - (nullable NSString *)formFieldName { diff --git a/MVMCoreUI/Molecules/ProgressBar.swift b/MVMCoreUI/Molecules/ProgressBar.swift new file mode 100644 index 00000000..a9d7ad48 --- /dev/null +++ b/MVMCoreUI/Molecules/ProgressBar.swift @@ -0,0 +1,49 @@ +// +// ProgressBar.swift +// MVMCoreUI +// +// Created by Panth Patel on 5/3/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ProgressBar: UIProgressView { + + var isRounded = Bool() + var thickness : Float = 0.0 { + willSet(newValue) { + heightAnchor.constraint(equalToConstant: CGFloat(newValue)).isActive = true + switch isRounded { + case true: + layer.cornerRadius = CGFloat(newValue/2) + clipsToBounds = true + default: + progressViewStyle = .bar + } + } + } + + public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + isRounded = json?.optionalBoolForKey("roundedRect") ?? false + thickness = json?.floatFromStringForKey("thickness") ?? Float(0.0) + let percentage = json?.floatFromStringForKey("percent") + progress = (percentage ?? Float(0.0))/100 + progressTintColor = UIColor.mfBattleshipGrey() + trackTintColor = UIColor.mfLighterGray() + + if let progresscolor = json?.optionalStringForKey("progressColor") { + if !progresscolor.isEmpty { + progressTintColor = UIColor.mfGet(forHex: progresscolor) + } + } + + if let backgroundcolor = json?.optionalStringForKey("backgroundColor") { + if !backgroundcolor.isEmpty { + trackTintColor = UIColor.mfGet(forHex: backgroundcolor) + } + } + } +} + + diff --git a/MVMCoreUI/Molecules/ProgressBarView.swift b/MVMCoreUI/Molecules/ProgressBarView.swift new file mode 100644 index 00000000..8106e0f7 --- /dev/null +++ b/MVMCoreUI/Molecules/ProgressBarView.swift @@ -0,0 +1,99 @@ +// +// ProgressBarView.swift +// MVMCoreUI +// +// Created by Panth Patel on 5/3/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class ProgressBarView: ViewConstrainingView { + + var progress = ProgressBar() + var topleftlabel = Label() + var toprightlabel = Label() + var bottomleftlabel = Label() + var bottomrightlabel = Label() + + open override func needsToBeConstrained() -> Bool { + return true + } + + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + progress.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + + let topleftlabeljson = json?.optionalDictionaryForKey("label") + let toprightlabeljson = json?.optionalDictionaryForKey("toprightlabel") + let bottomleftlabeljson = json?.optionalDictionaryForKey("bottomleftlabel") + let bottomrightlabeljson = json?.optionalDictionaryForKey("bottomrightlabel") + + topleftlabel.setWithJSON(topleftlabeljson, delegateObject: delegateObject, additionalData: additionalData) + toprightlabel.setWithJSON(toprightlabeljson, delegateObject: delegateObject, additionalData: additionalData) + bottomleftlabel.setWithJSON(bottomleftlabeljson, delegateObject: delegateObject, additionalData: additionalData) + bottomrightlabel.setWithJSON(bottomrightlabeljson, delegateObject: delegateObject, additionalData: additionalData) + } + + override open func setupView() { + super.setupView() + addSubview(topleftlabel) + addSubview(toprightlabel) + addSubview(bottomleftlabel) + addSubview(bottomrightlabel) + addSubview(progress) + + progress.translatesAutoresizingMaskIntoConstraints = false + + topleftlabel.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true + topleftlabel.topAnchor.constraint(equalTo: self.topAnchor).isActive = true + let topleftwidthconstraint = NSLayoutConstraint(item: topleftlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0) + topleftwidthconstraint.priority = UILayoutPriority(100) + topleftwidthconstraint.isActive = true + topleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .horizontal) + topleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .vertical) + + NSLayoutConstraint(item: toprightlabel, attribute: .leading, relatedBy: .equal, toItem: topleftlabel, attribute: .trailing, multiplier: 1.0, constant: PaddingTwo).isActive = true + toprightlabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true + toprightlabel.topAnchor.constraint(equalTo: self.topAnchor).isActive = true + toprightlabel.textAlignment = .right + toprightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .horizontal) + toprightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .vertical) + + var topconstraint = progress.topAnchor.constraint(equalTo: topleftlabel.bottomAnchor, constant: PaddingTwo) + topconstraint.priority = UILayoutPriority(249) + topconstraint.isActive = true + progress.topAnchor.constraint(greaterThanOrEqualTo: topleftlabel.bottomAnchor, constant: PaddingTwo).isActive = true + topconstraint = progress.topAnchor.constraint(equalTo: toprightlabel.bottomAnchor, constant: PaddingTwo) + topconstraint.priority = UILayoutPriority(249) + topconstraint.isActive = true + progress.topAnchor.constraint(greaterThanOrEqualTo: toprightlabel.bottomAnchor, constant: PaddingTwo).isActive = true + + progress.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true + progress.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true + + bottomleftlabel.topAnchor.constraint(equalTo: progress.bottomAnchor, constant: PaddingTwo).isActive = true + bottomleftlabel.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true + let bottomleftwidthconstraint = NSLayoutConstraint(item: bottomleftlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0) + bottomleftwidthconstraint.priority = UILayoutPriority(100) + bottomleftwidthconstraint.isActive = true + bottomleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .horizontal) + bottomleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .vertical) + + NSLayoutConstraint(item: bottomrightlabel, attribute: .leading, relatedBy: .equal, toItem: bottomleftlabel, attribute: .trailing, multiplier: 1.0, constant: PaddingTwo).isActive = true + bottomrightlabel.topAnchor.constraint(equalTo: progress.bottomAnchor, constant: PaddingTwo).isActive = true + bottomrightlabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true + bottomrightlabel.textAlignment = .right + bottomrightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .horizontal) + bottomrightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .vertical) + + var bottomconstraint = bottomAnchor.constraint(equalTo: bottomleftlabel.bottomAnchor, constant: PaddingTwo) + bottomconstraint.priority = UILayoutPriority(249) + bottomconstraint.isActive = true + bottomAnchor.constraint(greaterThanOrEqualTo: bottomleftlabel.bottomAnchor, constant: PaddingTwo).isActive = true + bottomconstraint = bottomAnchor.constraint(equalTo: bottomrightlabel.bottomAnchor, constant: PaddingTwo) + bottomconstraint.priority = UILayoutPriority(249) + bottomconstraint.isActive = true + bottomAnchor.constraint(greaterThanOrEqualTo: bottomrightlabel.bottomAnchor, constant: PaddingTwo).isActive = true + } +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 01f0e298..29fb217e 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -34,6 +34,10 @@ @"footer": StandardFooterView.class, @"caretView": CaretView.class, @"caretButton": CaretButton.class, + @"textField" : MFTextField.class, + @"checkbox" : MVMCoreUICheckBox.class, + @"progressBarView" : ProgressBarView.class, + @"progressBar": ProgressBar.class, @"textField": MFTextField.class, @"checkbox": MVMCoreUICheckBox.class, @"listItem": MoleculeTableViewCell.class, diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m index affbc470..487a7b51 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m @@ -197,7 +197,13 @@ static const CGFloat VertialShadowOffset = 6; [view.rightAnchor constraintEqualToAnchor:button.rightAnchor constant:PaddingTwo].active = YES; [view.centerYAnchor constraintEqualToAnchor:button.centerYAnchor].active = YES; } else { - [NSLayoutConstraint constraintPinSubview:button pinTop:YES topConstant:PaddingOne pinBottom:NO bottomConstant:0 pinLeft:NO leftConstant:0 pinRight:YES rightConstant:PaddingTwo]; + if (@available(iOS 11.0, *)) { + [button.topAnchor constraintEqualToAnchor:view.safeAreaLayoutGuide.topAnchor constant:PaddingOne].active = YES; + [view.safeAreaLayoutGuide.trailingAnchor constraintEqualToAnchor:button.trailingAnchor constant:PaddingTwo].active = YES; + } else { + [NSLayoutConstraint constraintPinSubview:button pinTop:YES topConstant:PaddingOne pinBottom:NO bottomConstant:0 pinLeft:NO leftConstant:0 pinRight:YES rightConstant:PaddingTwo]; + } + } } return button;