iOS: mute changes; combined select/sort menu on right, on/off, greyed out text, scrollable menu when needed, etc

This commit is contained in:
David Sinclair 2016-02-03 21:51:57 -08:00
parent e98cf18bfd
commit 850b547b2e
10 changed files with 85 additions and 39 deletions

View file

@ -10,4 +10,6 @@
@interface FeedChooserViewCell : UITableViewCell
@property (nonatomic) BOOL isMuteOperation;
@end

View file

@ -41,14 +41,24 @@
frame.size.width = self.detailTextLabel.frame.origin.x - self.textLabel.frame.origin.x;
self.textLabel.frame = frame;
frame = self.detailTextLabel.frame;
frame.origin.x -= 10.0;
self.detailTextLabel.frame = frame;
self.textLabel.backgroundColor = [UIColor clearColor];
self.textLabel.textColor = UIColorFromRGB(0x303030);
self.textLabel.highlightedTextColor = UIColorFromRGB(0x303030);
self.textLabel.shadowColor = UIColorFromRGB(0xF0F0F0);
self.textLabel.shadowOffset = CGSizeMake(0, 1);
if (self.isMuteOperation) {
self.textLabel.highlightedTextColor = UIColorFromRGB(0x808080);
self.detailTextLabel.highlightedTextColor = UIColorFromRGB(0xa0a0a0);
} else {
self.textLabel.highlightedTextColor = UIColorFromRGB(0x303030);
self.detailTextLabel.highlightedTextColor = UIColorFromRGB(0x505050);
}
self.detailTextLabel.textColor = UIColorFromRGB(0x505050);
self.detailTextLabel.highlightedTextColor = UIColorFromRGB(0x505050);
self.backgroundColor = UIColorFromRGB(0xFFFFFF);
self.backgroundView.backgroundColor = UIColorFromRGB(0xFFFFFF);

View file

