summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLWindowCapability+ScreenManagerExtensions.m
blob: 441356a838b4f283a76b28ec6f3a5e2e87793692 (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
//
//  SDLWindowCapability+ShowManagerExtensions.m
//  SmartDeviceLink
//
//  Created by Joel Fischer on 2/28/18.
//  Updated by Kujtim Shala (Ford) on 13.09.19.
//    - Renamed and adapted for WindowCapability
//  Copyright © 2019 smartdevicelink. All rights reserved.
//

#import "SDLWindowCapability+ScreenManagerExtensions.h"
#import "SDLImageField.h"
#import "SDLTextField.h"

@implementation SDLWindowCapability (ScreenManagerExtensions)

- (BOOL)hasTextFieldOfName:(SDLTextFieldName)name {
    for (SDLTextField *textField in self.textFields) {
        if ([textField.name isEqualToString:name]) {
            return YES;
        }
    }

    return NO;
}

- (NSUInteger)maxNumberOfMainFieldLines {
    NSInteger highestFound = 0;
    for (SDLTextField *textField in self.textFields) {
        if (![textField.name isKindOfClass:[NSString class]]) { continue; }
        if ([textField.name isEqualToString:SDLTextFieldNameMainField1]
            || [textField.name isEqualToString:SDLTextFieldNameMainField2]
            || [textField.name isEqualToString:SDLTextFieldNameMainField3]
            || [textField.name isEqualToString:SDLTextFieldNameMainField4]) {
            NSInteger fieldNumber = [[textField.name substringFromIndex:(textField.name.length - 1)] integerValue];
            highestFound = (highestFound < fieldNumber) ? fieldNumber : highestFound;

            if (highestFound == 4) { break; }
        }
    }

    return (NSUInteger)highestFound;
}

- (BOOL)hasImageFieldOfName:(SDLImageFieldName)name {
    for (SDLImageField *imageField in self.imageFields) {
        if ([imageField.name isEqualToString:name]) {
            return YES;
        }
    }

    return NO;
}

@end