Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

vipera-npm-registry / de-splashscreen-plugin   js

Repository URL to install this package:

Version: 0.0.4 

/ src / ios / DEDefaultSplashScreen.m

//
//  DESplashScreen.m
//  HelloCordova
//
//  Created by Marco Bonati on 23/02/2017.
//
//

#import <Foundation/Foundation.h>
#import <DEUtility/DEAppPreferencesUtils.h>
#import "DEDefaultSplashScreen.h"
#import "DESplashScreenDefines.h"
#import "UIColor+Hex.h"

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

@interface DEDefaultSplashScreen()
+ (UIColor *)colorFromHexString:(NSString *)hexString;
@end

@implementation DEDefaultSplashScreen

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    [self extraInitialization];
    return self;
}

-(void)dealloc {

    @try {
        [self removeObserver:self forKeyPath:@"frame"];
        [self removeObserver:self forKeyPath:@"bounds"];
    }
    @catch (NSException *exception) {
        // When reloading the page from a remotely connected Safari, there
        // are no observers, so the removeObserver method throws an exception,
        // that we can safely ignore.
        // Alternatively we can check whether there are observers before calling removeObserver
    }

    int stop = 0;
    stop++;
}

- (void)extraInitialization
{
    NSString *imageName = [[DEAppPreferencesUtils sharedInstance] stringPreferenceForKey:DESPLASH_CFG_PARAM_RESOURCE_NAME withDefaultValue:nil];
    
    NSString *colorStr = [[DEAppPreferencesUtils sharedInstance] stringPreferenceForKey:DESPLASH_CFG_PARAM_BKG_COLOR withDefaultValue:@"ffffff"];
    
    if (imageName!=nil){
        UIImage *image = [UIImage imageNamed:imageName];
        self.image = image;
    }
    
    self.backgroundColor = [UIColor colorWithCSS:colorStr];
 
    // Frame is required when launching in portrait mode.
    // Bounds for landscape since it captures the rotation.
    [self addObserver:self forKeyPath:@"frame" options:0 context:nil];
    [self addObserver:self forKeyPath:@"bounds" options:0 context:nil];
    
}

- (void)observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object change:(NSDictionary*)change context:(void*)context
{
    //TODO!! Change image for orientation
}



@end