Stubbing in notifications table. Now needs notification feed cells.

This commit is contained in:
Samuel Clay 2016-11-23 09:29:29 -08:00
parent 56c03d113a
commit 47a7126c91
12 changed files with 261 additions and 17 deletions

View file

@ -24,6 +24,7 @@
#import "FontSettingsViewController.h"
#import "AddSiteViewController.h"
#import "TrainerViewController.h"
#import "NotificationsViewController.h"
#import "StoriesCollection.h"
#import "UserTagsViewController.h"

View file

@ -137,6 +137,7 @@ SFSafariViewControllerDelegate> {
NSArray * userInteractionsArray;
NSArray * userActivitiesArray;
NSMutableArray * dictFoldersArray;
NSArray * notificationFeedIds;
FMDatabaseQueue *database;
NSOperationQueue *offlineQueue;
@ -247,6 +248,7 @@ SFSafariViewControllerDelegate> {
@property (nonatomic) NSArray *userInteractionsArray;
@property (nonatomic) NSArray *userActivitiesArray;
@property (nonatomic) NSMutableArray *dictFoldersArray;
@property (nonatomic) NSArray *notificationFeedIds;
@property (nonatomic) NSArray *categories;
@property (nonatomic) NSDictionary *categoryFeeds;

View file

@ -164,6 +164,7 @@
@synthesize userInteractionsArray;
@synthesize userActivitiesArray;
@synthesize dictFoldersArray;
@synthesize notificationFeedIds;
@synthesize database;
@synthesize categories;
@ -863,6 +864,7 @@
self.dictSavedStoryFeedCounts = nil;
self.dictFolders = nil;
self.dictFoldersArray = nil;
self.notificationFeedIds = nil;
self.userActivitiesArray = nil;
self.userInteractionsArray = nil;
self.dictUnreadCounts = nil;

View file

@ -2035,17 +2035,23 @@ heightForHeaderInSection:(NSInteger)section {
}
- (void)checkForFeedNotifications {
NSMutableArray *notificationFeedIds = [NSMutableArray array];
for (NSDictionary *feed in appDelegate.dictFeeds.allValues) {
NSArray *types = [feed objectForKey:@"notification_types"];
if (types) {
for (NSString *notificationType in types) {
if ([notificationType isEqualToString:@"ios"]) {
[appDelegate registerForRemoteNotifications];
return;
}
}
if ([types count]) {
[notificationFeedIds addObject:[feed objectForKey:@"id"]];
}
}
}
appDelegate.notificationFeedIds = notificationFeedIds;
}
- (void)refreshHeaderCounts {

View file

@ -0,0 +1,20 @@
//
// NotificationFeedCell.h
// NewsBlur
//
// Created by Samuel Clay on 11/23/16.
// Copyright © 2016 NewsBlur. All rights reserved.
//
#import <UIKit/UIKit.h>
@class NewsBlurAppDelegate;
@interface NotificationFeedCell : UITableViewCell {
NewsBlurAppDelegate *appDelegate;
}
@property (nonatomic) NewsBlurAppDelegate *appDelegate;
@end

View file

@ -0,0 +1,27 @@
//
// NotificationFeedCell.m
// NewsBlur
//
// Created by Samuel Clay on 11/23/16.
// Copyright © 2016 NewsBlur. All rights reserved.
//
#import "NotificationFeedCell.h"
#import "NewsBlurAppDelegate.h"
@implementation NotificationFeedCell
@synthesize appDelegate;
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end

View file

@ -7,7 +7,16 @@
//
#import <UIKit/UIKit.h>
#import "NewsBlurAppDelegate.h"
@interface NotificationsViewController : UIViewController
@class NewsBlurAppDelegate;
@interface NotificationsViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
NewsBlurAppDelegate *appDelegate;
}
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) IBOutlet UITableView *notificationsTable;
@property (nonatomic) NSInteger feedId;
@end

View file

@ -7,6 +7,7 @@
//
#import "NotificationsViewController.h"
#import "NotificationFeedCell.h"
@interface NotificationsViewController ()
@ -14,9 +15,30 @@
@implementation NotificationsViewController
@synthesize notificationsTable;
@synthesize appDelegate;
@synthesize feedId;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.navigationItem.title = @"Notifications";
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle: @"Done"
style: UIBarButtonItemStylePlain
target: self
action: @selector(doCancelButton)];
[self.navigationItem setRightBarButtonItem:cancelButton];
// Do any additional setup after loading the view from its nib.
self.appDelegate = (NewsBlurAppDelegate *)[[UIApplication sharedApplication] delegate];
notificationsTable = [[UITableView alloc] init];
notificationsTable.delegate = self;
notificationsTable.dataSource = self;
notificationsTable.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);;
notificationsTable.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
notificationsTable.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.view addSubview:notificationsTable];
}
- (void)didReceiveMemoryWarning {
@ -24,14 +46,144 @@
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
- (void)doCancelButton {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[notificationsTable reloadData];
self.view.backgroundColor = UIColorFromRGB(NEWSBLUR_WHITE_COLOR);
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(@"notifications table: %@ / %@", NSStringFromCGRect(notificationsTable.frame), NSStringFromCGRect(self.view.frame));
}
#pragma mark - Table view delegate
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 36;
}
- (UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section {
int headerLabelHeight, folderImageViewY;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
headerLabelHeight = 36;
folderImageViewY = 3;
} else {
headerLabelHeight = 36;
folderImageViewY = 0;
}
// create the parent view that will hold header Label
UIControl* customView = [[UIControl alloc]
initWithFrame:CGRectMake(0.0, 0.0,
tableView.bounds.size.width, headerLabelHeight + 1)];
UIView *borderTop = [[UIView alloc]
initWithFrame:CGRectMake(0.0, 0,
tableView.bounds.size.width, 1.0)];
borderTop.backgroundColor = UIColorFromRGB(0xe0e0e0);
borderTop.opaque = NO;
[customView addSubview:borderTop];
UIView *borderBottom = [[UIView alloc]
initWithFrame:CGRectMake(0.0, headerLabelHeight,
tableView.bounds.size.width, 1.0)];
borderBottom.backgroundColor = [UIColorFromRGB(0xB7BDC6) colorWithAlphaComponent:0.5];
borderBottom.opaque = NO;
[customView addSubview:borderBottom];
UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
customView.opaque = NO;
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.opaque = NO;
headerLabel.textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:1.0];
headerLabel.highlightedTextColor = UIColorFromRGB(NEWSBLUR_WHITE_COLOR);
headerLabel.font = [UIFont boldSystemFontOfSize:11];
headerLabel.frame = CGRectMake(36.0, 1.0, 286.0, headerLabelHeight);
headerLabel.shadowColor = [UIColor colorWithRed:.94 green:0.94 blue:0.97 alpha:1.0];
headerLabel.shadowOffset = CGSizeMake(0.0, 1.0);
if (self.feedId && section == 0) {
headerLabel.text = @"SITE NOTIFICATIONS";
} else {
headerLabel.text = @"ALL NOTIFICATIONS";
}
customView.backgroundColor = [UIColorFromRGB(0xD7DDE6)
colorWithAlphaComponent:0.8];
[customView addSubview:headerLabel];
UIImage *folderImage;
int folderImageViewX = 10;
if (self.feedId && section == 0) {
folderImage = [UIImage imageNamed:@"menu_icn_notifications.png"];
} else {
folderImage = [UIImage imageNamed:@"menu_icn_notifications.png"];
}
folderImageViewX = 9;
UIImageView *folderImageView = [[UIImageView alloc] initWithImage:folderImage];
folderImageView.frame = CGRectMake(folderImageViewX, folderImageViewY, 20, 36);
[customView addSubview:folderImageView];
[customView setAutoresizingMask:UIViewAutoresizingNone];
return customView;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
if (self.feedId) {
return 2;
}
return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 140;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (self.feedId && section == 0) {
return 1;
}
return MAX(appDelegate.notificationFeedIds.count, 1);
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CGRect vb = self.view.bounds;
static NSString *CellIdentifier = @"NotificationFeedCellIdentifier";
NotificationFeedCell *cell = (NotificationFeedCell *)[tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[NotificationFeedCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:nil];
}
if (appDelegate.notificationFeedIds.count == 0) {
UILabel *msg = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, vb.size.width, 140)];
[cell.contentView addSubview:msg];
msg.text = @"No results.";
msg.textColor = UIColorFromRGB(0x7a7a7a);
if (vb.size.width > 320) {
msg.font = [UIFont fontWithName:@"Helvetica-Bold" size: 20.0];
} else {
msg.font = [UIFont fontWithName:@"Helvetica-Bold" size: 14.0];
}
msg.textAlignment = NSTextAlignmentCenter;
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
*/
@end

