Merge pull request #41 in BPHVB/mvm_core from feature/top_alert_color to develop
* commit '79aaae2ad736126a6e052583e3da53cb5cf0c546': Add background and text color
This commit is contained in:
commit
2bf04f354c
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2016 Verizon Wireless. All rights reserved.
|
// Copyright © 2016 Verizon Wireless. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <UIKit/UIKit.h>
|
||||||
#import <MVMCore/MVMCoreTopAlertDelegateProtocol.h>
|
#import <MVMCore/MVMCoreTopAlertDelegateProtocol.h>
|
||||||
|
|
||||||
extern NSUInteger const TopAlertDismissTime;
|
extern NSUInteger const TopAlertDismissTime;
|
||||||
@ -44,6 +44,10 @@ extern NSUInteger const TopAlertDismissTime;
|
|||||||
// If 0, uses default 5 seconds.
|
// If 0, uses default 5 seconds.
|
||||||
@property (nonatomic) NSInteger topAlertDismissTime;
|
@property (nonatomic) NSInteger topAlertDismissTime;
|
||||||
|
|
||||||
|
// Server can set color.
|
||||||
|
@property (nullable, strong, nonatomic) UIColor *backgroundColor;
|
||||||
|
@property (nullable, strong, nonatomic) UIColor *textColor;
|
||||||
|
|
||||||
- (nullable instancetype)initWithResponseInfo:(nullable NSDictionary *)responseInfo;
|
- (nullable instancetype)initWithResponseInfo:(nullable NSDictionary *)responseInfo;
|
||||||
|
|
||||||
- (nullable instancetype)initWithType:(nullable NSString *)type message:(nullable NSString *)message;
|
- (nullable instancetype)initWithType:(nullable NSString *)type message:(nullable NSString *)message;
|
||||||
|
|||||||
@ -8,9 +8,11 @@
|
|||||||
|
|
||||||
#import "MVMCoreTopAlertObject.h"
|
#import "MVMCoreTopAlertObject.h"
|
||||||
#import <MVMCore/NSDictionary+MFConvenience.h>
|
#import <MVMCore/NSDictionary+MFConvenience.h>
|
||||||
|
#import "MVMCoreGetterUtility.h"
|
||||||
#import "MVMCoreAlertHandler.h"
|
#import "MVMCoreAlertHandler.h"
|
||||||
#import "MVMCoreJSONConstants.h"
|
#import "MVMCoreJSONConstants.h"
|
||||||
|
|
||||||
|
|
||||||
NSUInteger const TopAlertDismissTime = 5;
|
NSUInteger const TopAlertDismissTime = 5;
|
||||||
|
|
||||||
@implementation MVMCoreTopAlertObject
|
@implementation MVMCoreTopAlertObject
|
||||||
@ -27,6 +29,15 @@ NSUInteger const TopAlertDismissTime = 5;
|
|||||||
self.topMessage = [responseInfo string:KeyTopMessage];
|
self.topMessage = [responseInfo string:KeyTopMessage];
|
||||||
self.imageNameOrURL = [responseInfo string:@"topAlertImageUrl"];
|
self.imageNameOrURL = [responseInfo string:@"topAlertImageUrl"];
|
||||||
|
|
||||||
|
NSString *color = [responseInfo string:@"topAlertColor"];
|
||||||
|
if (color) {
|
||||||
|
self.backgroundColor = [MVMCoreGetterUtility getColorForHexString:color];
|
||||||
|
}
|
||||||
|
color = [responseInfo string:@"messageColor"];
|
||||||
|
if (color) {
|
||||||
|
self.textColor = [MVMCoreGetterUtility getColorForHexString:color];
|
||||||
|
}
|
||||||
|
|
||||||
// The default is yes if not sent by server (for legacy to work as is)
|
// The default is yes if not sent by server (for legacy to work as is)
|
||||||
NSNumber *closeButton = [responseInfo objectForKey:KeyCloseButton ofType:[NSNumber class]];
|
NSNumber *closeButton = [responseInfo objectForKey:KeyCloseButton ofType:[NSNumber class]];
|
||||||
if (closeButton) {
|
if (closeButton) {
|
||||||
|
|||||||
@ -21,4 +21,8 @@
|
|||||||
|
|
||||||
// Returns true if the user's language is Spanish
|
// Returns true if the user's language is Spanish
|
||||||
+ (BOOL)userPrefersSpanish;
|
+ (BOOL)userPrefersSpanish;
|
||||||
|
|
||||||
|
// Returns a UIColor
|
||||||
|
+ (nonnull UIColor *)getColorForHexString:(nonnull NSString *)hexString;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -34,5 +34,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (nonnull UIColor *)getColorForHexString:(nonnull NSString *)hexString {
|
||||||
|
unsigned int hexint = 0;
|
||||||
|
|
||||||
|
// Create scanner
|
||||||
|
NSScanner *scanner = [NSScanner scannerWithString:hexString];
|
||||||
|
|
||||||
|
// Tell scanner to skip the # character
|
||||||
|
[scanner setCharactersToBeSkipped:[NSCharacterSet characterSetWithCharactersInString:@"#"]];
|
||||||
|
[scanner scanHexInt:&hexint];
|
||||||
|
|
||||||
|
return [UIColor colorWithRed:((CGFloat) ((hexint & 0xFF0000) >> 16))/255
|
||||||
|
green:((CGFloat) ((hexint & 0xFF00) >> 8))/255
|
||||||
|
blue:((CGFloat) (hexint & 0xFF))/255
|
||||||
|
alpha:1];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user