summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLLockScreenConfiguration.m
blob: 4f82c287aaf34f0263792f6e9bcc93e722fc75d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
//  SDLLockScreenConfiguration.m
//  SmartDeviceLink-iOS
//
//  Created by Joel Fischer on 10/13/15.
//  Copyright © 2015 smartdevicelink. All rights reserved.
//

#import "SDLLockScreenConfiguration.h"


NS_ASSUME_NONNULL_BEGIN

@interface SDLLockScreenConfiguration ()

@end


@implementation SDLLockScreenConfiguration

#pragma mark - Lifecycle

- (instancetype)initWithAutoLockScreen:(BOOL)enableAutomatic enableInOptional:(BOOL)enableOptional backgroundColor:(UIColor *)backgroundColor appIcon:(nullable UIImage *)appIcon viewController:(nullable UIViewController *)customViewController {
    self = [super init];
    if (!self) {
        return nil;
    }

    _enableAutomaticLockScreen = enableAutomatic;
    _showInOptionalState = enableOptional;
    _backgroundColor = backgroundColor;
    _appIcon = appIcon;
    _customViewController = customViewController;

    return self;
}

+ (instancetype)disabledConfiguration {
    return [[self alloc] initWithAutoLockScreen:NO enableInOptional:NO backgroundColor:[self sdl_defaultBackgroundColor] appIcon:nil viewController:nil];
}

+ (instancetype)enabledConfiguration {
    return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO backgroundColor:[self sdl_defaultBackgroundColor] appIcon:nil viewController:nil];
}

+ (instancetype)enabledConfigurationWithAppIcon:(UIImage *)lockScreenAppIcon backgroundColor:(nullable UIColor *)lockScreenBackgroundColor {
    if (lockScreenBackgroundColor == nil) {
        lockScreenBackgroundColor = [self.class sdl_defaultBackgroundColor];
    }

    return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO backgroundColor:lockScreenBackgroundColor appIcon:lockScreenAppIcon viewController:nil];
}

+ (instancetype)enabledConfigurationWithViewController:(UIViewController *)viewController {
    return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO backgroundColor:[self.class sdl_defaultBackgroundColor] appIcon:nil viewController:viewController];
}


#pragma mark - Defaults

+ (UIColor *)sdl_defaultBackgroundColor {
    return [UIColor colorWithRed:(57.0 / 255.0) green:(78.0 / 255.0) blue:(96.0 / 255.0) alpha:1.0];
}


#pragma mark - NSCopying

- (id)copyWithZone:(nullable NSZone *)zone {
    SDLLockScreenConfiguration *new = [[SDLLockScreenConfiguration allocWithZone:zone] initWithAutoLockScreen : _enableAutomaticLockScreen
                                           enableInOptional : _showInOptionalState
                                               backgroundColor : _backgroundColor
                                                   appIcon : _appIcon
                                                       viewController : _customViewController];

    return new;
}

@end

NS_ASSUME_NONNULL_END