Skip to content

Commit a8035e2

Browse files
committed
Show an instructional label when there are no tokens
1 parent 1f80ade commit a8035e2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Authenticator/Classes/OTPTokenListViewController.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ @interface OTPTokenListViewController () <OTPTokenEditorDelegate>
3737

3838
@property (nonatomic, strong) OTPTokenManager *tokenManager;
3939
@property (nonatomic, strong) OTPProgressRing *ring;
40+
@property (nonatomic, strong) UILabel *noTokensLabel;
4041
@property (nonatomic, strong) UIBarButtonItem *addButtonItem;
4142

4243
@end
@@ -77,6 +78,22 @@ - (void)viewDidLoad
7778
self.tableView.contentInset = UIEdgeInsetsMake(10, 0, 0, 0);
7879
self.tableView.allowsSelectionDuringEditing = YES;
7980

81+
self.noTokensLabel = [UILabel new];
82+
self.noTokensLabel.numberOfLines = 2;
83+
NSMutableAttributedString *noTokenString = [[NSMutableAttributedString alloc] initWithString:@"No Tokens\n"
84+
attributes:@{NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Light" size:20]}];
85+
[noTokenString appendAttributedString:[[NSAttributedString alloc] initWithString:@"Tap + to add a new token"
86+
attributes:@{NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Light" size:17]}]];
87+
[noTokenString addAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Light" size:25]}
88+
range:[noTokenString.string rangeOfString:@"+"]];
89+
self.noTokensLabel.attributedText = noTokenString;
90+
self.noTokensLabel.textAlignment = NSTextAlignmentCenter;
91+
self.noTokensLabel.textColor = [UIColor otpForegroundColor];
92+
self.noTokensLabel.frame = CGRectMake(0, 0,
93+
self.view.bounds.size.width,
94+
self.view.bounds.size.height * 0.6f);
95+
[self.view addSubview:self.noTokensLabel];
96+
8097
[self update];
8198
}
8299

@@ -92,6 +109,7 @@ - (void)update
92109
}
93110

94111
self.editButtonItem.enabled = !!self.tokenManager.tokens.count;
112+
self.noTokensLabel.hidden = !!self.tokenManager.tokens.count;
95113
}
96114

97115

0 commit comments

Comments
 (0)