Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

add back premium button

roryclear94745fced902
diff --git a/clearcam/SettingsViewController.m b/clearcam/SettingsViewController.m
index e0e286e..96cc9a2 100644
--- a/clearcam/SettingsViewController.m
+++ b/clearcam/SettingsViewController.m
@@ -11,6 +11,7 @@
@property (nonatomic, assign) BOOL isPresetsSectionExpanded; // Track if presets section is expanded
@property (nonatomic, assign) BOOL sendEmailAlertsEnabled;
@property (nonatomic, assign) BOOL encryptEmailDataEnabled;
+@property (nonatomic, assign) BOOL isPaid; // Tracks whether the user has "upgraded"
@end
@@ -22,6 +23,7 @@
// Basic setup
self.view.backgroundColor = [UIColor systemBackgroundColor];
self.title = @"Settings";
+ self.isPaid = NO; // Default to non-premium state
// Initialize selectedResolution and selectedPresetKey based on SettingsManager
SettingsManager *settingsManager = [SettingsManager sharedManager];
@@ -81,7 +83,7 @@
#pragma mark - UITableView DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 2; // One for general settings, one for presets
+ return 3; // One for general settings, one for presets, one for upgrade to premium
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
@@ -91,6 +93,8 @@
// Presets section: 1 row for "Manage Presets" header, plus rows for each preset, plus "Add New +"
NSArray *presetKeys = [[[NSUserDefaults standardUserDefaults] objectForKey:@"yolo_presets"] allKeys];
return self.isPresetsSectionExpanded ? (presetKeys.count + 2) : 1;
+ } else if (section == 2) {
+ return self.isPaid ? 0 : 1; // Show "Upgrade to Premium" button only if not premium
}
return 0;
}
@@ -131,6 +135,17 @@
cell.textLabel.text = @"Email Address";
NSString *email = [[NSUserDefaults standardUserDefaults] stringForKey:@"user_email"];
cell.detailTextLabel.text = email ?: @"Not set"; // Show current email or "Not set"
+
+ // Disable if not premium
+ if (!self.isPaid) {
+ cell.textLabel.textColor = [UIColor grayColor];
+ cell.detailTextLabel.textColor = [UIColor grayColor];
+ cell.userInteractionEnabled = NO;
+ } else {
+ cell.textLabel.textColor = [UIColor labelColor];
+ cell.detailTextLabel.textColor = [UIColor secondaryLabelColor];
+ cell.userInteractionEnabled = YES;
+ }
} else if (indexPath.row == 3) {
// Send Email Alerts
cell.textLabel.text = @"Send Email Alerts";
@@ -141,6 +156,17 @@
emailAlertsSwitch.on = self.sendEmailAlertsEnabled;
[emailAlertsSwitch addTarget:self action:@selector(emailAlertsSwitchToggled:) forControlEvents:UIControlEventValueChanged];
cell.accessoryView = emailAlertsSwitch;
+
+ // Disable if not premium
+ if (!self.isPaid) {
+ emailAlertsSwitch.enabled = NO;
+ cell.textLabel.textColor = [UIColor grayColor];
+ cell.userInteractionEnabled = NO;
+ } else {
+ emailAlertsSwitch.enabled = YES;
+ cell.textLabel.textColor = [UIColor labelColor];
+ cell.userInteractionEnabled = YES;
+ }
} else if (indexPath.row == 4) {
// Encrypt Email Data
cell.textLabel.text = @"Encrypt Email Data (Recommended)";
@@ -151,6 +177,17 @@
encryptEmailDataSwitch.on = self.encryptEmailDataEnabled;
[encryptEmailDataSwitch addTarget:self action:@selector(encryptEmailDataSwitchToggled:) forControlEvents:UIControlEventValueChanged];
cell.accessoryView = encryptEmailDataSwitch;
+
+ // Disable if not premium
+ if (!self.isPaid) {
+ encryptEmailDataSwitch.enabled = NO;
+ cell.textLabel.textColor = [UIColor grayColor];
+ cell.userInteractionEnabled = NO;
+ } else {
+ encryptEmailDataSwitch.enabled = YES;
+ cell.textLabel.textColor = [UIColor labelColor];
+ cell.userInteractionEnabled = YES;
+ }
}
} else if (indexPath.section == 1) {
// Presets section (unchanged)
@@ -174,11 +211,53 @@
cell.imageView.tintColor = [UIColor systemGreenColor]; // Set the icon color to green
cell.accessoryType = UITableViewCellAccessoryNone;
}
+ } else if (indexPath.section == 2) {
+ // Upgrade to Premium section
+ cell.textLabel.text = @"Upgrade to Premium";
+ cell.textLabel.textColor = [UIColor systemBlueColor];
+ cell.textLabel.textAlignment = NSTextAlignmentCenter;
+ cell.accessoryType = UITableViewCellAccessoryNone;
}
return cell;
}
+#pragma mark - UITableView Delegate
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+ if (indexPath.section == 0) {
+ if (indexPath.row == 0) {
+ [self showResolutionPicker];
+ } else if (indexPath.row == 1) {
+ [self showYoloIndexesPicker];
+ } else if (indexPath.row == 2 && self.isPaid) { // Only allow interaction if premium
+ [self showEmailInputDialog];
+ }
+ // Ignore taps on the "Send Email Alerts" row (indexPath.row == 3) and "Encrypt Email Data" row (indexPath.row == 4)
+ } else if (indexPath.section == 1) {
+ NSArray *presetKeys = [[[NSUserDefaults standardUserDefaults] objectForKey:@"yolo_presets"] allKeys];
+ if (indexPath.row == 0) {
+ // Toggle presets section expansion
+ self.isPresetsSectionExpanded = !self.isPresetsSectionExpanded;
+ [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationAutomatic];
+ } else if (indexPath.row <= presetKeys.count) {
+ // Edit preset
+ NSString *presetKey = presetKeys[indexPath.row - 1];
+ NSArray *selectedIndexes = [[NSUserDefaults standardUserDefaults] objectForKey:@"yolo_presets"][presetKey];
+ [self showNumberSelectionForPreset:presetKey selectedIndexes:selectedIndexes];
+ } else {
+ // Add new preset
+ [self showAddPresetDialog];
+ }
+ } else if (indexPath.section == 2) {
+ // Upgrade to Premium button tapped
+ self.isPaid = YES; // Simulate the upgrade (no actual purchase logic for now)
+ [self.tableView reloadData]; // Reload the table view to update UI (hide "Upgrade to Premium" and enable email settings)
+ }
+
+ [tableView deselectRowAtIndexPath:indexPath animated:YES];
+}
+
- (void)encryptEmailDataSwitchToggled:(UISwitch *)sender {
if (sender.on) {
// Check if a password already exists in the secrets manager
@@ -397,36 +476,6 @@
#pragma mark - UITableView Delegate
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.section == 0) {
- if (indexPath.row == 0) {
- [self showResolutionPicker];
- } else if (indexPath.row == 1) {
- [self showYoloIndexesPicker];
- } else if (indexPath.row == 2) {
- [self showEmailInputDialog];
- }
- // Ignore taps on the "Send Email Alerts" row (indexPath.row == 3)
- } else if (indexPath.section == 1) {
- NSArray *presetKeys = [[[NSUserDefaults standardUserDefaults] objectForKey:@"yolo_presets"] allKeys];
- if (indexPath.row == 0) {
- // Toggle presets section expansion
- self.isPresetsSectionExpanded = !self.isPresetsSectionExpanded;
- [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationAutomatic];
- } else if (indexPath.row <= presetKeys.count) {
- // Edit preset
- NSString *presetKey = presetKeys[indexPath.row - 1];
- NSArray *selectedIndexes = [[NSUserDefaults standardUserDefaults] objectForKey:@"yolo_presets"][presetKey];
- [self showNumberSelectionForPreset:presetKey selectedIndexes:selectedIndexes];
- } else {
- // Add new preset
- [self showAddPresetDialog];
- }
- }
-
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
-}
-
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 1 && indexPath.row > 0 && indexPath.row <= [[[NSUserDefaults standardUserDefaults] objectForKey:@"yolo_presets"] allKeys].count) {
NSString *presetKey = [[[NSUserDefaults standardUserDefaults] objectForKey:@"yolo_presets"] allKeys][indexPath.row - 1];