#1247 (Mac Catalyst edition)

- Added the acivity button to the user info above the feeds list.
- Now validates the menu items based on visible views.
- The View > Columns etc submenus now include checkmarks for their current state.
- The Feed menu items are now disabled for Everything and folders etc as appropriate.
- The Story > Save This Story and Mark as Read menu items toggle their titles as appropriate.
- Fixed the Notifications, Statistics, and other panels not appearing.
- Removed the View > Hide Toolbar menu command, since it doesn’t make sense to do so.
- Fixed the no story message being hidden when it shouldn’t be.
This commit is contained in:
David Sinclair 2024-01-19 21:44:29 -05:00
parent 46bdd7214f
commit 1d68bc889b
22 changed files with 141 additions and 42 deletions

View file

@ -14,6 +14,8 @@
@property (nonatomic, readonly) BOOL isVision;
@property (nonatomic, readonly) BOOL isPortrait;
@property (nonatomic, readonly) BOOL isCompactWidth;
@property (nonatomic, readonly) BOOL isFeedShown;
@property (nonatomic, readonly) BOOL isStoryShown;
- (void)informError:(id)error;
- (void)informError:(id)error statusCode:(NSInteger)statusCode;
@ -49,6 +51,8 @@
- (IBAction)chooseFontSize:(id)sender;
- (IBAction)chooseSpacing:(id)sender;
- (IBAction)chooseTheme:(id)sender;
- (IBAction)showTrain:(id)sender;
- (IBAction)showShare:(id)sender;
@end

View file

@ -218,11 +218,63 @@
}
}
- (BOOL)isFeedShown {
return appDelegate.storiesCollection.activeFeed != nil || appDelegate.storiesCollection.activeFolder != nil;
}
- (BOOL)isStoryShown {
return !appDelegate.storyPagesViewController.currentPage.view.isHidden && appDelegate.storyPagesViewController.currentPage.noStoryMessage.isHidden;
}
- (BOOL)isCompactWidth {
return self.view.window.windowScene.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact;
//return self.compactWidth > 0.0;
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
if (action == @selector(muteSite) || action == @selector(openRenameSite)) {
return !appDelegate.storiesCollection.isEverything;
} else if (action == @selector(openTrainSite) || action == @selector(openNotifications:) || action == @selector(openStatistics:)) {
return !appDelegate.storiesCollection.isRiverOrSocial;
} else if (action == @selector(openRenameSite)) {
return appDelegate.storiesCollection.isSocialView;
} else if (action == @selector(showTrain:) || action == @selector(showShare:)) {
return self.isStoryShown;
} else {
return [super canPerformAction:action withSender:sender];
}
}
- (void)validateCommand:(UICommand *)command {
[super validateCommand:command];
if (command.action == @selector(chooseColumns:)) {
command.state = [command.propertyList isEqualToString:appDelegate.detailViewController.behaviorString];
} else if (command.action == @selector(chooseFontSize:)) {
NSString *value = [[NSUserDefaults standardUserDefaults] objectForKey:@"feed_list_font_size"];
command.state = [command.propertyList isEqualToString:value];
} else if (command.action == @selector(chooseSpacing:)) {
NSString *value = [[NSUserDefaults standardUserDefaults] objectForKey:@"feed_list_spacing"];
command.state = [command.propertyList isEqualToString:value];
} else if (command.action == @selector(chooseTheme:)) {
command.state = [command.propertyList isEqualToString:ThemeManager.themeManager.theme];
} else if (command.action == @selector(toggleStorySaved:)) {
BOOL isRead = [[self.appDelegate.activeStory objectForKey:@"starred"] boolValue];
if (isRead) {
command.title = @"Unsave This Story";
} else {
command.title = @"Save THis Story";
}
} else if (command.action == @selector(toggleStoryUnread:)) {
BOOL isRead = [[self.appDelegate.activeStory objectForKey:@"read_status"] boolValue];
if (isRead) {
command.title = @"Mark as Unread";
} else {
command.title = @"Mark as Read";
}
}
}
- (IBAction)reloadFeeds:(id)sender {
[appDelegate reloadFeedsView:NO];
}
@ -299,4 +351,12 @@
[ThemeManager themeManager].theme = string;
}
- (IBAction)showTrain:(id)sender {
[self.appDelegate openTrainStory:self.appDelegate.storyPagesViewController.fontSettingsButton];
}
- (IBAction)showShare:(id)sender {
[self.appDelegate.storyPagesViewController.currentPage openShareDialog];
}
@end

View file

@ -168,7 +168,7 @@ class DetailViewController: BaseViewController {
/// How the split controller behaves.
var behavior: Behavior {
switch UserDefaults.standard.string(forKey: Key.behavior) {
switch behaviorString {
case BehaviorValue.tile:
return .tile
case BehaviorValue.displace:
@ -180,6 +180,11 @@ class DetailViewController: BaseViewController {
}
}
/// The split controller behavior as a raw string.
@objc var behaviorString: String {
return UserDefaults.standard.string(forKey: Key.behavior) ?? BehaviorValue.auto
}
/// Position of the divider between the views.
var dividerPosition: CGFloat {
get {

View file

@ -3018,9 +3018,9 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
}
- (IBAction)openNotifications:(id)sender {
NSString *feedId = [self.appDelegate.storiesCollection.activeFeed objectForKey:@"id"];
NSString *feedIdStr = storiesCollection.activeFeedIdStr;
[appDelegate openNotificationsWithFeed:feedId];
[appDelegate openNotificationsWithFeed:feedIdStr];
}
- (void)openNotificationsWithFeed:(NSString *)feedId {
@ -3028,9 +3028,9 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
}
- (IBAction)openStatistics:(id)sender {
NSString *feedId = [self.appDelegate.storiesCollection.activeFeed objectForKey:@"id"];
NSString *feedIdStr = storiesCollection.activeFeedIdStr;
[appDelegate openStatisticsWithFeed:feedId sender:settingsBarButton];
[appDelegate openStatisticsWithFeed:feedIdStr sender:settingsBarButton];
}
- (void)openStatisticsWithFeed:(NSString *)feedId {

View file

@ -57,6 +57,7 @@ UIGestureRecognizerDelegate, UISearchBarDelegate> {
@property (nonatomic) IBOutlet UIBarButtonItem * homeButton;
@property (nonatomic) IBOutlet UIBarButtonItem * addBarButton;
@property (nonatomic) IBOutlet UIBarButtonItem * settingsBarButton;
@property (nonatomic) UIButton *activityButton;
@property (nonatomic) IBOutlet UIBarButtonItem * activitiesButton;
#if TARGET_OS_MACCATALYST
@property (nonatomic) IBOutlet UIBarButtonItem * spacerBarButton;

View file

@ -712,18 +712,19 @@ static NSArray<NSString *> *NewsBlurTopSectionNames;
// [settingsBarButton setCustomView:settingsButton];
UIImage *activityImage = [Utilities templateImageNamed:@"dialog-notifications" sized:32];
NBBarButtonItem *activityButton = [NBBarButtonItem buttonWithType:UIButtonTypeCustom];
activityButton.accessibilityLabel = @"Activities";
[activityButton setImage:activityImage forState:UIControlStateNormal];
activityButton.tintColor = UIColorFromRGB(0x8F918B);
[activityButton setImageEdgeInsets:UIEdgeInsetsMake(4, 0, 4, 0)];
[activityButton addTarget:self
[self.activityButton removeFromSuperview];
self.activityButton = [NBBarButtonItem buttonWithType:UIButtonTypeCustom];
self.activityButton.accessibilityLabel = @"Activities";
[self.activityButton setImage:activityImage forState:UIControlStateNormal];
self.activityButton.tintColor = UIColorFromRGB(0x8F918B);
[self.activityButton setImageEdgeInsets:UIEdgeInsetsMake(4, 0, 4, 0)];
[self.activityButton addTarget:self
action:@selector(showInteractionsPopover:)
forControlEvents:UIControlEventTouchUpInside];
activitiesButton = [[UIBarButtonItem alloc]
initWithCustomView:activityButton];
initWithCustomView:self.activityButton];
activitiesButton.width = 32;
// activityButton.backgroundColor = UIColor.redColor;
// self.activityButton.backgroundColor = UIColor.redColor;
self.navigationItem.rightBarButtonItem = activitiesButton;
NSMutableDictionary *sortedFolders = [[NSMutableDictionary alloc] init];
@ -2881,7 +2882,7 @@ heightForHeaderInSection:(NSInteger)section {
[self.userInfoView removeFromSuperview];
self.userInfoView = [[UIView alloc]
initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 50)];
initWithFrame:CGRectMake(0, 0, self.innerView.bounds.size.width, 50)];
self.userInfoView.backgroundColor = UIColorFromLightSepiaMediumDarkRGB(0xE0E0E0, 0xFFF8CA, 0x4F4F4F, 0x292B2C);
#else
if (!orientation) {
@ -2969,15 +2970,18 @@ heightForHeaderInSection:(NSInteger)section {
positiveCount.backgroundColor = [UIColor clearColor];
[self.userInfoView addSubview:positiveCount];
[self.userInfoView sizeToFit];
// self.userInfoView.backgroundColor = UIColor.blueColor;
#if TARGET_OS_MACCATALYST
self.activityButton.frame = CGRectMake(self.innerView.bounds.size.width - 36, 10, 32, 32);
[self.userInfoView addSubview:self.activityButton];
[self.innerView addSubview:self.userInfoView];
self.feedTitlesTopConstraint.constant = 50;
#else
[self.userInfoView sizeToFit];
self.navigationItem.titleView = self.userInfoView;
#endif
}

View file

@ -3356,6 +3356,24 @@
popoverPresentationController.backgroundColor = UIColorFromRGB(NEWSBLUR_WHITE_COLOR);
popoverPresentationController.permittedArrowDirections = permittedArrowDirections;
#if TARGET_OS_MACCATALYST
if (barButtonItem && barButtonItem == appDelegate.feedDetailViewController.settingsBarButton) {
UINavigationController *feedDetailNavController = appDelegate.feedDetailViewController.navigationController;
barButtonItem = nil;
sourceView = feedDetailNavController.view;
if (appDelegate.splitViewController.isFeedListHidden) {
sourceRect = CGRectMake(224, 0, 20, 20);
} else {
sourceRect = CGRectMake(152, 0, 20, 20);
}
} else if (barButtonItem && barButtonItem == appDelegate.storyPagesViewController.fontSettingsButton) {
UINavigationController *storiesNavController = appDelegate.storyPagesViewController.navigationController;
barButtonItem = nil;
sourceView = storiesNavController.view;
sourceRect = CGRectMake(storiesNavController.view.frame.size.width - 59, 0, 20, 20);
}
#endif
if (barButtonItem) {
popoverPresentationController.barButtonItem = barButtonItem;
} else {

View file

@ -59,10 +59,12 @@
@property (nonatomic, readwrite) BOOL transferredFromDashboard;
@property (nonatomic, readwrite) BOOL showHiddenStories;
@property (nonatomic, readwrite) BOOL inSearch;
@property (nonatomic, readonly) BOOL isEverything;
@property (nonatomic, readonly) BOOL isRiverOrSocial;
@property (nonatomic) NSString *searchQuery;
@property (nonatomic) NSString *savedSearchQuery;
@property (nonatomic, readonly) NSString *activeFeedIdStr;
@property (nonatomic, readonly) NSString *activeOrder;
@property (nonatomic, readonly) NSString *activeReadFilter;
@property (nonatomic, readonly) NSString *activeStoryTitlesPosition;

View file

@ -97,6 +97,10 @@
self.savedSearchQuery = fromCollection.savedSearchQuery;
}
- (BOOL)isEverything {
return [activeFolder isEqualToString:@"everything"];
}
- (BOOL)isRiverOrSocial {
return self.isRiverView || self.isSavedView || self.isReadView || self.isWidgetView || self.isSocialView || self.isSocialRiverView;
}
@ -232,6 +236,10 @@
return [[activeFeedStoryLocations objectAtIndex:location] intValue];
}
- (NSString *)activeFeedIdStr {
return [NSString stringWithFormat:@"%@", [activeFeed objectForKey:@"id"]];
}
- (NSString *)activeOrder {
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
NSString *orderPrefDefault = [userPreferences stringForKey:@"default_order"];

View file

@ -1405,9 +1405,11 @@
int bottomPosition = webpageHeight - topPosition - viewportHeight;
BOOL singlePage = webpageHeight - 200 <= viewportHeight;
BOOL atBottom = bottomPosition < 150;
BOOL pullingDown = topPosition < 0;
BOOL atTop = topPosition < 50;
#if !TARGET_OS_MACCATALYST
BOOL pullingDown = topPosition < 0;
BOOL nearTop = topPosition < 100;
#endif
if (!hasScrolled && topPosition != 0) {
hasScrolled = YES;

View file

@ -156,8 +156,6 @@
- (IBAction)toggleStorySaved:(id)sender;
- (IBAction)toggleStoryUnread:(id)sender;
- (IBAction)showTrain:(id)sender;
- (IBAction)showShare:(id)sender;
- (void)finishMarkAsSaved:(NSDictionary *)params;
- (BOOL)failedMarkAsSaved:(NSDictionary *)params;

View file

@ -1086,9 +1086,12 @@
}
self.scrollingToPage = pageIndex;
[self.currentPage hideNoStoryMessage];
[self.nextPage hideNoStoryMessage];
[self.previousPage hideNoStoryMessage];
if (pageIndex >= 0) {
[self.currentPage hideNoStoryMessage];
[self.nextPage hideNoStoryMessage];
[self.previousPage hideNoStoryMessage];
}
// Check if already on the selected page
if (self.isHorizontal ? offset.x == frame.origin.x : offset.y == frame.origin.y) {
@ -1488,14 +1491,6 @@
[appDelegate.feedDetailViewController reload]; // XXX only if successful?
}
- (IBAction)showTrain:(id)sender {
[self.appDelegate openTrainStory:self.appDelegate.storyPagesViewController.fontSettingsButton];
}
- (IBAction)showShare:(id)sender {
[self.appDelegate.storyPagesViewController.currentPage openShareDialog];
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
if (action == @selector(toggleTextView:) ||
action == @selector(scrollPageDown:) ||

View file

@ -25,7 +25,7 @@ class StoryPagesViewController: StoryPagesObjCViewController {
@objc func validateToolbarItem(_ item: NSToolbarItem) -> Bool {
if [.storyPagesSettings, .storyPagesBrowser].contains(item.itemIdentifier) {
return !self.currentPage.view.isHidden && self.currentPage.noStoryMessage.isHidden
return self.isStoryShown
} else {
return true
}

View file

@ -3853,7 +3853,7 @@
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1120;
LastUpgradeCheck = 1510;
LastUpgradeCheck = 1520;
ORGANIZATIONNAME = NewsBlur;
TargetAttributes = {
173CB30C26BCE94700BA872A = {

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
LastUpgradeVersion = "1520"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
LastUpgradeVersion = "1520"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
LastUpgradeVersion = "1520"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
LastUpgradeVersion = "1520"
wasCreatedForAppExtension = "YES"
version = "1.3">
<BuildAction

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
LastUpgradeVersion = "1520"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
LastUpgradeVersion = "1520"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
LastUpgradeVersion = "1520"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction

View file

@ -346,7 +346,7 @@
<children>
<menu title="Columns" id="Zsw-UK-Yxk">
<children>
<command title="Automatic" propertyListString="auto" input="4" id="6Vl-Xq-5Ko">
<command title="Automatic" propertyListString="auto" menuElementState="on" input="4" id="6Vl-Xq-5Ko">
<keyModifierFlags key="modifierFlags" option="YES" command="YES"/>
<connections>
<action selector="chooseColumns:" destination="J28-e1-gcC" id="vNz-nO-9sE"/>
@ -421,9 +421,8 @@
</children>
</menu>
<menu title="Theme" id="k0L-se-kpA">
<menuOptions key="menuOptions" singleSelection="YES"/>
<children>
<command title="Light" propertyListString="light" id="nvf-Kg-GEz">
<command title="Light" propertyListString="light" menuElementState="on" id="nvf-Kg-GEz">
<connections>
<action selector="chooseTheme:" destination="J28-e1-gcC" id="AGW-N1-hqV"/>
</connections>
@ -446,6 +445,9 @@
</children>
</menu>
</children>
<systemMenuChildDeletions>
<menuDeletion anchor="com.apple.menu.toolbar"/>
</systemMenuChildDeletions>
</menu>
<menu title="Site" identifier="site" anchor="com.apple.menu.view" id="Kg8-V5-XsH">
<children>