background color consolidation

This commit is contained in:
Pfeil, Scott Robert 2019-06-26 12:58:43 -04:00
parent 0db0f91b3b
commit 01803e90d6
12 changed files with 15 additions and 34 deletions

View File

@ -108,10 +108,6 @@ open class CaretView: MFView {
// Configure class properties with JSON values
guard let dictionary = json else { return }
if let backgroundColorHex = dictionary[KeyBackgroundColor] as? String {
backgroundColor = UIColor.mfGet(forHex: backgroundColorHex)
}
if let strokeColorHex = dictionary["strokeColor"] as? String {
strokeColor = UIColor.mfGet(forHex: strokeColorHex)
}

View File

@ -74,10 +74,6 @@ open class DashLine: MFView {
// Configure class properties with JSON values
guard let jsonDictionary = json else { return }
if let backgroundColorHex = jsonDictionary[KeyBackgroundColor] as? String {
backgroundColor = UIColor.mfGet(forHex: backgroundColorHex)
}
if let isHiddenValue = jsonDictionary[KeyIsHidden] as? Bool {
isHidden = isHiddenValue
}

View File

@ -170,10 +170,6 @@ import Foundation
leftTextLabel.setWithJSON(dictionary.optionalDictionaryForKey("leftText"), delegateObject: delegateObject as? MVMCoreUIDelegateObject, additionalData: additionalData)
rightTextLabel.setWithJSON(dictionary.optionalDictionaryForKey("rightText"), delegateObject: delegateObject as? MVMCoreUIDelegateObject, additionalData: additionalData)
if let backgroundColorHex = dictionary[KeyBackgroundColor] as? String {
backgroundColor = UIColor.mfGet(forHex: backgroundColorHex)
}
if !leftTextLabel.hasText {
constrainRightLabel()
} else if !rightTextLabel.hasText {

View File

@ -186,9 +186,6 @@ import UIKit
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) {
backgroundColor = UIColor.mfGet(forHex: backgroundColorString)
}
if let accessibilityString = json?.optionalStringForKey("accessibilityText") {
imageView.accessibilityLabel = accessibilityString
imageView.accessibilityTraits = .staticText

View File

@ -8,6 +8,9 @@
#import "MFView.h"
@import MVMCore.Swift;
@import MVMCore.NSDictionary_MFConvenience;
#import "MVMCoreUIConstants.h"
#import "UIColor+MFConvenience.h"
@implementation MFView
@ -46,6 +49,11 @@
- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
self.json = json;
NSString *colorString = [json string:KeyBackgroundColor];
if (colorString) {
self.backgroundColor = [UIColor mfGetColorForHex:colorString];
}
}
@end

View File

@ -115,10 +115,7 @@
[self setAsLight];
}
}
NSString *backgroundColor = [json string:KeyBackgroundColor];
if (backgroundColor) {
self.backgroundColor = [UIColor mfGetColorForHex:backgroundColor];
}
} else {
self.hidden = YES;
}

View File

@ -326,6 +326,9 @@
if (self.molecule) {
[self.molecule setWithJSON:json delegateObject:delegateObject additionalData:additionalData];
}
if (self.constrainedView) {
self.backgroundColor = self.constrainedView.backgroundColor;
}
}
@end

View File

@ -111,7 +111,8 @@ public class MoleculeStackView: ViewConstrainingView {
}
translatesAutoresizingMaskIntoConstraints = false
backgroundColor = .clear
addConstrainedView(contentView)
addSubview(contentView)
pinView(toSuperView: contentView)
contentView.setContentHuggingPriority(.defaultHigh, for: .vertical)
contentView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
}
@ -164,10 +165,6 @@ public class MoleculeStackView: ViewConstrainingView {
items = self.items
}
self.items = []
if let colorString = json?.optionalStringForKey(KeyBackgroundColor) {
backgroundColor = .mfGet(forHex: colorString)
}
guard let molecules = json?.arrayForKey(KeyMolecules) as? [[String: Any]] else {
return

View File

@ -95,9 +95,6 @@ public class StandardFooterView: ViewConstrainingView {
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
if let colorString = json?.optionalStringForKey(KeyBackgroundColor) {
backgroundColor = .mfGet(forHex: colorString)
}
twoButtonView.setWithJSON(json?.optionalDictionaryForKey("twoButtonView"), delegateObject: delegateObject, additionalData: additionalData)
textButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegateObject: delegateObject, additionalData: additionalData)
}

View File

@ -122,9 +122,6 @@ public class StandardHeaderView: ViewConstrainingView {
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
if let colorString = json?.optionalStringForKey(KeyBackgroundColor) {
backgroundColor = .mfGet(forHex: colorString)
}
if let colorString = json?.optionalStringForKey("contentColor") {
let color = UIColor.mfGet(forHex: colorString)
headlineLabel.textColor = color

View File

@ -41,9 +41,6 @@ import UIKit
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) {
backgroundColor = UIColor.mfGet(forHex: backgroundColorString)
}
let primaryButtonMap = json?.optionalDictionaryForKey("primaryButton")
let secondaryButtonMap = json?.optionalDictionaryForKey("secondaryButton")
set(primaryButtonJSON: primaryButtonMap, secondaryButtonJSON: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)

View File

@ -89,13 +89,13 @@
return nil;
}
UIView <MVMCoreUIMoleculeViewProtocol>*molecule = [self createMoleculeForName:moleculeName];
[molecule setWithJSON:json delegateObject:delegateObject additionalData:nil];
// Check if we need to constrain this view.
UIView <MVMCoreUIViewConstrainingProtocol> *castMolecule = [molecule conformsToProtocol:@protocol(MVMCoreUIViewConstrainingProtocol)] ? (UIView <MVMCoreUIViewConstrainingProtocol> *)molecule : nil;
if (constrainIfNeeded && [castMolecule respondsToSelector:@selector(needsToBeConstrained)] && [castMolecule needsToBeConstrained]) {
molecule = [[ViewConstrainingView alloc] initWithMolecule:molecule alignment:[castMolecule respondsToSelector:@selector(alignment)] ? [castMolecule alignment] : UIStackViewAlignmentFill];
}
[molecule setWithJSON:json delegateObject:delegateObject additionalData:nil];
return molecule;
}