Merge branch 'feature/label_atom' into 'develop'

Feature/label atom

See merge request BPHV_MIPS/mvm_core_ui!2
This commit is contained in:
Pfeil, Scott Robert 2019-03-05 15:55:51 -05:00
commit 90c674577b
23 changed files with 262 additions and 72 deletions

View File

@ -9,8 +9,8 @@
/* Begin PBXBuildFile section */
01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */; };
01DF567021FA5AB300CC099B /* MVMCoreUITextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* MVMCoreUITextFieldListFormViewController.swift */; };
D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationControllerViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationControllerViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationControllerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationControllerViewController.m */; };
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 */; };
D22D1F1A220341F60077CEC0 /* MVMCoreUICheckBox.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */; settings = {ATTRIBUTES = (Public, ); }; };
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */; };
D22D1F1E220343560077CEC0 /* MVMCoreUICheckMarkView.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F1C220343560077CEC0 /* MVMCoreUICheckMarkView.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -164,8 +164,8 @@
/* Begin PBXFileReference section */
01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = "<group>"; };
01DF566F21FA5AB300CC099B /* MVMCoreUITextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MVMCoreUITextFieldListFormViewController.swift; sourceTree = "<group>"; };
D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationControllerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationControllerViewController.h; sourceTree = "<group>"; };
D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationControllerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUINavigationControllerViewController.m; sourceTree = "<group>"; };
D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = "<group>"; };
D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUINavigationController.m; sourceTree = "<group>"; };
D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICheckBox.h; sourceTree = "<group>"; };
D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUICheckBox.m; sourceTree = "<group>"; };
D22D1F1C220343560077CEC0 /* MVMCoreUICheckMarkView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICheckMarkView.h; sourceTree = "<group>"; };
@ -464,8 +464,8 @@
children = (
D29DF2B721E7BE79003B2FB9 /* TabBarController */,
D29DF2B621E7BE66003B2FB9 /* SplitViewController */,
D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationControllerViewController.h */,
D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationControllerViewController.m */,
D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */,
D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */,
);
path = Containers;
sourceTree = "<group>";
@ -704,7 +704,7 @@
D29DF26421E6A9D9003B2FB9 /* MFTransparentGIFView.h in Headers */,
D29DF27921E7A533003B2FB9 /* MVMCoreUISession.h in Headers */,
D29DF25C21E6A2B6003B2FB9 /* DashLine.h in Headers */,
D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationControllerViewController.h in Headers */,
D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */,
D29DF29D21E7AE38003B2FB9 /* MFStyler.h in Headers */,
D29DF2B021E7B3A4003B2FB9 /* MFTextView.h in Headers */,
D29DF2A921E7B2F9003B2FB9 /* MVMCoreUIConstants.h in Headers */,
@ -889,7 +889,7 @@
D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */,
D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */,
D29DF28A21E7AC2B003B2FB9 /* MFLabel.m in Sources */,
D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationControllerViewController.m in Sources */,
D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */,
D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */,
01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */,
D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */,

View File

@ -8,6 +8,7 @@
#import "PrimaryButton.h"
#import <MVMCoreUI/MFSizeObject.h>
#import <MVMCoreUI/MVMCoreUIConstants.h>
#import "MVMCoreUISplitViewController.h"
#import "MFStyler.h"
#import "UIColor+MFConvenience.h"
@ -566,7 +567,7 @@
self.primaryButtonType = PrimaryButtonTypeCustom;
NSString *color = [json string:@"fillColor"];
self.fillColor = (color ? [UIColor mfGetColorForHex:color] : nil);
color = [json string:@"textColor"];
color = [json string:KeyTextColor];
self.textColor = (color ? [UIColor mfGetColorForHex:color] : nil);
color = [json string:@"borderColor"];
self.borderColor = (color ? [UIColor mfGetColorForHex:color] : nil);

View File

