session-ios/Session/Signal/NotificationSettingsOptions...

70 lines
2.6 KiB
Mathematica
Raw Normal View History

//
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "NotificationSettingsOptionsViewController.h"
2019-05-02 23:58:48 +02:00
#import "Session-Swift.h"
#import "SignalApp.h"
2020-11-26 00:37:56 +01:00
#import <SessionMessagingKit/Environment.h>
2020-11-11 07:45:50 +01:00
#import <SignalUtilitiesKit/SignalUtilitiesKit-Swift.h>
@implementation NotificationSettingsOptionsViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self updateTableContents];
2020-08-27 07:06:11 +02:00
2020-08-27 07:10:28 +02:00
[LKViewControllerUtilities setUpDefaultSessionStyleForVC:self withTitle:NSLocalizedString(@"Content", @"") customBackButton:NO];
self.tableView.backgroundColor = UIColor.clearColor;
}
#pragma mark - Table Contents
- (void)updateTableContents
{
OWSTableContents *contents = [OWSTableContents new];
__weak NotificationSettingsOptionsViewController *weakSelf = self;
OWSTableSection *section = [OWSTableSection new];
2019-06-14 07:25:39 +02:00
// section.footerTitle = NSLocalizedString(@"NOTIFICATIONS_FOOTER_WARNING", nil);
2018-08-31 19:44:13 +02:00
OWSPreferences *prefs = Environment.shared.preferences;
NotificationType selectedNotifType = [prefs notificationPreviewType];
for (NSNumber *option in
@[ @(NotificationNamePreview), @(NotificationNameNoPreview), @(NotificationNoNameNoPreview) ]) {
NotificationType notificationType = (NotificationType)option.intValue;
2018-07-13 00:14:04 +02:00
[section addItem:[OWSTableItem
itemWithCustomCellBlock:^{
UITableViewCell *cell = [OWSTableItem newCell];
cell.tintColor = LKColors.accent;
2018-07-13 00:14:04 +02:00
[[cell textLabel] setText:[prefs nameForNotificationPreviewType:notificationType]];
if (selectedNotifType == notificationType) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
2019-03-21 15:26:38 +01:00
cell.accessibilityIdentifier
= ACCESSIBILITY_IDENTIFIER_WITH_NAME(NotificationSettingsOptionsViewController,
2019-03-21 15:26:38 +01:00
NSStringForNotificationType(notificationType));
2018-07-13 00:14:04 +02:00
return cell;
}
actionBlock:^{
[weakSelf setNotificationType:notificationType];
}]];
}
[contents addSection:section];
self.contents = contents;
}
- (void)setNotificationType:(NotificationType)notificationType
{
2018-08-31 19:44:13 +02:00
[Environment.shared.preferences setNotificationPreviewType:notificationType];
[self.navigationController popViewControllerAnimated:YES];
}
@end