View file

@ -347,6 +347,8 @@
FF546DF9160298E500948020 /* fleuron@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FF546DF8160298E500948020 /* fleuron@2x.png */; };
FF5ACC211DE5ED7500FBD044 /* menu_icn_notifications.png in Resources */ = {isa = PBXBuildFile; fileRef = FF5ACC201DE5ED7500FBD044 /* menu_icn_notifications.png */; };
FF5ACC241DE5F0C000FBD044 /* NotificationsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FF5ACC231DE5F0C000FBD044 /* NotificationsViewController.m */; };
FF5ACC271DE5FA3E00FBD044 /* NotificationFeedCell.m in Sources */ = {isa = PBXBuildFile; fileRef = FF5ACC261DE5FA3E00FBD044 /* NotificationFeedCell.m */; };
FF5ACC2B1DE6088B00FBD044 /* menu_icn_notifications@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FF5ACC291DE6088B00FBD044 /* menu_icn_notifications@2x.png */; };
FF5D4017179A00B900349659 /* traverse_send.png in Resources */ = {isa = PBXBuildFile; fileRef = FF5D4015179A00B900349659 /* traverse_send.png */; };
FF5D4018179A00B900349659 /* traverse_send@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FF5D4016179A00B900349659 /* traverse_send@2x.png */; };
FF5D401B179A03E700349659 /* traverse_previous_off.png in Resources */ = {isa = PBXBuildFile; fileRef = FF5D4019179A03E700349659 /* traverse_previous_off.png */; };
@ -1048,6 +1050,9 @@
FF5ACC201DE5ED7500FBD044 /* menu_icn_notifications.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = menu_icn_notifications.png; sourceTree = "<group>"; };
FF5ACC221DE5F0C000FBD044 /* NotificationsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotificationsViewController.h; sourceTree = "<group>"; };
FF5ACC231DE5F0C000FBD044 /* NotificationsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NotificationsViewController.m; sourceTree = "<group>"; };
FF5ACC251DE5FA3E00FBD044 /* NotificationFeedCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotificationFeedCell.h; sourceTree = "<group>"; };
FF5ACC261DE5FA3E00FBD044 /* NotificationFeedCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NotificationFeedCell.m; sourceTree = "<group>"; };
FF5ACC291DE6088B00FBD044 /* menu_icn_notifications@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "menu_icn_notifications@2x.png"; sourceTree = "<group>"; };
FF5D4015179A00B900349659 /* traverse_send.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = traverse_send.png; sourceTree = "<group>"; };
FF5D4016179A00B900349659 /* traverse_send@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "traverse_send@2x.png"; sourceTree = "<group>"; };
FF5D4019179A03E700349659 /* traverse_previous_off.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = traverse_previous_off.png; sourceTree = "<group>"; };
@ -1632,6 +1637,8 @@
FF2D8CE314893BBF00057B80 /* MoveSiteViewController.m */,
FF5ACC221DE5F0C000FBD044 /* NotificationsViewController.h */,
FF5ACC231DE5F0C000FBD044 /* NotificationsViewController.m */,
FF5ACC251DE5FA3E00FBD044 /* NotificationFeedCell.h */,
FF5ACC261DE5FA3E00FBD044 /* NotificationFeedCell.m */,
);
name = "Feed-Detail";
sourceTree = "<group>";
@ -1924,6 +1931,7 @@
43A4C3F315B00A26008787B5 /* arrow.png */,
43A4C3F415B00A26008787B5 /* arrow@2x.png */,
FF5ACC201DE5ED7500FBD044 /* menu_icn_notifications.png */,
FF5ACC291DE6088B00FBD044 /* menu_icn_notifications@2x.png */,
43A4C3F715B00A26008787B5 /* Background.png */,
43A4C3F815B00A26008787B5 /* Background@2X.png */,
43A4C41115B00A26008787B5 /* fleuron.png */,
@ -2893,6 +2901,7 @@
1740C69E1C1110BA005EA453 /* theme_color_light-sel.png in Resources */,
FFDD848216E887D3000AA0A2 /* g_icn_unread.png in Resources */,
FFDD848316E887D3000AA0A2 /* g_icn_unread@2x.png in Resources */,
FF5ACC2B1DE6088B00FBD044 /* menu_icn_notifications@2x.png in Resources */,
FFDD848616E8EB1E000AA0A2 /* share.png in Resources */,
FFDD848716E8EB1E000AA0A2 /* share@2x.png in Resources */,
17C5BA6B1CA39EA400F5961C /* unread_green_icn.png in Resources */,
@ -3084,6 +3093,7 @@
FF8D1ECE1BAA311000725D8A /* SBJson4StreamParserState.m in Sources */,
FF4151C016DED9660013E84B /* UIBarButtonItem+Image.m in Sources */,
FF8D1ED11BAA311000725D8A /* SBJson4StreamWriterState.m in Sources */,
FF5ACC271DE5FA3E00FBD044 /* NotificationFeedCell.m in Sources */,
FFA045B619CA49D700618DC4 /* SSWDirectionalPanGestureRecognizer.m in Sources */,
FF1F13D318A9C2BE00FDA816 /* TMCache.m in Sources */,
FF22FE5E16E53ADC0046165A /* Underscore+Functional.m in Sources */,