@ -19,8 +19,7 @@ static const CGFloat kFolderTitleHeight = 36.0;
@interface FeedChooserViewController () <FeedChooserTitleDelegate>
@property (nonatomic, strong) UIBarButtonItem *selectionItem;
@property (nonatomic, strong) UIBarButtonItem *sortItem;
@property (nonatomic, strong) UIBarButtonItem *optionsItem;
@property (nonatomic, strong) UIBarButtonItem *moveItem;
@property (nonatomic, strong) UIBarButtonItem *deleteItem;
@property (nonatomic, strong) NSArray *sections;
@ -45,23 +44,27 @@ static const CGFloat kFolderTitleHeight = 36.0;
[super viewDidLoad];
UIBarButtonItem *doneItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done)];
self.selectionItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"barbutton_selection.png"] style:UIBarButtonItemStylePlain target:self action:@selector(showSelectionMenu)];
self.sortItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:[self sortIconName]] style:UIBarButtonItemStylePlain target:self action:@selector(showSortMenu)];
self.optionsItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"nav_icn_settings.png"] style:UIBarButtonItemStylePlain target:self action:@selector(showOptionsMenu)];
if (self.operation == FeedChooserOperationOrganizeSites) {
self.moveItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"menu_icn_move.png"] style:UIBarButtonItemStylePlain target:self action:@selector(showMoveMenu)];
self.deleteItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"menu_icn_delete.png"] style:UIBarButtonItemStylePlain target:self action:@selector(deleteFeeds)];
self.navigationItem.leftBarButtonItems = @[self.selectionItem, self.sortItem];
self.navigationItem.rightBarButtonItems = @[doneItem, self.deleteItem, self.moveItem];
self.navigationItem.leftBarButtonItems = @[self.moveItem, self.deleteItem];
self.navigationItem.rightBarButtonItems = @[doneItem, self.optionsItem];
self.navigationItem.title = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? @"Organize Sites" : @"Organize";
self.tableView.editing = YES;
} else {
self.navigationItem.leftBarButtonItems = @[self.selectionItem, self.sortItem];
self.navigationItem.rightBarButtonItem = doneItem;
UIBarButtonItem *cancelItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel)];
self.navigationItem.leftBarButtonItem = cancelItem;
self.navigationItem.rightBarButtonItems = @[doneItem, self.optionsItem];
self.navigationItem.title = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? @"Mute Sites" : @"Mute";
self.tableView.editing = NO;
}
self.tableView.editing = YES;
self.tableView.backgroundColor = UIColorFromRGB(0xECEEEA);
self.tableView.separatorColor = UIColorFromRGB(0x909090);
self.tableView.sectionIndexColor = UIColorFromRGB(0x303030);
@ -114,7 +117,7 @@ static const CGFloat kFolderTitleHeight = 36.0;
[self rebuildItemsAnimated:NO];
[self enumerateAllRowsUsingBlock:^(NSIndexPath *indexPath, FeedChooserItem *item) {
if ([item.info[@"active"] boolValue]) {
if (![item.info[@"active"] boolValue]) {
[self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
}
}];
@ -346,24 +349,6 @@ static const CGFloat kFolderTitleHeight = 36.0;
#pragma mark - Target/action methods
- (void)showSelectionMenu {
MenuViewController *viewController = [MenuViewController new];
[viewController addTitle:@"Select All" iconName:@"barbutton_selection.png" selectionShouldDismiss:YES handler:^{
[self enumerateSectionsUsingBlock:^(NSUInteger section, FeedChooserItem *folder) {
[self select:YES section:section];
}];
}];
[viewController addTitle:@"Select None" iconName:@"barbutton_selection_off.png" selectionShouldDismiss:YES handler:^{
[self enumerateSectionsUsingBlock:^(NSUInteger section, FeedChooserItem *folder) {
[self select:NO section:section];
}];
}];
[viewController showFromNavigationController:self.navigationController barButtonItem:self.selectionItem];
}
- (NSString *)sortIconName {
if (self.ascending) {
return @"barbutton_sort_asc.png";
@ -383,8 +368,9 @@ static const CGFloat kFolderTitleHeight = 36.0;
[self selectItemsWithIdentifiers:identifiers animated:NO];
}
- (void)showSortMenu {
- (void)showOptionsMenu {
MenuViewController *viewController = [MenuViewController new];
BOOL isMute = self.operation == FeedChooserOperationMuteSites;
[viewController addTitle:@"Name" iconName:[self sortIconName] selectionShouldDismiss:YES handler:^{
[self sort:FeedChooserSortName];
@ -411,7 +397,6 @@ static const CGFloat kFolderTitleHeight = 36.0;
[viewController addSegmentedControlWithTitles:@[@"Ascending", @"Descending"] selectIndex:self.ascending ? 0 : 1 selectionShouldDismiss:YES handler:^(NSUInteger selectedIndex) {
NSArray *identifiers = [self selectedItemIdentifiers];
self.ascending = selectedIndex == 0;
self.sortItem.image = [UIImage imageNamed:[self sortIconName]];
[self sortItemsAnimated:YES];
[self selectItemsWithIdentifiers:identifiers animated:NO];
}];
@ -423,7 +408,19 @@ static const CGFloat kFolderTitleHeight = 36.0;
[self selectItemsWithIdentifiers:identifiers animated:NO];
}];
[viewController showFromNavigationController:self.navigationController barButtonItem:self.sortItem];
[viewController addTitle:isMute ? @"Mute All" : @"Select All" iconName:isMute ? @"mute_feed_off.png" : @"barbutton_selection.png" selectionShouldDismiss:YES handler:^{
[self enumerateSectionsUsingBlock:^(NSUInteger section, FeedChooserItem *folder) {
[self select:YES section:section];
}];
}];
[viewController addTitle:isMute ? @"Unmute All" : @"Select None" iconName:isMute ? @"mute_feed_on.png" : @"barbutton_selection_off.png" selectionShouldDismiss:YES handler:^{
[self enumerateSectionsUsingBlock:^(NSUInteger section, FeedChooserItem *folder) {
[self select:NO section:section];
}];
}];
[viewController showFromNavigationController:self.navigationController barButtonItem:self.optionsItem];
}
- (void)performMoveToFolder:(FeedChooserItem *)toFolder {
@ -548,9 +545,14 @@ static const CGFloat kFolderTitleHeight = 36.0;
NSString *urlString = [NSString stringWithFormat:@"%@/reader/save_feed_chooser", self.appDelegate.url];
NSURL *url = [NSURL URLWithString:urlString];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
for (id identifier in [self selectedItemIdentifiers]) {
[request addPostValue:identifier forKey:@"approved_feeds"];
}
NSArray *mutedIndexPaths = self.tableView.indexPathsForSelectedRows;
[self enumerateAllRowsUsingBlock:^(NSIndexPath *indexPath, FeedChooserItem *item) {
if (![mutedIndexPaths containsObject:indexPath]) {
[request addPostValue:item.identifier forKey:@"approved_feeds"];
}
}];
[request setCompletionBlock:^(void) {
[self.appDelegate reloadFeedsView:YES];
[self dismissViewControllerAnimated:YES completion:nil];
@ -585,6 +587,10 @@ static const CGFloat kFolderTitleHeight = 36.0;
}
}
- (void)cancel {
[self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
@ -608,7 +614,7 @@ static const CGFloat kFolderTitleHeight = 36.0;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIndentifier = @"FeedChooserCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIndentifier];
FeedChooserViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIndentifier];
if (!cell) {
cell = [[FeedChooserViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIndentifier];
@ -616,10 +622,16 @@ static const CGFloat kFolderTitleHeight = 36.0;
FeedChooserItem *item = [self itemForIndexPath:indexPath];
cell.isMuteOperation = self.operation == FeedChooserOperationMuteSites;
cell.textLabel.text = item.title;
cell.detailTextLabel.text = [item detailForSort:self.sort];
cell.imageView.image = item.icon;
UIImage *image = [UIImage imageNamed:@"mute_feed_on.png"];
UIImage *highlightedImage = [UIImage imageNamed:@"mute_feed_off.png"];
cell.accessoryView = [[UIImageView alloc] initWithImage:image highlightedImage:highlightedImage];
return cell;
}

View file

@ -49,6 +49,12 @@ NSString * const MenuHandler = @"handler";
[self.menuTableView reloadData];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.menuTableView.scrollEnabled = self.preferredContentSize.height > self.view.frame.size.height;
}
- (CGSize)preferredContentSize {
CGSize size = CGSizeMake(100.0, 0.0);
UIFont *font = [UIFont fontWithName:@"Helvetica-Bold" size:14.0];

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
@ -16,7 +16,7 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="460"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" bounces="NO" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="12">
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="12">
<rect key="frame" x="0.0" y="0.0" width="320" height="460"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>

View file

@ -36,6 +36,10 @@
175065911C5730FB00072BF5 /* barbutton_selection_off@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1750658E1C5730FB00072BF5 /* barbutton_selection_off@3x.png */; };
175696A61C596ABC004C128D /* menu_icn_all.png in Resources */ = {isa = PBXBuildFile; fileRef = 175696A41C596ABC004C128D /* menu_icn_all.png */; };
175696A71C596ABC004C128D /* menu_icn_all@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 175696A51C596ABC004C128D /* menu_icn_all@2x.png */; };
176129601C630AEB00702FE4 /* mute_feed_off.png in Resources */ = {isa = PBXBuildFile; fileRef = 1761295C1C630AEB00702FE4 /* mute_feed_off.png */; };
176129611C630AEB00702FE4 /* mute_feed_off@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1761295D1C630AEB00702FE4 /* mute_feed_off@2x.png */; };
176129621C630AEB00702FE4 /* mute_feed_on.png in Resources */ = {isa = PBXBuildFile; fileRef = 1761295E1C630AEB00702FE4 /* mute_feed_on.png */; };
176129631C630AEB00702FE4 /* mute_feed_on@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1761295F1C630AEB00702FE4 /* mute_feed_on@2x.png */; };
17BE5A721C5DDA8C0075F92C /* barbutton_sort_asc.png in Resources */ = {isa = PBXBuildFile; fileRef = 17BE5A6C1C5DDA8C0075F92C /* barbutton_sort_asc.png */; };
17BE5A731C5DDA8C0075F92C /* barbutton_sort_asc@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 17BE5A6D1C5DDA8C0075F92C /* barbutton_sort_asc@2x.png */; };
17BE5A741C5DDA8C0075F92C /* barbutton_sort_asc@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 17BE5A6E1C5DDA8C0075F92C /* barbutton_sort_asc@3x.png */; };
@ -554,6 +558,10 @@
1750658E1C5730FB00072BF5 /* barbutton_selection_off@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "barbutton_selection_off@3x.png"; sourceTree = "<group>"; };
175696A41C596ABC004C128D /* menu_icn_all.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = menu_icn_all.png; sourceTree = "<group>"; };
175696A51C596ABC004C128D /* menu_icn_all@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "menu_icn_all@2x.png"; sourceTree = "<group>"; };
1761295C1C630AEB00702FE4 /* mute_feed_off.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = mute_feed_off.png; sourceTree = "<group>"; };
1761295D1C630AEB00702FE4 /* mute_feed_off@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "mute_feed_off@2x.png"; sourceTree = "<group>"; };
1761295E1C630AEB00702FE4 /* mute_feed_on.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = mute_feed_on.png; sourceTree = "<group>"; };
1761295F1C630AEB00702FE4 /* mute_feed_on@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "mute_feed_on@2x.png"; sourceTree = "<group>"; };
17BE5A6C1C5DDA8C0075F92C /* barbutton_sort_asc.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = barbutton_sort_asc.png; sourceTree = "<group>"; };
17BE5A6D1C5DDA8C0075F92C /* barbutton_sort_asc@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "barbutton_sort_asc@2x.png"; sourceTree = "<group>"; };
17BE5A6E1C5DDA8C0075F92C /* barbutton_sort_asc@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "barbutton_sort_asc@3x.png"; sourceTree = "<group>"; };
@ -1597,6 +1605,10 @@
17EB505B1BE4411E0021358B /* choose_font@2x.png */,
FFF1E4C917750D2C00BF59D3 /* menu_icn_preferences.png */,
FFF1E4CA17750D2C00BF59D3 /* menu_icn_preferences@2x.png */,
1761295C1C630AEB00702FE4 /* mute_feed_off.png */,
1761295D1C630AEB00702FE4 /* mute_feed_off@2x.png */,
1761295E1C630AEB00702FE4 /* mute_feed_on.png */,
1761295F1C630AEB00702FE4 /* mute_feed_on@2x.png */,
FF1104601769695A00502C29 /* g_icn_offline@2x.png */,
FFC518B81768E59F00542719 /* g_icn_offline.png */,
FF8364C41757EC0B008F5C58 /* traverse_background_left.png */,
@ -2495,6 +2507,7 @@
43A4BADD15C866FA00F3B8D4 /* popoverArrowDownSimple.png in Resources */,
43A4BADE15C866FA00F3B8D4 /* popoverArrowLeft.png in Resources */,
FFC486AC19CA410000F4758F /* logo_50.png in Resources */,
176129601C630AEB00702FE4 /* mute_feed_off.png in Resources */,
FFB9BE4817F4B65B00FE0A36 /* logo_152.png in Resources */,
43A4BADF15C866FA00F3B8D4 /* popoverArrowLeft@2x.png in Resources */,
1750658F1C5730FB00072BF5 /* barbutton_selection_off.png in Resources */,
@ -2510,6 +2523,7 @@
43A4BAE515C866FA00F3B8D4 /* popoverArrowUp@2x.png in Resources */,
43A4BAE615C866FA00F3B8D4 /* popoverArrowUpSimple.png in Resources */,
43A4BAE715C866FA00F3B8D4 /* popoverBg.png in Resources */,
176129631C630AEB00702FE4 /* mute_feed_on@2x.png in Resources */,
43A4BAE815C866FA00F3B8D4 /* popoverBg@2x.png in Resources */,
FF88F10E1811BAEC007FEE78 /* unread_green.png in Resources */,
43A4BAE915C866FA00F3B8D4 /* popoverBgSimple.png in Resources */,
@ -2629,6 +2643,7 @@
17CBD3C21BF6ED2C003FCCAE /* menu_icn_markread.png in Resources */,
FFB7050E1925921F0052101C /* line_spacing_xs.png in Resources */,
FF22FE4E16E41EB40046165A /* disclosure_down.png in Resources */,
176129611C630AEB00702FE4 /* mute_feed_off@2x.png in Resources */,
17BE5A741C5DDA8C0075F92C /* barbutton_sort_asc@3x.png in Resources */,
FF22FE4F16E41EB40046165A /* disclosure_down@2x.png in Resources */,
FF22FE5116E42C600046165A /* world@2x.png in Resources */,
@ -2681,6 +2696,7 @@
FFB9BE4B17F4B65B00FE0A36 /* logo_120~iphone.png in Resources */,
17E6359E1C5431F50075338E /* menu_icn_organize.png in Resources */,
FFDD847916E887D3000AA0A2 /* g_icn_focus@2x.png in Resources */,
176129621C630AEB00702FE4 /* mute_feed_on.png in Resources */,
FFDD847A16E887D3000AA0A2 /* g_icn_folder_add.png in Resources */,
FFDD847B16E887D3000AA0A2 /* g_icn_folder_add@2x.png in Resources */,
FFDD847C16E887D3000AA0A2 /* g_icn_folder_rss.png in Resources */,

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB