attempt to standardize json for top labels

This commit is contained in:
Pfeil, Scott Robert 2019-01-25 12:56:29 -05:00
parent a5727bcb5f
commit d0f0736360
8 changed files with 57 additions and 46 deletions

View File

@ -74,4 +74,7 @@
- (void)styleB1:(BOOL)scale;
- (void)styleTableRow:(BOOL)scale;
// Without color
- (void)setFontH1:(BOOL)scale;
@end

View File

@ -308,6 +308,11 @@
[self setScale:scale];
}
- (void)setFontH1:(BOOL)scale {
self.font = [MFStyler fontH1:NO];
[self setScale:scale];
}
- (void)setAccessibilityTraits:(UIAccessibilityTraits)accessibilityTraits {
if (accessibilityTraits& UIAccessibilityTraitHeader) {

View File

@ -37,19 +37,6 @@
@implementation TopLabelsAndBottomButtonsTableViewController
- (void)backButtonPressed {
[super backButtonPressed];
//[self tryToCleanUpMemory];
}
- (void)tryToCleanUpMemory {
//[self.footerView removeFromSuperview];
//self.footerView = nil;
//self.footerAccessoryView = nil;
//self.bottomView = nil;
}
- (void)initialLoad {
[super initialLoad];
self.rebuildUIOnSizeChange = YES;
@ -156,9 +143,11 @@
[self.tableView reloadData];
}
-(void)setHeadlineAndMessage {
[self.topLabelsView setHeadlineString:[[self mapForTopLabels] stringForKey:KeyTitle] messageString:[[self mapForTopLabels] stringForKey:KeyMessage]];
- (void)setHeadlineAndMessage {
[self.topLabelsView setWtihJSON:[self mapForTopLabels]];
}
- (void)updateViewConstraints {
[super updateViewConstraints];
@ -217,10 +206,6 @@
}
}
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)setUpHeaderAccessoryView {
UIView *headerAccessoryView = [[UIView alloc] initWithFrame:CGRectZero];
headerAccessoryView.translatesAutoresizingMaskIntoConstraints = NO;

View File

@ -113,6 +113,7 @@
self.topLabelsView = topLabelsView;
topView = topLabelsView;
self.topView = topView;
[topLabelsView setWtihJSON:[self mapForTopLabels]];
}
[self.contentView addSubview:topView];
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView)]];
@ -263,11 +264,6 @@
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topBetweenEdgeView]-0-[spacer]-0-[bottomBetweenEdgeView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topBetweenEdgeView,spacer,bottomBetweenEdgeView)]];
}
if (self.topLabelsView) {
[self.topLabelsView setHeadlineString:[[self mapForTopLabels] stringForKey:KeyTitle] messageString:[[self mapForTopLabels] stringForKey:KeyMessage]];
}
}
- (void)updateViewConstraints {

View File

@ -50,4 +50,7 @@
- (void)setLeftConstant:(CGFloat)leftConstant;
- (void)setRightConstant:(CGFloat)rightConstant;
// Sets up the ui based on the json
- (void)setWtihJSON:(nullable NSDictionary *)json;
@end

View File

@ -14,6 +14,7 @@
#import <MVMCoreUI/MFStyler.h>
#import <MVMCore/MVMCoreConstants.h>
#import <MVMCoreUI/NSLayoutConstraint+MFConvenience.h>
#import <MVMCoreUI/UIColor+MFConvenience.h>
@interface TopLabelsView ()
@ -30,8 +31,6 @@
@implementation TopLabelsView
- (nullable instancetype)initWithTableView:(nullable TopLabelsAndBottomButtonsTableViewController *)tableView {
if (self = [super init]) {
self.tableView = tableView;
@ -216,5 +215,31 @@
self.rightConstraintSeparator.constant = rightConstant;
}
- (void)setWtihJSON:(nullable NSDictionary *)json {
[self setHeadlineString:[json stringForKey:KeyTitle] messageString:[json stringForKey:KeyMessage]];
UIColor *textColor = [self colorForTopLabelsWithJSON:json];
self.headlineLabel.textColor = textColor;
self.messageLabel.textColor = textColor;
self.backgroundColor = [self colorForBackgroundWithJSON:json];
self.separatorView.hidden = ![json boolForKey:@"showBottomLine"];
}
- (nonnull UIColor *)colorForTopLabelsWithJSON:(nullable NSDictionary *)json {
NSString *titleColor = [json string:@"titleBgColor"];
if (titleColor) {
return [UIColor mfGetColorForHex:titleColor];
} else {
return [UIColor blackColor];
}
}
- (nonnull UIColor *)colorForBackgroundWithJSON:(nullable NSDictionary *)json {
NSString *color = [json string:@"backgroundColor"];
if (color) {
return [UIColor mfGetColorForHex:color];
} else {
return [UIColor clearColor];
}
}
@end

View File

@ -8,10 +8,22 @@
#import <UIKit/UIKit.h>
#import <MVMCoreUI/TopLabelsAndBottomButtonsViewController.h>
@class LabelView;
@class LabelWithInternalButton;
NS_ASSUME_NONNULL_BEGIN
@interface MVMCoreUILargeHeaderSingleLabelTemplate : TopLabelsAndBottomButtonsViewController
// A label that can go below the top labels. Can be a normal label or one with internal buttons.
@property (nullable, weak, nonatomic) LabelView *labelViewUnderTopLabels;
@property (nullable, weak, nonatomic) LabelWithInternalButton *labelUnderTopLabelsWithInternalButton;
// Override to specifiy the label under top label. Default uses the value for key "description" in the page json.
- (nullable NSString *)stringForLabelUnderTopLabels;
// Override to specifiy the label under top label with internal button. Default uses the value for key "Link" in the "ButtonMap" of the page json.
- (nullable NSDictionary *)actionMapForLabelUnderTopLabelsWithInternalButton;
@end
NS_ASSUME_NONNULL_END

View File

@ -13,19 +13,13 @@
@interface MVMCoreUILargeHeaderSingleLabelTemplate ()
// A label that can go below the top labels. Can be a normal label or one with internal buttons.
@property (nullable, weak, nonatomic) LabelView *labelViewUnderTopLabels;
@property (nullable, weak, nonatomic) LabelWithInternalButton *labelUnderTopLabelsWithInternalButton;
@end
@implementation MVMCoreUILargeHeaderSingleLabelTemplate
- (void)newDataBuildScreen {
[super newDataBuildScreen];
[self.topLabelsView.headlineLabel styleH1:YES];
self.topLabelsView.separatorView.hidden = YES;
[self updateTopLabelsColor];
[self.topLabelsView.headlineLabel setFontH1:YES];
}
- (void)initialLoad {
@ -81,18 +75,6 @@
// Dispose of any resources that can be recreated.
}
#pragma mark - Top labels style
- (void)updateTopLabelsColor {
self.topLabelsView.headlineLabel.textColor = [UIColor blackColor];
self.topLabelsView.messageLabel.textColor = [UIColor blackColor];
NSString *titleColor = [[self mapForTopLabels] string:@"titleBgColor"];
if (titleColor) {
self.topLabelsView.headlineLabel.textColor = [UIColor mfGetColorForHex:titleColor];
self.topLabelsView.messageLabel.textColor = [UIColor mfGetColorForHex:titleColor];
}
}
- (UIEdgeInsets)paddingForTopLabels {
UIEdgeInsets edge = [super paddingForTopLabels];
edge.bottom = PaddingTwo;