View file

@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="15A282b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2555" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="UIApplication">
@ -28,6 +32,7 @@
<outlet property="loginViewController" destination="102" id="103"/>
<outlet property="moveSiteViewController" destination="124" id="126"/>
<outlet property="navigationController" destination="39" id="45"/>
<outlet property="notificationsViewController" destination="Fm7-T6-awA" id="PFa-sw-wdZ"/>
<outlet property="shareViewController" destination="131" id="132"/>
<outlet property="storyDetailViewController" destination="92" id="173"/>
<outlet property="storyPageControl" destination="170" id="172"/>
@ -111,6 +116,12 @@
<outlet property="appDelegate" destination="3" id="136"/>
</connections>
</viewController>
<viewController id="Fm7-T6-awA" customClass="NotificationsViewController">
<extendedEdge key="edgesForExtendedLayout"/>
<connections>
<outlet property="appDelegate" destination="3" id="zKW-JW-oDh"/>
</connections>
</viewController>
<viewController id="146" customClass="FontSettingsViewController">
<extendedEdge key="edgesForExtendedLayout"/>
<connections>
@ -153,15 +164,14 @@
<window opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="12" customClass="EventWindow">
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
<autoresizingMask key="autoresizingMask"/>
<animations/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
</window>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="39">
<extendedEdge key="edgesForExtendedLayout"/>
<navigationBar key="navigationBar" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="41">
<rect key="frame" x="0.0" y="0.0" width="1000" height="1000"/>
<autoresizingMask key="autoresizingMask"/>
<animations/>
</navigationBar>
<viewControllers>
<viewController nibName="NewsBlurViewController" id="40" customClass="NewsBlurViewController">
@ -171,4 +181,9 @@
</viewControllers>
</navigationController>
</objects>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
</simulatedMetricsContainer>
</document>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB