Add object detection, tracking, mobile notifications, and search to any security camera.
add live tab
roryclear045dcc5e81e6
diff --git a/clearcam/GalleryViewController.m b/clearcam/GalleryViewController.mindex 46b9a33..8b141fc 100644--- a/clearcam/GalleryViewController.m+++ b/clearcam/GalleryViewController.m@@ -64,7 +64,50 @@@end+// New Live tab view controller+@interface LiveViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>+@property (nonatomic, strong) UITableView *tableView;+@end++@implementation LiveViewController++- (void)viewDidLoad {+ [super viewDidLoad];+ self.title = @"Live";+ [self setupTableView];+}++- (void)setupTableView {+ self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];+ self.tableView.delegate = self;+ self.tableView.dataSource = self;+ self.tableView.backgroundColor = [UIColor systemBackgroundColor];+ [self.view addSubview:self.tableView];++ self.tableView.translatesAutoresizingMaskIntoConstraints = NO;+ [NSLayoutConstraint activateConstraints:@[+ [self.tableView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor],+ [self.tableView.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor],+ [self.tableView.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor],+ [self.tableView.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor]+ ]];+}++- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {+ return 0; // Empty for now+}++- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {+ return [UITableViewCell new]; // Empty for now+}++@end++// Modified GalleryViewController with tabs@interface GalleryViewController () <UITableViewDelegate, UITableViewDataSource>+@property (nonatomic, strong) UITabBarController *tabController;+@property (nonatomic, strong) UIViewController *eventsViewController;+@property (nonatomic, strong) LiveViewController *liveViewController;@property (nonatomic, strong) UITableView *tableView;@property (nonatomic, strong) NSMutableArray<NSString *> *videoFiles;@property (nonatomic, strong) NSString *downloadDirectory;@@ -81,9 +124,26 @@- (void)viewDidLoad {[super viewDidLoad];self.view.backgroundColor = [UIColor systemBackgroundColor];- self.title = @"Events";self.navigationController.navigationBarHidden = NO;+ // Initialize view controllers for tabs+ self.eventsViewController = [[UIViewController alloc] init];+ self.eventsViewController.title = @"Events";++ self.liveViewController = [[LiveViewController alloc] init];+ self.liveViewController.title = @"Live";++ // Set up tab bar controller+ self.tabController = [[UITabBarController alloc] init];+ self.tabController.viewControllers = @[self.eventsViewController, self.liveViewController];+ [self addChildViewController:self.tabController];+ [self.view addSubview:self.tabController.view];+ self.tabController.view.frame = self.view.bounds;+ [self.tabController didMoveToParentViewController:self];++ // Move all the existing events UI to the eventsViewController+ [self setupEventsViewController];+self.videoFiles = [NSMutableArray array];self.groupedVideos = [NSMutableDictionary dictionary];self.sectionTitles = [NSMutableArray array];@@ -95,12 +155,43 @@self.downloadSession = [NSURLSession sessionWithConfiguration:config];self.loadedFilenames = [NSMutableSet set];[self setupDownloadDirectory];- [self setupTableView];- [self setupRefreshControl];[self loadExistingVideos];[self getEvents];}+- (void)setupEventsViewController {+ // Move all the existing table view setup to the events view controller+ self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];+ self.tableView.delegate = self;+ self.tableView.dataSource = self;+ self.tableView.backgroundColor = [UIColor systemBackgroundColor];+ [self.tableView registerClass:[VideoTableViewCell class] forCellReuseIdentifier:@"VideoCell"];+ self.tableView.separatorInset = UIEdgeInsetsMake(0, 16, 0, 16);++ if (@available(iOS 11.0, *)) {+ self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;+ }++ [self.eventsViewController.view addSubview:self.tableView];++ self.tableView.translatesAutoresizingMaskIntoConstraints = NO;+ [NSLayoutConstraint activateConstraints:@[+ [self.tableView.topAnchor constraintEqualToAnchor:self.eventsViewController.view.safeAreaLayoutGuide.topAnchor constant:0],+ [self.tableView.leadingAnchor constraintEqualToAnchor:self.eventsViewController.view.safeAreaLayoutGuide.leadingAnchor constant:0],+ [self.tableView.trailingAnchor constraintEqualToAnchor:self.eventsViewController.view.safeAreaLayoutGuide.trailingAnchor constant:0],+ [self.tableView.bottomAnchor constraintEqualToAnchor:self.eventsViewController.view.safeAreaLayoutGuide.bottomAnchor constant:0]+ ]];++ // Setup refresh control for events+ self.refreshControl = [[UIRefreshControl alloc] init];+ [self.refreshControl addTarget:self action:@selector(handleRefresh) forControlEvents:UIControlEventValueChanged];+ if (@available(iOS 10.0, *)) {+ self.tableView.refreshControl = self.refreshControl;+ } else {+ [self.tableView addSubview:self.refreshControl];+ }+}+- (void)setupRefreshControl {self.refreshControl = [[UIRefreshControl alloc] init];[self.refreshControl addTarget:self action:@selector(handleRefresh) forControlEvents:UIControlEventValueChanged];@@ -691,4 +782,3 @@}@end-