UNPKG

1.46 kBPlain TextView Raw
1// Copyright 2016-present 650 Industries. All rights reserved.
2#import <EXAdsFacebook/EXAdOptionsViewManager.h>
3#import <UMCore/UMUtilities.h>
4#import <UMCore/UMUIManager.h>
5#import <EXAdsFacebook/EXNativeAdView.h>
6
7@interface EXAdOptionsViewManager ()
8
9@property (nonatomic, weak) UMModuleRegistry *moduleRegistry;
10
11@end
12
13@implementation EXAdOptionsViewManager
14
15UM_EXPORT_MODULE(AdOptionsViewManager)
16
17- (NSString *)viewName
18{
19 return @"AdOptionsView";
20}
21
22- (UIView *)view
23{
24 return [[FBAdOptionsView alloc] init];
25}
26
27- (void)setModuleRegistry:(UMModuleRegistry *)moduleRegistry
28{
29 _moduleRegistry = moduleRegistry;
30}
31
32UM_VIEW_PROPERTY(nativeAdViewTag, NSNumber *, FBAdOptionsView)
33{
34 id<UMUIManager> uiManager = [_moduleRegistry getModuleImplementingProtocol:@protocol(UMUIManager)];
35 [uiManager addUIBlock:^(EXNativeAdView *view) {
36 [view setNativeAd:view.nativeAd];
37 } forView:value ofClass:[EXNativeAdView class]];
38}
39
40UM_VIEW_PROPERTY(iconColor, NSString *, FBAdOptionsView)
41{
42 view.foregroundColor = [EXAdOptionsViewManager colorFromHexString:value];
43}
44
45+ (UIColor *)colorFromHexString:(NSString *)hexString {
46 unsigned rgbValue = 0;
47 NSScanner *scanner = [NSScanner scannerWithString:hexString];
48 [scanner setScanLocation:1]; // bypass '#' character
49 [scanner scanHexInt:&rgbValue];
50 return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
51}
52
53@end