Skip to content

Commit 8c6f6bf

Browse files
author
Michael Beattie
committed
[#67767620] Added new table cell for creating new feeds
1 parent 444117d commit 8c6f6bf

7 files changed

Lines changed: 122 additions & 51 deletions

File tree

EasyReader.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
0D9A835918E0AA4300D8376E /* CSSearchFeedCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D7987A418DB6AF4004440C3 /* CSSearchFeedCell.m */; };
2525
0D9A835A18E0AA4300D8376E /* CSSearchFeedCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D7987A418DB6AF4004440C3 /* CSSearchFeedCell.m */; };
2626
0D9A835B18E0AA4400D8376E /* CSSearchFeedCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D7987A418DB6AF4004440C3 /* CSSearchFeedCell.m */; };
27+
0D9A835E18E0C82200D8376E /* EZRCustomFeedCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D9A835D18E0C82200D8376E /* EZRCustomFeedCell.m */; };
2728
0DE51FF418CF911000454E51 /* FeedItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 0DE51FF018CF911000454E51 /* FeedItem.m */; };
2829
0DE51FF518CF911000454E51 /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = 0DE51FF218CF911000454E51 /* User.m */; };
2930
0DE51FF818CF919900454E51 /* Feed.m in Sources */ = {isa = PBXBuildFile; fileRef = 0DE51FF718CF919900454E51 /* Feed.m */; };
@@ -321,6 +322,8 @@
321322
0D7987B018DB8F69004440C3 /* CSMenuUserFeedDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSMenuUserFeedDataSource.m; sourceTree = "<group>"; };
322323
0D8FF1A818D0D8C0005155E6 /* Main_iPhone.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main_iPhone.storyboard; sourceTree = "<group>"; };
323324
0D8FF1AA18D0DA3F005155E6 /* control_dualEntryTextField@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "control_dualEntryTextField@2x.png"; sourceTree = "<group>"; };
325+
0D9A835C18E0C82100D8376E /* EZRCustomFeedCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZRCustomFeedCell.h; sourceTree = "<group>"; };
326+
0D9A835D18E0C82200D8376E /* EZRCustomFeedCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZRCustomFeedCell.m; sourceTree = "<group>"; };
324327
0DE51FE318CF8BDE00454E51 /* api_v2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = api_v2.xcdatamodel; sourceTree = "<group>"; };
325328
0DE51FEF18CF911000454E51 /* FeedItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FeedItem.h; sourceTree = "<group>"; };
326329
0DE51FF018CF911000454E51 /* FeedItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FeedItem.m; sourceTree = "<group>"; };
@@ -507,6 +510,8 @@
507510
0D79879F18DB6ABC004440C3 /* MenuCells */ = {
508511
isa = PBXGroup;
509512
children = (
513+
0D9A835C18E0C82100D8376E /* EZRCustomFeedCell.h */,
514+
0D9A835D18E0C82200D8376E /* EZRCustomFeedCell.m */,
510515
0D7987A018DB6AE4004440C3 /* CSUserFeedCell.h */,
511516
0D7987A118DB6AE4004440C3 /* CSUserFeedCell.m */,
512517
0D7987A318DB6AF4004440C3 /* CSSearchFeedCell.h */,
@@ -1453,6 +1458,7 @@
14531458
files = (
14541459
9D16D33D18DB7767001E9C38 /* CSFeedUpdateService.m in Sources */,
14551460
9D9CBABF18DC826700532F8C /* CSApplicationStyleService.m in Sources */,
1461+
0D9A835E18E0C82200D8376E /* EZRCustomFeedCell.m in Sources */,
14561462
0DE51FF818CF919900454E51 /* Feed.m in Sources */,
14571463
9DAC172D170A043200383722 /* CSAppDelegate.m in Sources */,
14581464
9DAC172E170A043200383722 /* main.m in Sources */,

EasyReader/Application/Controllers/Menu/CSMenuLeftViewController.m

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,8 @@ - (void)searchFieldDidChange
158158

159159
// If the user is typing a url
160160
if ([self.textField_searchInput.text hasPrefix:@"http"]) {
161-
// Get the local context
162-
NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextForCurrentThread];
163-
164-
// Create a new Feed in the current thread context
165-
Feed *customFeed = [Feed MR_createInContext:localContext];
166-
customFeed.name = self.textField_searchInput.text;
167-
customFeed.url = self.textField_searchInput.text;
161+
// Create a dictionary containing the new Feed url
162+
NSDictionary *customFeed = @{@"url" : self.textField_searchInput.text};
168163

169164
// Add custom feed to the searchFeeds
170165
[searchedFeeds addObject:customFeed];
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// EZRCustomFeedCell.h
3+
// EasyReader
4+
//
5+
// Created by Michael Beattie on 3/24/14.
6+
// Copyright (c) 2014 Cloudspace. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface EZRCustomFeedCell : UITableViewCell
12+
13+
#pragma mark - IBOutlets
14+
15+
/// The custom feed url
16+
@property (weak, nonatomic) IBOutlet UILabel *label_url;
17+
18+
@end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// EZRCustomFeedCell.m
3+
// EasyReader
4+
//
5+
// Created by Michael Beattie on 3/24/14.
6+
// Copyright (c) 2014 Cloudspace. All rights reserved.
7+
//
8+
9+
#import "EZRCustomFeedCell.h"
10+
11+
@implementation EZRCustomFeedCell
12+
13+
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
14+
{
15+
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
16+
if (self) {
17+
// Initialization code
18+
}
19+
return self;
20+
}
21+
22+
- (void)awakeFromNib
23+
{
24+
// Initialization code
25+
}
26+
27+
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
28+
{
29+
[super setSelected:selected animated:animated];
30+
31+
// Configure the view for the selected state
32+
}
33+
34+
@end

EasyReader/Application/Controllers/Menu/MenuDataSources/CSMenuSearchFeedDataSource.m

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#import "UIColor+EZRSharedColorAdditions.h"
1414

1515
#import "CSSearchFeedCell.h"
16+
#import "EZRCustomFeedCell.h"
1617

1718
#import "Feed.h"
1819
#import "FeedItem.h"
@@ -89,53 +90,38 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
8990
*/
9091
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
9192
{
92-
// Dequeue a styled cell
93-
CSSearchFeedCell *cell = (CSSearchFeedCell *)[tableView dequeueReusableCellWithIdentifier:@"SearchFeedCell"];
94-
95-
Feed *feed = [self.sortedFeeds objectAtIndex:indexPath.row];
96-
cell.feed = feed;
97-
98-
// Set the label text
99-
cell.label_name.text = feed.name;
100-
cell.label_name.textColor = [UIColor whiteColor];
101-
102-
// Show feed icons
103-
[cell.imageView_icon setHidden:NO];
104-
[cell.imageView setImageWithURL:[NSURL URLWithString:feed.icon] placeholderImage:nil];
105-
106-
UIView *selectedBackgroundView = [[UIView alloc] init];
107-
[selectedBackgroundView setBackgroundColor: [UIColor EZR_charcoal]];
108-
cell.selectedBackgroundView = selectedBackgroundView;
109-
return cell;
110-
}
93+
if ([[self.sortedFeeds objectAtIndex:indexPath.row] isKindOfClass:[Feed class]]) {
94+
// Dequeue a styled cell
95+
CSSearchFeedCell *cell = (CSSearchFeedCell *)[tableView dequeueReusableCellWithIdentifier:@"SearchFeedCell"];
11196

112-
/**
113-
* Commits each editing action
114-
*/
115-
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
116-
{
117-
if (editingStyle == UITableViewCellEditingStyleDelete) {
118-
Feed *toDelete = [self.sortedFeeds objectAtIndex:indexPath.row];
97+
Feed *feed = [self.sortedFeeds objectAtIndex:indexPath.row];
98+
cell.feed = feed;
11999

120-
[self.feeds removeObject:toDelete];
121-
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
100+
// Set the label text
101+
cell.label_name.text = feed.name;
122102

123-
for ( FeedItem *item in toDelete.feedItems ) [item deleteEntity];
124-
[toDelete deleteEntity];
103+
// Show feed icons
104+
[cell.imageView_icon setHidden:NO];
105+
[cell.imageView setImageWithURL:[NSURL URLWithString:feed.icon] placeholderImage:nil];
125106

126-
[[NSManagedObjectContext defaultContext] saveToPersistentStoreAndWait];
107+
UIView *selectedBackgroundView = [[UIView alloc] init];
108+
[selectedBackgroundView setBackgroundColor: [UIColor EZR_charcoal]];
109+
cell.selectedBackgroundView = selectedBackgroundView;
110+
return cell;
127111
}
128-
}
129-
130-
/**
131-
* Determines the editing style for each row
132-
*/
133-
- (UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
134-
{
135-
if ( indexPath.row == [self.sortedFeeds count] ) {
136-
return UITableViewCellEditingStyleInsert;
137-
} else {
138-
return UITableViewCellEditingStyleDelete;
112+
else{
113+
// Dequeue a styled cell
114+
EZRCustomFeedCell *cell = (EZRCustomFeedCell *)[tableView dequeueReusableCellWithIdentifier:@"CustomFeedCell"];
115+
116+
NSDictionary *customFeed = [self.sortedFeeds objectAtIndex:indexPath.row];
117+
118+
cell.label_url.text = [customFeed objectForKey:@"url"];
119+
120+
UIView *selectedBackgroundView = [[UIView alloc] init];
121+
[selectedBackgroundView setBackgroundColor: [UIColor EZR_charcoal]];
122+
cell.selectedBackgroundView = selectedBackgroundView;
123+
124+
return cell;
139125
}
140126
}
141127

EasyReader/Application/Controllers/Menu/MenuDataSources/CSMenuUserFeedDataSource.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
9595

9696
// Set the label text
9797
cell.label_name.text = feed.name;
98-
cell.label_name.textColor = [UIColor whiteColor];
9998

10099
// Show feed icons
101100
[cell.imageView_icon setHidden:NO];

EasyReader/Application/Views/Main_iPhone.storyboard

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
191191
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
192192
<fontDescription key="fontDescription" type="system" pointSize="17"/>
193-
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
193+
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
194194
<nil key="highlightedColor"/>
195195
</label>
196196
</subviews>
@@ -218,6 +218,7 @@
218218
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
219219
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
220220
<fontDescription key="fontDescription" type="system" pointSize="17"/>
221+
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
221222
<nil key="highlightedColor"/>
222223
</label>
223224
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xNC-fC-qEa">
@@ -237,6 +238,38 @@
237238
<outlet property="label_name" destination="SoB-0g-JfK" id="tc1-yU-AWq"/>
238239
</connections>
239240
</tableViewCell>
241+
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="CustomFeedCell" id="Omc-hY-KcW" customClass="EZRCustomFeedCell">
242+
<rect key="frame" x="0.0" y="170" width="270" height="44"/>
243+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
244+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Omc-hY-KcW" id="qA1-fL-k0E">
245+
<rect key="frame" x="0.0" y="0.0" width="270" height="43"/>
246+
<autoresizingMask key="autoresizingMask"/>
247+
<subviews>
248+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hpn-wo-IlL">
249+
<rect key="frame" x="15" y="11" width="210" height="21"/>
250+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
251+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
252+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
253+
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
254+
<nil key="highlightedColor"/>
255+
</label>
256+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tWI-oY-NeB">
257+
<rect key="frame" x="234" y="11" width="21" height="21"/>
258+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
259+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
260+
<fontDescription key="fontDescription" name="AmericanTypewriter-Bold" family="American Typewriter" pointSize="18"/>
261+
<state key="normal" title="+">
262+
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
263+
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
264+
</state>
265+
</button>
266+
</subviews>
267+
</tableViewCellContentView>
268+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
269+
<connections>
270+
<outlet property="label_url" destination="Hpn-wo-IlL" id="T31-7F-AMt"/>
271+
</connections>
272+
</tableViewCell>
240273
</prototypes>
241274
</tableView>
242275
</subviews>

0 commit comments

Comments
 (0)