@ -10,7 +10,7 @@
#import <MVMCoreUI/MFView.h>
@class MFSizeObject;
@interface MFLabel : UILabel <MVMCoreViewProtocol>
@interface MFLabel : UILabel <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol>
- (nullable instancetype)initWithStandardFontSize:(CGFloat)size;
@ -23,6 +23,9 @@
// Set the font and set to scale
- (void)setFont:(nonnull UIFont *)font scale:(BOOL)scale;
// Convenience checker for text or attributed text.
- (BOOL)hasText;
#pragma mark - 2.0
+ (nonnull MFLabel *)commonLabelB2:(BOOL)scale;

View File

@ -7,23 +7,60 @@
//
#import "MFLabel.h"
#import "MFStyler.h"
#import <MVMCoreUI/MFStyler.h>
#import <MVMCoreUI/MFSizeObject.h>
#import <MVMCoreUI/MVMCoreUIConstants.h>
#import "UIColor+MFConvenience.h"
#import "MFFonts.h"
#import "MVMCoreUISplitViewController.h"
@import MVMCore.MVMCoreGetterUtility;
@import MVMCore.NSDictionary_MFConvenience;
@import MVMCore.MVMCoreJSONConstants;
@interface MFLabel ()
@property (strong, nonatomic) NSNumber *scaleSize;
// Used for scaling the font in updateView.
@property (strong, nonatomic) NSAttributedString *originalAttributedString;
@end
@implementation MFLabel
- (instancetype)initWithStandardFontSize:(CGFloat)size {
- (void)setupView {
self.backgroundColor = [UIColor clearColor];
self.numberOfLines = 0;
self.lineBreakMode = NSLineBreakByWordWrapping;
self.translatesAutoresizingMaskIntoConstraints = NO;
[self styleB2:YES];
}
- (instancetype)init {
if (self = [super init]) {
[self setupView];
}
return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
self = [super initWithCoder:coder];
if (self) {
[self setupView];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setupView];
}
return self;
}
- (instancetype)initWithStandardFontSize:(CGFloat)size {
if ([self init]) {
self.standardFontSize = size;
}
return self;
@ -31,7 +68,16 @@
- (void)updateView:(CGFloat)size {
self.scaleSize = @(size);
if (!fequal(self.standardFontSize, 0)) {
if (self.originalAttributedString) {
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithAttributedString:self.originalAttributedString];
[attributedString removeAttribute:NSFontAttributeName range:NSMakeRange(0, attributedString.length)];
[self.originalAttributedString enumerateAttribute:NSFontAttributeName inRange:NSMakeRange(0, self.originalAttributedString.length) options:0 usingBlock:^(UIFont *value, NSRange range, BOOL * _Nonnull stop) {
// Loop the original attributed string, resize the fonts.
UIFont *font = [value fontWithSize:[[MFStyler sizeObjectGenericForCurrentDevice:value.pointSize] getValueBasedOnSize:size]];
[attributedString addAttribute:NSFontAttributeName value:font range:range];
}];
self.attributedText = attributedString;
} else if (!fequal(self.standardFontSize, 0)) {
MFSizeObject *sizeObject = self.sizeObject;
if (!sizeObject) {
sizeObject = [MFStyler sizeObjectGenericForCurrentDevice:self.standardFontSize];
@ -56,13 +102,12 @@
#pragma mark - Getters
- (BOOL)hasText {
return self.text.length > 0 || self.attributedText.length > 0;
}
+ (nonnull MFLabel *)label {
MFLabel *label = [[MFLabel alloc] initWithFrame:CGRectZero];
label.backgroundColor = [UIColor clearColor];
label.numberOfLines = 0;
label.lineBreakMode = NSLineBreakByWordWrapping;
label.translatesAutoresizingMaskIntoConstraints = NO;
return label;
return [[MFLabel alloc] initWithFrame:CGRectZero];
}
+ (nonnull MFLabel *)commonLabelB2:(BOOL)scale {
@ -193,6 +238,72 @@
#pragma mark - Setters
+ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData {
if (label) {
label.text = [json string:KeyText];
NSString *textColor = [json string:KeyTextColor];
if (textColor) {
label.textColor = [UIColor mfGetColorForHex:textColor];
}
NSString *backgroundColor = [json string:KeyBackgroundColor];
if (backgroundColor) {
label.backgroundColor = [UIColor mfGetColorForHex:backgroundColor];
}
NSString *accessibilityText = [json string:@"accessibilityText"];
if (accessibilityText) {
label.accessibilityLabel = accessibilityText;
}
NSString *fontName = [json string:@"fontName"];
NSNumber *fontSize = [json optionalNumberForKey:@"fontSize"];
if (fontName) {
label.font = [MFFonts mfFontWithName:fontName size:fontSize ? fontSize.doubleValue : label.font.pointSize];
} else if (fontSize) {
label.font = [label.font fontWithSize:fontSize.doubleValue];
}
NSArray *attributes = [json array:@"attributes"];
if (attributes) {
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:label.text attributes:@{NSFontAttributeName:label.font,NSForegroundColorAttributeName:label.textColor}];
for (NSDictionary *attribute in attributes) {
NSNumber *location = [attribute optionalNumberForKey:@"location"];
NSNumber *length = [attribute optionalNumberForKey:@"length"];
if (location && length) {
NSRange range = NSMakeRange(location.unsignedIntegerValue, length.unsignedIntegerValue);
NSString *type = [attribute string:KeyType];
if ([type isEqualToString:@"underline"]) {
[attributedString addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:range];
} else if ([type isEqualToString:@"strikethrough"]) {
[attributedString addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlineStyleThick) range:range];
} else if ([type isEqualToString:@"color"]) {
NSString *color = [attribute string:KeyTextColor];
if (color) {
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor mfGetColorForHex:color] range:range];
}
} else if ([type isEqualToString:@"font"]) {
NSString *fontName = [attribute string:@"name"];
NSNumber *fontSize = [attribute optionalNumberForKey:@"size"];
UIFont *font = nil;
if (fontName) {
font = [MFFonts mfFontWithName:fontName size:fontSize ? fontSize.doubleValue : label.font.pointSize];
} else if (fontSize) {
font = [label.font fontWithSize:fontSize.doubleValue];
}
if (font) {
[attributedString addAttribute:NSFontAttributeName value:font range:range];
}
}
}
}
label.attributedText = attributedString;
}
}
}
- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData {
[MFLabel setUILabel:self withJSON:json delegate:delegate additionalData:additionalData];
self.originalAttributedString = self.attributedText;
}
- (void)styleB2:(BOOL)scale {
[MFStyler styleLabelB2:self genericScaling:NO];
[self setScale:scale];

View File

@ -8,8 +8,11 @@
#import "SeparatorView.h"
#import <MVMCoreUI/MFSizeObject.h>
#import <MVMCoreUI/MVMCoreUIConstants.h>
#import "MVMCoreUICommonViewsUtility.h"
#import "UIColor+MFConvenience.h"
@import MVMCore.MVMCoreJSONConstants;
@import MVMCore.NSDictionary_MFConvenience;
@interface SeparatorView()
@ -17,9 +20,6 @@
@implementation SeparatorView
#pragma mark - class methods
+ (nullable SeparatorView *)separatorAddToView:(nullable UIView *)superView position:(SeparatorPosition)position positionPadding:(CGFloat)positionPadding withHorizontalPadding:(CGFloat)padding {
@ -95,6 +95,27 @@
}
}
- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData {
[super setWithJSON:json delegate:delegate additionalData:additionalData];
if (json) {
self.hidden = NO;
NSString *type = [json string:KeyType];
if ([type isEqualToString:@"standard"]) {
[self setSize:1];
} else if ([type isEqualToString:@"medium"]) {
[self setSize:2];
} else if ([type isEqualToString:@"heavy"]) {
[self setSize:4];
}
NSString *backgroundColor = [json string:KeyBackgroundColor];
if (backgroundColor) {
self.backgroundColor = [UIColor mfGetColorForHex:backgroundColor];
}
} else {
self.hidden = YES;
}
}
#pragma mark - helper
- (void)hide {
@ -104,37 +125,37 @@
self.hidden = NO;
}
- (void)setAsHeavy {
self.heightSizeObject.standardSize = 4;
- (void)setSize:(CGFloat)size {
self.heightSizeObject.standardSize = size;
self.height.constant = [self.heightSizeObject getValueBasedOnScreenSize];
}
- (void)setAsHeavy {
[self setSize:4];
self.backgroundColor = [UIColor blackColor];
[self setNeedsLayout];
[self layoutIfNeeded];
}
- (void)setAsRegular {
self.heightSizeObject.standardSize = 1;
self.height.constant = [self.heightSizeObject getValueBasedOnScreenSize];
[self setSize:1];
self.backgroundColor = [UIColor blackColor];
[self setNeedsLayout];
[self layoutIfNeeded];
}
- (void)setAsLight {
self.heightSizeObject.standardSize = 1;
self.height.constant = [self.heightSizeObject getValueBasedOnScreenSize];
[self setSize:1];
self.backgroundColor = [UIColor mfSilver];
[self setNeedsLayout];
[self layoutIfNeeded];
}
- (void)setAsMedium {
self.heightSizeObject.standardSize = 2;
self.height.constant = [self.heightSizeObject getValueBasedOnScreenSize];
[self setSize:2];
self.backgroundColor = [UIColor blackColor];
[self setNeedsLayout];
[self layoutIfNeeded];
}
@end

View File

@ -35,7 +35,7 @@
#import "MVMCoreUISession.h"
#import "MVMCoreUILoggingHandler.h"
#import "MVMCoreUITabBarPageControlViewController.h"
#import "MVMCoreUINavigationControllerViewController.h"
#import "MVMCoreUINavigationController.h"
@import MVMAnimationFramework;
@interface MFViewController ()

View File

@ -1,5 +1,5 @@
//
// MVMCoreUINavigationControllerViewController.h
// MVMCoreUINavigationController.h
// MVMCoreUI
//
// Created by Scott Pfeil on 1/25/19.
@ -10,7 +10,7 @@
@class SeparatorView;
NS_ASSUME_NONNULL_BEGIN
@interface MVMCoreUINavigationControllerViewController : UINavigationController
@interface MVMCoreUINavigationController : UINavigationController
// Convenience getter
+ (nullable instancetype)navigationController;

View File

@ -1,12 +1,12 @@
//
// MVMCoreUINavigationControllerViewController.m
// MVMCoreUINavigationController.m
// MVMCoreUI
//
// Created by Scott Pfeil on 1/25/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
#import "MVMCoreUINavigationControllerViewController.h"
#import "MVMCoreUINavigationController.h"
#import "UIColor+MFConvenience.h"
#import "SeparatorView.h"
#import "MFFonts.h"
@ -14,18 +14,18 @@
#import "MVMCoreUISession.h"
@import MVMCore.MVMCoreActionUtility;
@import MVMCore.MVMCoreNavigationHandler;
@interface MVMCoreUINavigationControllerViewController ()
@interface MVMCoreUINavigationController ()
@end
@implementation MVMCoreUINavigationControllerViewController
@implementation MVMCoreUINavigationController
+ (nullable instancetype)navigationController {
return [MVMCoreActionUtility initializerClassCheck:[MVMCoreUISession sharedGlobal].navigationController classToVerify:self];
}
+ (nullable instancetype)setupNavigationController {
MVMCoreUINavigationControllerViewController *navigationController = [[MVMCoreUINavigationControllerViewController alloc] init];
MVMCoreUINavigationController *navigationController = [[MVMCoreUINavigationController alloc] init];
[UIColor mfSetBackgroundColorForNavigationBar:[UIColor whiteColor] navigationBar:navigationController.navigationBar transparent:NO];
[navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
navigationController.navigationBar.translucent = NO;
@ -44,7 +44,7 @@
}
+ (nullable instancetype)setupWithNavigationControllerAsMainController {
MVMCoreUINavigationControllerViewController *navigationController = [self setupNavigationController];
MVMCoreUINavigationController *navigationController = [self setupNavigationController];
[[MVMCoreUISession sharedGlobal] setupAsStandardLoadViewDelegate:navigationController];
return navigationController;
}

View File

@ -12,7 +12,7 @@
#import <MVMCoreUI/MVMCoreUIPanelProtocol.h>
#import <MVMCoreUI/MVMCoreUIPanelButtonProtocol.h>
@class MVMCoreUINavigationControllerViewController;
@class MVMCoreUINavigationController;
@class MVMCoreUITopAlertView;
@class MFViewController;
@ -34,7 +34,7 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) {
@property (nullable, strong, nonatomic) UIBarButtonItem *backButton;
@property (nullable, weak, nonatomic, readonly) MVMCoreUINavigationControllerViewController *navigationController;
@property (nullable, weak, nonatomic, readonly) MVMCoreUINavigationController *navigationController;
// Reference to the top alert view
@property (nullable, weak, nonatomic) MVMCoreUITopAlertView *topAlertView;

View File

@ -23,7 +23,7 @@
#import "MVMCoreUIConstants.h"
#import "MVMCoreUICommonViewsUtility.h"
#import "MVMCoreUITopAlertView.h"
#import "MVMCoreUINavigationControllerViewController.h"
#import "MVMCoreUINavigationController.h"
@interface MVMCoreUISplitViewController ()
@ -40,7 +40,7 @@
@property (weak, nonatomic, readwrite) UIViewController <MVMCoreUIPanelProtocol> *leftPanel;
@property (weak, nonatomic, readwrite) UIViewController <MVMCoreUIPanelProtocol> *rightPanel;
@property (weak, nonatomic, readwrite) MVMCoreUINavigationControllerViewController *navigationController;
@property (weak, nonatomic, readwrite) MVMCoreUINavigationController *navigationController;
// A view that covers the detail view when the master is out.
@property (weak, nonatomic) IBOutlet UIView *mainViewCoverView;
@ -694,7 +694,7 @@ CGFloat const PanelAnimationDuration = 0.2;
}
// The main view.
MVMCoreUINavigationControllerViewController *navigationController = [MVMCoreUINavigationControllerViewController setupNavigationController];
MVMCoreUINavigationController *navigationController = [MVMCoreUINavigationController setupNavigationController];
self.navigationController = navigationController;
self.automaticallyAdjustsScrollViewInsets = NO;

View File

@ -164,7 +164,7 @@
// If we are not loading from the cache, check if the server has provided an index to start with. (When loading from the cache, we use the requested pagetype and modules to find the tab)
__block NSInteger currentIndex = NSNotFound;
if (!self.loadObject.pageDataFromCache) {
NSNumber *currentIndexNumber = [self.loadObject.pageJSON objectForKey:@"currentTabIndex" ofType:[NSNumber class]];
NSNumber *currentIndexNumber = [self.loadObject.pageJSON optionalNumberForKey:@"currentTabIndex"];
if (currentIndexNumber) {
currentIndex = [currentIndexNumber integerValue];
}

View File

@ -56,7 +56,7 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[];
#import <MVMCoreUI/TopLabelsAndBottomButtonsTableViewController.h>
#pragma mark - Containers
#import <MVMCoreUI/MVMCoreUINavigationControllerViewController.h>
#import <MVMCoreUI/MVMCoreUINavigationController.h>
#import <MVMCoreUI/MVMCoreUIPanelProtocol.h>
#import <MVMCoreUI/MVMCoreUIDetailViewProtocol.h>

View File

@ -24,6 +24,7 @@ public class MVMCoreUIHeaderView: ViewConstrainingView {
headlineLabel.updateView(size)
messageLabel.updateView(size)
separatorView?.updateView(size)
setSpacing()
}
public override func setupView() {
@ -74,6 +75,30 @@ public class MVMCoreUIHeaderView: ViewConstrainingView {
}
}
public func setSpacing() {
if headlineLabel.hasText() && messageLabel.hasText() {
spaceBetweenLabels?.constant = PaddingTwo
show()
} else if headlineLabel.hasText() || messageLabel.hasText() {
spaceBetweenLabels?.constant = 0
show()
} else {
hide()
}
}
public override func show() {
super.show()
heightConstraint?.isActive = false
layoutIfNeeded()
}
public override func hide() {
super.hide()
heightConstraint?.isActive = true
layoutIfNeeded()
}
public override func setLeftPinConstant(_ constant: CGFloat) {
leftConstraintTitle?.constant = constant
leftConstraintMessage?.constant = constant
@ -88,10 +113,7 @@ public class MVMCoreUIHeaderView: ViewConstrainingView {
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) {
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
headlineLabel.text = json?.optionalStringForKey(KeyTitle)
messageLabel.text = json?.optionalStringForKey(KeyMessage)
separatorView?.isHidden = !(json?.boolForKey("showSeparator") ?? false)
if let colorString = json?.optionalStringForKey("backgroundColor") {
if let colorString = json?.optionalStringForKey(KeyBackgroundColor) {
backgroundColor = .mfGet(forHex: colorString)
}
if let colorString = json?.optionalStringForKey("contentColor") {
@ -101,6 +123,13 @@ public class MVMCoreUIHeaderView: ViewConstrainingView {
separatorView?.backgroundColor = color
}
let headlineJSON = json?.optionalDictionaryForKey("headline")
headlineLabel.setWithJSON(headlineJSON, delegate: delegate, additionalData: additionalData)
let bodyJSON = json?.optionalDictionaryForKey("body")
messageLabel.setWithJSON(bodyJSON, delegate: delegate, additionalData: additionalData)
let separatorJSON = json?.optionalDictionaryForKey("separator")
separatorView?.setWithJSON(separatorJSON, delegate: delegate, additionalData: additionalData)
if separatorView?.isHidden ?? true {
bottomPin?.constant = 0
} else {

View File

@ -12,6 +12,10 @@ public class MVMCoreUIMoleculeStackView: MFView {
var spacingBlock: ((Any) -> UIEdgeInsets)?
var moleculesArray: [UIView]?
public override init(frame: CGRect) {
super.init(frame: frame)
}
init(withJSON json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) {
super.init(frame: CGRect.zero)
setWithJSON(json, delegate: delegate, additionalData: additionalData)

View File

@ -11,7 +11,7 @@
@class MVMCoreUITopAlertView;
@class MVMCoreUISplitViewController;
@class MFViewController;
@class MVMCoreUINavigationControllerViewController;
@class MVMCoreUINavigationController;
@class MFLoadingViewController;
NS_ASSUME_NONNULL_BEGIN
@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (weak, nonatomic, nullable) MVMCoreUITopAlertView *topAlertView;
@property (weak, nonatomic, nullable) MVMCoreUISplitViewController *splitViewController;
@property (weak, nonatomic, nullable) MVMCoreUINavigationControllerViewController *navigationController;
@property (weak, nonatomic, nullable) MVMCoreUINavigationController *navigationController;
@property (weak, nonatomic, nullable) MFLoadingViewController *loadingViewController;
// for handscroll Animation on subclasses of MFScrollingViewController

View File

@ -11,7 +11,7 @@ import UIKit
public class MoleculeStackTemplate: ThreeLayerViewController {
public override func spaceBetweenMiddleAndBottom() -> CGFloat? {
public override func spaceBetweenTopAndMiddle() -> CGFloat? {
return PaddingTwo
}

View File

@ -193,6 +193,7 @@
PrimaryButton *button = [PrimaryButton primaryWhiteButton:YES];
button.bordered = YES;
[button setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
[button setContentHuggingPriority:800 forAxis:UILayoutConstraintAxisHorizontal];
button.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:button];

View File

@ -31,6 +31,9 @@
// Returns the top alert view
+ (nullable instancetype)sharedGlobal;
// Returns a TopAlertView with the mvm styling. Also sets the property in the session.
+ (nullable instancetype)setupTopAlertView;
// Pins the status bar view at the top of the passed in view controller.
- (void)pinATopViewController:(nonnull UIViewController *)viewController;

View File

@ -54,6 +54,13 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed.";
return [MVMCoreUISession sharedGlobal].topAlertView;
}
+ (nullable instancetype)setupTopAlertView {
MVMCoreUITopAlertView *topAlertView = [[self alloc] init];
topAlertView.translatesAutoresizingMaskIntoConstraints = NO;
[MVMCoreUISession sharedGlobal].topAlertView = topAlertView;
return topAlertView;
}
- (void)setupView {
[super setupView];
if (!self.statusBarView) {

View File

@ -15,5 +15,6 @@
+ (nullable UIFont *)mfFont75Bd:(CGFloat)size;
+ (nullable UIFont *)mfFont55Rg:(CGFloat)size;
+ (nullable UIFont *)mfFontOcratxt:(CGFloat)size;
+ (nullable UIFont *)mfFontWithName:(nonnull NSString *)name size:(CGFloat)size;
@end

View File

@ -13,6 +13,15 @@
@implementation MFFonts
+ (void)loadMVMFonts {
static dispatch_once_t once;
dispatch_once(&once, ^{
[MFFonts loadFont:@"NHaasGroteskDSStd-75Bd" type:@"otf"];
[MFFonts loadFont:@"NHaasGroteskDSStd-55Rg" type:@"otf"];
[MFFonts loadFont:@"OCRAExtended" type:@"ttf"];
});
}
+ (void)loadFont:(NSString *)fontName type:(NSString *)type{
NSString *fontPath = [[MVMCoreUIUtility bundleForMVMCoreUI] pathForResource:fontName ofType:type];
@ -31,30 +40,22 @@
}
+ (nullable UIFont *)mfFont75Bd:(CGFloat)size {
NSString *fontName = @"NHaasGroteskDSStd-75Bd";
static dispatch_once_t once;
dispatch_once(&once, ^{
[MFFonts loadFont:fontName type:@"otf"];
});
return [UIFont fontWithName:fontName size:size];
[self loadMVMFonts];
return [UIFont fontWithName:@"NHaasGroteskDSStd-75Bd" size:size];
}
+ (nullable UIFont *)mfFont55Rg:(CGFloat)size {
NSString *fontName = @"NHaasGroteskDSStd-55Rg";
static dispatch_once_t once;
dispatch_once(&once, ^{
[MFFonts loadFont:fontName type:@"otf"];
});
return [UIFont fontWithName:fontName size:size];
[self loadMVMFonts];
return [UIFont fontWithName:@"NHaasGroteskDSStd-55Rg" size:size];
}
+ (nullable UIFont *)mfFontOcratxt:(CGFloat)size {
NSString *fontName = @"OCRAExtended";
static dispatch_once_t once;
dispatch_once(&once, ^{
[MFFonts loadFont:fontName type:@"ttf"];
});
return [UIFont fontWithName:fontName size:size];
[self loadMVMFonts];
return [UIFont fontWithName:@"OCRAExtended" size:size];
}
+ (nullable UIFont *)mfFontWithName:(nonnull NSString *)name size:(CGFloat)size {
return [UIFont fontWithName:name size:size] ?: [self mfFont55Rg:size];
}
@end

View File

@ -28,6 +28,10 @@ extern NSString * const KeySecondaryButton;
extern NSString * const KeyTitlePrefix;
extern NSString * const KeyTitlePostfix;
extern NSString * const KeyBackgroundColor;
extern NSString * const KeyText;
extern NSString * const KeyTextColor;
#pragma mark - Values
extern NSString * const StringY;

View File

@ -27,6 +27,10 @@ NSString * const KeySecondaryButton = @"SecondaryButton";
NSString * const KeyTitlePrefix = @"titlePrefix";
NSString * const KeyTitlePostfix = @"titlePostfix";
NSString * const KeyBackgroundColor = @"backgroundColor";
NSString * const KeyText = @"text";
NSString * const KeyTextColor = @"textColor";
#pragma mark - Values
NSString * const StringY = @"Y";