Settings: Add show NSFW public rooms toggle.

This commit is contained in:
SBiOSoftWhare
2021-03-03 16:32:05 +01:00
parent d4b1c32140
commit 104f516a7f
4 changed files with 43 additions and 0 deletions
@@ -132,6 +132,7 @@ enum
OTHER_TERM_CONDITIONS_INDEX,
OTHER_PRIVACY_INDEX,
OTHER_THIRD_PARTY_INDEX,
OTHER_SHOW_NSFW_ROOMS_INDEX,
OTHER_CRASH_REPORT_INDEX,
OTHER_ENABLE_RAGESHAKE_INDEX,
OTHER_MARK_ALL_AS_READ_INDEX,
@@ -435,6 +436,8 @@ TableViewSectionsDelegate>
[sectionOther addRowWithTag:OTHER_TERM_CONDITIONS_INDEX];
[sectionOther addRowWithTag:OTHER_PRIVACY_INDEX];
[sectionOther addRowWithTag:OTHER_THIRD_PARTY_INDEX];
[sectionOther addRowWithTag:OTHER_SHOW_NSFW_ROOMS_INDEX];
if (BuildSettings.settingsScreenAllowChangingCrashUsageDataSettings)
{
[sectionOther addRowWithTag:OTHER_CRASH_REPORT_INDEX];
@@ -2104,6 +2107,19 @@ TableViewSectionsDelegate>
cell = thirdPartyCell;
}
else if (row == OTHER_SHOW_NSFW_ROOMS_INDEX)
{
MXKTableViewCellWithLabelAndSwitch* labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
labelAndSwitchCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_show_NSFW_public_rooms", @"Vector", nil);
labelAndSwitchCell.mxkSwitch.on = RiotSettings.shared.showNSFWPublicRooms;
labelAndSwitchCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor;
labelAndSwitchCell.mxkSwitch.enabled = YES;
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleNSFWPublicRoomsFiltering:) forControlEvents:UIControlEventTouchUpInside];
cell = labelAndSwitchCell;
}
else if (row == OTHER_CRASH_REPORT_INDEX)
{
MXKTableViewCellWithLabelAndSwitch* sendCrashReportCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
@@ -3599,6 +3615,18 @@ TableViewSectionsDelegate>
animated:YES];
}
- (void)toggleNSFWPublicRoomsFiltering:(id)sender
{
if (sender && [sender isKindOfClass:UISwitch.class])
{
UISwitch *switchButton = (UISwitch*)sender;
RiotSettings.shared.showNSFWPublicRooms = switchButton.isOn;
[self.tableView reloadData];
}
}
#pragma mark - TextField listener
- (IBAction)textFieldDidChange:(id)sender