#1247 (Mac Catalyst edition)

- Moved globally-relevant methods to BaseViewController, so their menu items are always available.
- Big refactor to eliminate redundant appDelegate properties.
- Work in progress on reimplementing the navigation bars as a Mac toolbar.
This commit is contained in:
David Sinclair 2024-01-05 22:02:43 -05:00
parent 8dac36651c
commit c94e517a88
46 changed files with 258 additions and 221 deletions

View file

@ -7,15 +7,10 @@
//
#import <UIKit/UIKit.h>
#import "NewsBlurAppDelegate.h"
#import "NewsBlur-Swift.h"
@class NewsBlurAppDelegate;
@interface AddSiteViewController : BaseViewController
<UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource> {
NewsBlurAppDelegate *appDelegate;
}
<UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource>
- (void)reload;
- (IBAction)addSite;

View file

@ -8,7 +8,6 @@
#import "AddSiteViewController.h"
#import "AddSiteAutocompleteCell.h"
#import "NewsBlurAppDelegate.h"
#import "MenuViewController.h"
#import "SBJson4.h"
#import "NewsBlur-Swift.h"

View file

@ -1,7 +1,13 @@
#import <UIKit/UIKit.h>
#import "MBProgressHUD.h"
@interface BaseViewController : UIViewController
@class NewsBlurAppDelegate;
@interface BaseViewController : UIViewController {
NewsBlurAppDelegate *appDelegate;
}
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic, readonly) BOOL isPhone;
@property (nonatomic, readonly) BOOL isMac;
@ -30,5 +36,19 @@
- (void)collectionView:(UICollectionView *)collectionView selectItemAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UICollectionViewScrollPosition)scrollPosition;
- (void)collectionView:(UICollectionView *)collectionView deselectItemAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated;
- (IBAction)reloadFeeds:(id)sender;
- (IBAction)showMuteSites:(id)sender;
- (IBAction)showOrganizeSites:(id)sender;
- (IBAction)showWidgetSites:(id)sender;
- (IBAction)showNotifications:(id)sender;
- (IBAction)showFindFriends:(id)sender;
- (IBAction)showPremium:(id)sender;
- (IBAction)showSupportForum:(id)sender;
- (IBAction)showLogout:(id)sender;
- (IBAction)chooseColumns:(id)sender;
- (IBAction)chooseFontSize:(id)sender;
- (IBAction)chooseSpacing:(id)sender;
- (IBAction)chooseTheme:(id)sender;
@end

View file

@ -4,17 +4,33 @@
@implementation BaseViewController
@synthesize appDelegate;
#pragma mark -
#pragma mark HTTP requests
- (instancetype)init {
if (self = [super init]) {
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
}
return self;
}
- (void)awakeFromNib {
[super awakeFromNib];
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
}
- (BOOL)becomeFirstResponder {
BOOL success = [super becomeFirstResponder];
NSLog(@"%@ becomeFirstResponder: %@", self, success ? @"yes" : @"no"); // log
return success;
}
#pragma mark -
#pragma mark View methods
@ -207,4 +223,80 @@
//return self.compactWidth > 0.0;
}
- (IBAction)reloadFeeds:(id)sender {
[appDelegate reloadFeedsView:NO];
}
- (IBAction)showMuteSites:(id)sender {
[self.appDelegate showMuteSites];
}
- (IBAction)showOrganizeSites:(id)sender {
[self.appDelegate showOrganizeSites];
}
- (IBAction)showWidgetSites:(id)sender {
[self.appDelegate showWidgetSites];
}
- (IBAction)showNotifications:(id)sender {
[self.appDelegate openNotificationsWithFeed:nil];
}
- (IBAction)showFindFriends:(id)sender {
[self.appDelegate showFindFriends];
}
- (IBAction)showPremium:(id)sender {
[self.appDelegate showPremiumDialog];
}
- (IBAction)showSupportForum:(id)sender {
NSURL *url = [NSURL URLWithString:@"https://forum.newsblur.com"];
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
}
- (IBAction)showLogout:(id)sender {
[self.appDelegate confirmLogout];
}
- (IBAction)chooseColumns:(id)sender {
UICommand *command = sender;
NSString *string = command.propertyList;
[[NSUserDefaults standardUserDefaults] setObject:string forKey:@"split_behavior"];
[UIView animateWithDuration:0.5 animations:^{
[self.appDelegate updateSplitBehavior:YES];
}];
[self.appDelegate.detailViewController updateLayoutWithReload:NO fetchFeeds:YES];
}
- (IBAction)chooseFontSize:(id)sender {
UICommand *command = sender;
NSString *string = command.propertyList;
[[NSUserDefaults standardUserDefaults] setObject:string forKey:@"feed_list_font_size"];
[self.appDelegate resizeFontSize];
}
- (IBAction)chooseSpacing:(id)sender {
UICommand *command = sender;
NSString *string = command.propertyList;
[[NSUserDefaults standardUserDefaults] setObject:string forKey:@"feed_list_spacing"];
[self.appDelegate.feedsViewController reloadFeedTitlesTable];
[self.appDelegate.feedDetailViewController reloadWithSizing];
}
- (IBAction)chooseTheme:(id)sender {
UICommand *command = sender;
NSString *string = command.propertyList;
[ThemeManager themeManager].theme = string;
}
@end

View file

@ -10,11 +10,6 @@ import UIKit
/// Manages the detail column of the split view, with the feed detail and/or the story pages.
class DetailViewController: BaseViewController {
/// Returns the shared app delegate.
var appDelegate: NewsBlurAppDelegate {
return NewsBlurAppDelegate.shared()
}
/// Preference keys.
enum Key {
/// Style of the feed detail list layout.

View file

@ -18,9 +18,7 @@ typedef NS_ENUM(NSUInteger, FeedChooserOperation)
};
@interface FeedChooserViewController : BaseViewController {
NewsBlurAppDelegate *appDelegate;
}
@interface FeedChooserViewController : BaseViewController
@property (weak) IBOutlet UITableView *tableView;

View file

@ -30,7 +30,6 @@ static const CGFloat kFolderTitleHeight = 36.0;
@property (nonatomic) FeedChooserSort sort;
@property (nonatomic) BOOL ascending;
@property (nonatomic) BOOL flat;
@property (nonatomic, readonly) NewsBlurAppDelegate *appDelegate;
@property (nonatomic, strong) NSUserDefaults *groupDefaults;
@property (nonatomic, readonly) NSArray *widgetFeeds;
@ -45,8 +44,6 @@ static const CGFloat kFolderTitleHeight = 36.0;
- (void)viewDidLoad {
[super viewDidLoad];
appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
if (self.operation == FeedChooserOperationWidgetSites) {
self.groupDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.newsblur.NewsBlur-Group"];
}

View file

@ -14,7 +14,6 @@
#import "MCSwipeTableViewCell.h"
#import "FeedDetailTableCell.h"
@class NewsBlurAppDelegate;
@class MCSwipeTableViewCell;
@interface FeedDetailObjCViewController : BaseViewController
@ -23,8 +22,6 @@
MCSwipeTableViewCellDelegate,
UIGestureRecognizerDelegate, UISearchBarDelegate,
UITableViewDragDelegate> {
NewsBlurAppDelegate *appDelegate;
BOOL pageFetching;
BOOL pageFinished;
BOOL finishedAnimatingIn;
@ -39,7 +36,6 @@
NBNotifier *notifier;
}
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic, strong) IBOutlet UITableView *storyTitlesTable;
@property (nonatomic) IBOutlet UIBarButtonItem * feedMarkReadButton;
@property (nonatomic) IBOutlet UIBarButtonItem * feedsBarButton;

View file

@ -69,7 +69,6 @@ typedef NS_ENUM(NSUInteger, FeedSection)
@synthesize separatorBarButton;
@synthesize titleImageBarButton;
@synthesize spacerBarButton, spacer2BarButton;
@synthesize appDelegate;
@synthesize pageFetching;
@synthesize pageFinished;
@synthesize finishedAnimatingIn;
@ -92,8 +91,6 @@ typedef NS_ENUM(NSUInteger, FeedSection)
- (void)viewDidLoad {
[super viewDidLoad];
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(preferredContentSizeChanged:)
name:UIContentSizeCategoryDidChangeNotification
@ -415,6 +412,11 @@ typedef NS_ENUM(NSUInteger, FeedSection)
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
#if TARGET_OS_MACCATALYST
[self.navigationController setNavigationBarHidden:YES animated:animated];
[self.navigationController setToolbarHidden:YES animated:animated];
#endif
self.appDelegate = (NewsBlurAppDelegate *)[[UIApplication sharedApplication] delegate];
if (self.standardInteractivePopGestureDelegate == nil) {
@ -2624,9 +2626,13 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
[viewController addThemeSegmentedControl];
#if TARGET_OS_MACCATALYST
//TODO: 🚧
#else
UINavigationController *navController = self.navigationController ?: appDelegate.storyPagesViewController.navigationController;
[viewController showFromNavigationController:navController barButtonItem:self.settingsBarButton];
#endif
}
- (NSString *)feedIdForSearch {

View file

@ -21,8 +21,6 @@ static enum {
NewsBlurTopSectionAllStories = 1
} NewsBlurTopSection;
@class NewsBlurAppDelegate;
@interface FeedsObjCViewController : BaseViewController
<UITableViewDelegate, UITableViewDataSource,
NSCacheDelegate,
@ -30,8 +28,6 @@ UIPopoverControllerDelegate,
IASKSettingsDelegate,
MCSwipeTableViewCellDelegate,
UIGestureRecognizerDelegate, UISearchBarDelegate> {
NewsBlurAppDelegate *appDelegate;
NSMutableDictionary * activeFeedLocations;
NSMutableDictionary *stillVisibleFeeds;
NSMutableDictionary *visibleFolders;
@ -53,7 +49,6 @@ UIGestureRecognizerDelegate, UISearchBarDelegate> {
NBNotifier *notifier;
}
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) IBOutlet UIView *innerView;
@property (nonatomic) IBOutlet UITableView *feedTitlesTable;
@property (nonatomic) IBOutlet NSLayoutConstraint *feedTitlesTopConstraint;
@ -103,20 +98,7 @@ UIGestureRecognizerDelegate, UISearchBarDelegate> {
- (void)didSelectSectionHeaderWithTag:(NSInteger)tag;
- (void)selectNextFolderOrFeed;
- (IBAction)reloadFeeds:(id)sender;
- (IBAction)selectIntelligence;
- (IBAction)showMuteSites:(id)sender;
- (IBAction)showOrganizeSites:(id)sender;
- (IBAction)showWidgetSites:(id)sender;
- (IBAction)showNotifications:(id)sender;
- (IBAction)showFindFriends:(id)sender;
- (IBAction)showPremium:(id)sender;
- (IBAction)showSupportForum:(id)sender;
- (IBAction)showLogout:(id)sender;
- (IBAction)chooseColumns:(id)sender;
- (IBAction)chooseFontSize:(id)sender;
- (IBAction)chooseSpacing:(id)sender;
- (IBAction)chooseTheme:(id)sender;
- (void)markFeedRead:(NSString *)feedId cutoffDays:(NSInteger)days;
- (void)markFeedsRead:(NSArray *)feedIds cutoffDays:(NSInteger)days;

View file

@ -57,7 +57,6 @@ static NSArray<NSString *> *NewsBlurTopSectionNames;
@implementation FeedsObjCViewController
@synthesize appDelegate;
@synthesize feedTitlesTable;
@synthesize feedViewToolbar;
@synthesize feedScoreSlider;
@ -254,6 +253,9 @@ static NSArray<NSString *> *NewsBlurTopSectionNames;
UITitlebar *titlebar = navController.navigationBar.window.windowScene.titlebar;
titlebar.titleVisibility = UITitlebarTitleVisibilityHidden;
[self.navigationController setNavigationBarHidden:YES animated:animated];
[self.navigationController setToolbarHidden:YES animated:animated];
#endif
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
@ -2731,10 +2733,6 @@ heightForHeaderInSection:(NSInteger)section {
}
#endif
- (IBAction)reloadFeeds:(id)sender {
[appDelegate reloadFeedsView:NO];
}
- (void)finishRefresh {
self.inPullToRefresh_ = NO;
#if !TARGET_OS_MACCATALYST
@ -2869,78 +2867,6 @@ heightForHeaderInSection:(NSInteger)section {
// return YES;
//}
- (IBAction)showMuteSites:(id)sender {
[self.appDelegate showMuteSites];
}
- (IBAction)showOrganizeSites:(id)sender {
[self.appDelegate showOrganizeSites];
}
- (IBAction)showWidgetSites:(id)sender {
[self.appDelegate showWidgetSites];
}
- (IBAction)showNotifications:(id)sender {
[self.appDelegate openNotificationsWithFeed:nil];
}
- (IBAction)showFindFriends:(id)sender {
[self.appDelegate showFindFriends];
}
- (IBAction)showPremium:(id)sender {
[self.appDelegate showPremiumDialog];
}
- (IBAction)showSupportForum:(id)sender {
NSURL *url = [NSURL URLWithString:@"https://forum.newsblur.com"];
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
}
- (IBAction)showLogout:(id)sender {
[self.appDelegate confirmLogout];
}
- (IBAction)chooseColumns:(id)sender {
UICommand *command = sender;
NSString *string = command.propertyList;
[[NSUserDefaults standardUserDefaults] setObject:string forKey:@"split_behavior"];
[UIView animateWithDuration:0.5 animations:^{
[self.appDelegate updateSplitBehavior:YES];
}];
[self.appDelegate.detailViewController updateLayoutWithReload:NO fetchFeeds:YES];
}
- (IBAction)chooseFontSize:(id)sender {
UICommand *command = sender;
NSString *string = command.propertyList;
[[NSUserDefaults standardUserDefaults] setObject:string forKey:@"feed_list_font_size"];
[self.appDelegate resizeFontSize];
}
- (IBAction)chooseSpacing:(id)sender {
UICommand *command = sender;
NSString *string = command.propertyList;
[[NSUserDefaults standardUserDefaults] setObject:string forKey:@"feed_list_spacing"];
[self reloadFeedTitlesTable];
[self.appDelegate.feedDetailViewController reloadWithSizing];
}
- (IBAction)chooseTheme:(id)sender {
UICommand *command = sender;
NSString *string = command.propertyList;
[ThemeManager themeManager].theme = string;
}
- (void)resetToolbar {
// self.navigationItem.leftBarButtonItem = nil;
self.navigationItem.titleView = nil;

View file

@ -11,11 +11,8 @@
#import "NewsBlurAppDelegate.h"
#import "NewsBlur-Swift.h"
@interface FirstTimeUserAddFriendsViewController : BaseViewController {
NewsBlurAppDelegate *appDelegate;
}
@interface FirstTimeUserAddFriendsViewController : BaseViewController
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) IBOutlet UIBarButtonItem *nextButton;
@property (weak, nonatomic) IBOutlet UIButton *facebookButton;
@property (weak, nonatomic) IBOutlet UIButton *twitterButton;

View file

@ -16,7 +16,6 @@
@implementation FirstTimeUserAddFriendsViewController
@synthesize appDelegate;
@synthesize nextButton;
@synthesize facebookButton;
@synthesize twitterButton;
@ -36,8 +35,6 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
UIBarButtonItem *next = [[UIBarButtonItem alloc] initWithTitle:@"Skip this step" style:UIBarButtonItemStyleDone target:self action:@selector(tapNextButton)];
self.nextButton = next;
self.navigationItem.rightBarButtonItem = next;

View file

@ -9,11 +9,8 @@
#import <UIKit/UIKit.h>
#import "NewsBlurAppDelegate.h"
@interface FirstTimeUserAddNewsBlurViewController : BaseViewController {
NewsBlurAppDelegate *appDelegate;
}
@interface FirstTimeUserAddNewsBlurViewController : BaseViewController
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) IBOutlet UIBarButtonItem *nextButton;
@property (strong, nonatomic) IBOutlet UILabel *instructionsLabel;

View file

@ -11,7 +11,6 @@
@implementation FirstTimeUserAddNewsBlurViewController
@synthesize appDelegate;
@synthesize nextButton;
@synthesize instructionsLabel;
@ -27,8 +26,6 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
UIBarButtonItem *next = [[UIBarButtonItem alloc] initWithTitle:@"Start reading" style:UIBarButtonItemStyleDone target:self action:@selector(tapNextButton)];
self.nextButton = next;
self.navigationItem.rightBarButtonItem = next;

View file

@ -10,11 +10,8 @@
#import "NewsBlurAppDelegate.h"
@interface FirstTimeUserAddSitesViewController : BaseViewController
<UITableViewDataSource, UITableViewDelegate> {
NewsBlurAppDelegate *appDelegate;
}
<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) IBOutlet UIButton *googleReaderButton;
@property (nonatomic) IBOutlet UIView *googleReaderButtonWrapper;
@property (nonatomic) IBOutlet UIBarButtonItem *nextButton;

View file

@ -24,7 +24,6 @@
@implementation FirstTimeUserAddSitesViewController
@synthesize appDelegate;
@synthesize googleReaderButton;
@synthesize nextButton;
@synthesize activityIndicator;
@ -50,8 +49,6 @@
[super viewDidLoad];
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
UIBarButtonItem *next = [[UIBarButtonItem alloc] initWithTitle:@"Next step" style:UIBarButtonItemStyleDone target:self action:@selector(tapNextButton)];
self.nextButton = next;
self.nextButton.enabled = YES;

View file

@ -13,7 +13,6 @@
@class NewsBlurAppDelegate;
@interface FriendsListViewController : BaseViewController <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate> {
NewsBlurAppDelegate *appDelegate;
UISearchBar *friendSearchBar;
UITableView *friendsTable;
NSArray *suggestedUserProfiles;
@ -21,7 +20,6 @@
NSArray *userProfileIds;
}
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) IBOutlet UISearchBar *friendSearchBar;
@property (nonatomic) IBOutlet UITableView *friendsTable;

View file

@ -27,7 +27,6 @@
@implementation FriendsListViewController
@synthesize appDelegate;
@synthesize friendSearchBar;
@synthesize friendsTable;
@synthesize suggestedUserProfiles;
@ -45,8 +44,6 @@
{
[super viewDidLoad];
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
self.navigationItem.title = @"Find Friends";
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle: @"Done"
style: UIBarButtonItemStylePlain

View file

@ -12,8 +12,6 @@
#define LANDSCAPE_MARGIN 128
@interface LoginViewController : BaseViewController {
NewsBlurAppDelegate *appDelegate;
BOOL isOnSignUpScreen;
UITextField *usernameInput;
UITextField *passwordInput;
@ -46,8 +44,6 @@
- (void)animateLoop;
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) IBOutlet UITextField *usernameInput;
@property (nonatomic) IBOutlet UITextField *passwordInput;
@property (nonatomic) IBOutlet UITextField *emailInput;

View file

@ -12,7 +12,6 @@
@implementation LoginViewController
@synthesize appDelegate;
@synthesize usernameInput;
@synthesize passwordInput;
@synthesize emailInput;
@ -44,8 +43,6 @@
}
- (void)viewDidLoad {
self.appDelegate = NewsBlurAppDelegate.sharedAppDelegate;
self.usernameInput.borderStyle = UITextBorderStyleRoundedRect;
self.passwordInput.borderStyle = UITextBorderStyleRoundedRect;
self.emailInput.borderStyle = UITextBorderStyleRoundedRect;

View file

@ -7,11 +7,12 @@
//
#import <UIKit/UIKit.h>
#import "BaseViewController.h"
typedef void (^MenuItemHandler)(void);
typedef void (^MenuItemSegmentedHandler)(NSUInteger selectedIndex);
@interface MenuViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@interface MenuViewController : BaseViewController <UITableViewDataSource, UITableViewDelegate>
@property (weak) IBOutlet UITableView *menuTableView;

View file

@ -9,16 +9,12 @@
#import <UIKit/UIKit.h>
#import "NewsBlurAppDelegate.h"
@class NewsBlurAppDelegate;
@interface FolderTextField : UITextField
@end
@interface MoveSiteViewController : BaseViewController
<UITextFieldDelegate, UIPickerViewDelegate, UIPickerViewDataSource> {
NewsBlurAppDelegate *appDelegate;
}
<UITextFieldDelegate, UIPickerViewDelegate, UIPickerViewDataSource>
- (void)reload;
- (IBAction)moveSite;
@ -27,7 +23,6 @@
- (IBAction)doMoveButton;
- (NSArray *)pickerFolders;
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) IBOutlet UITextField *fromFolderInput;
@property (nonatomic) IBOutlet FolderTextField *toFolderInput;
@property (nonatomic) IBOutlet UILabel *titleLabel;

View file

@ -7,13 +7,11 @@
//
#import "MoveSiteViewController.h"
#import "NewsBlurAppDelegate.h"
#import "StringHelper.h"
#import "StoriesCollection.h"
@implementation MoveSiteViewController
@synthesize appDelegate;
@synthesize toFolderInput;
@synthesize fromFolderInput;
@synthesize titleLabel;
@ -34,8 +32,6 @@
}
- (void)viewDidLoad {
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
UIImageView *folderImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"folder-open"]];
folderImage.frame = CGRectMake(0, 0, 24, 16);
[folderImage setContentMode:UIViewContentModeRight];
@ -54,8 +50,6 @@
frame.size.height += 20;
self.navBar.frame = frame;
appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
[super viewDidLoad];
}

View file

@ -1173,6 +1173,7 @@
#pragma mark View Management
- (void)prepareViewControllers {
self.appDelegate = self;
self.splitViewController = (SplitViewController *)self.window.rootViewController;
NSArray <UIViewController *> *splitChildren = self.splitViewController.viewControllers;
@ -2398,8 +2399,11 @@
self.safariViewController = [[SFSafariViewController alloc] initWithURL:url configuration:config];
self.safariViewController.delegate = self;
#if TARGET_OS_MACCATALYST
#else
[self.storyPagesViewController setNavigationBarHidden:NO];
[feedsNavigationController presentViewController:self.safariViewController animated:YES completion:nil];
#endif
}
- (BOOL)showingSafariViewController {
@ -3350,7 +3354,7 @@
[self.navigationControllerForPopover presentViewController:viewController animated:YES completion:^{
popoverPresentationController.passthroughViews = nil;
// NSLog(@"%@ canBecomeFirstResponder? %d", viewController, viewController.canBecomeFirstResponder);
[viewController becomeFirstResponder];
// [viewController becomeFirstResponder];
}];
}

View file

@ -13,11 +13,9 @@
@class NewsBlurAppDelegate;
@interface NotificationsViewController : BaseViewController <UITableViewDelegate, UITableViewDataSource> {
NewsBlurAppDelegate *appDelegate;
NSArray *notificationFeedIds;
}
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) IBOutlet UITableView *notificationsTable;
@property (nonatomic) NSString *feedId;

View file

@ -16,14 +16,11 @@
@implementation NotificationsViewController
@synthesize notificationsTable;
@synthesize appDelegate;
@synthesize feedId;
- (void)viewDidLoad {
[super viewDidLoad];
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
self.navigationItem.title = @"Notifications";
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle: @"Done"
style: UIBarButtonItemStylePlain
@ -31,9 +28,6 @@
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;

View file

@ -10,13 +10,10 @@
#import "BaseViewController.h"
#import <WebKit/WebKit.h>
@class NewsBlurAppDelegate;
@interface OriginalStoryViewController : BaseViewController
<UITextFieldDelegate, WKNavigationDelegate, WKUIDelegate,
UIGestureRecognizerDelegate> {
NewsBlurAppDelegate *appDelegate;
NSString *activeUrl;
NSMutableArray *visitedUrls;
WKWebView *webView;
@ -27,7 +24,6 @@ UIGestureRecognizerDelegate> {
BOOL finishedLoading;
}
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) IBOutlet WKWebView *webView;
//@property (strong, nonatomic) SloppySwiper *swiper;
@property (nonatomic) UIProgressView *progressView;

View file

@ -17,7 +17,6 @@
@implementation OriginalStoryViewController
@synthesize appDelegate;
@synthesize webView;
//@synthesize swiper;
@synthesize progressView;
@ -25,8 +24,6 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
self.view.layer.masksToBounds = NO;
self.view.layer.shadowRadius = 5;
self.view.layer.shadowOpacity = 0.5;

View file

@ -14,7 +14,6 @@
@interface PremiumViewController : BaseViewController <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) IBOutlet UITableView *premiumTable;

View file

@ -24,8 +24,6 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle: @"Done"
style: UIBarButtonItemStylePlain
target: self

View file

@ -12,9 +12,26 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
let appDelegate: NewsBlurAppDelegate = .shared
var window: UIWindow?
#if targetEnvironment(macCatalyst)
var toolbar = NSToolbar(identifier: "main")
var toolbarDelegate = ToolbarDelegate()
#endif
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
appDelegate.window = window
#if targetEnvironment(macCatalyst)
guard let windowScene = scene as? UIWindowScene, let titlebar = windowScene.titlebar else {
return
}
toolbar.delegate = toolbarDelegate
toolbar.displayMode = .iconOnly
titlebar.toolbar = toolbar
titlebar.toolbarStyle = .automatic
#endif
appDelegate.prepareViewControllers()
}
}

View file

@ -15,7 +15,6 @@
}
@property (nonatomic) IBOutlet UITextView *commentField;
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) IBOutlet UIButton *facebookButton;
@property (nonatomic) IBOutlet UIButton *twitterButton;
@property (nonatomic) IBOutlet UIBarButtonItem *submitButton;

View file

@ -21,7 +21,6 @@
@synthesize twitterButton;
@synthesize submitButton;
@synthesize commentField;
@synthesize appDelegate;
@synthesize activeReplyId;
@synthesize activeCommentId;
@synthesize activeStoryId;
@ -38,9 +37,7 @@
}
- (void)viewDidLoad {
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
[[NSNotificationCenter defaultCenter]
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(onTextChange:)
name:UITextViewTextDidChangeNotification

View file

@ -24,4 +24,10 @@ class SplitViewController: UISplitViewController {
override var childForStatusBarStyle: UIViewController? {
return nil
}
// Can do menu validation here.
// override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
// print("canPerformAction: \(action) with \(sender ?? "nil")")
// return true
// }
}

View file

@ -11,13 +11,9 @@
#import "BaseViewController.h"
@import WebKit;
@class NewsBlurAppDelegate;
@interface StoryDetailObjCViewController : BaseViewController
<UIScrollViewDelegate, UIGestureRecognizerDelegate,
UIActionSheetDelegate, WKNavigationDelegate> {
NewsBlurAppDelegate *appDelegate;
NSString *activeStoryId;
NSMutableDictionary *activeStory;
UIView *innerView;
@ -34,7 +30,6 @@ UIActionSheetDelegate, WKNavigationDelegate> {
UIInterfaceOrientation _orientation;
}
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) NSString *activeStoryId;
@property (nonatomic, readwrite) NSMutableDictionary *activeStory;
@property (nonatomic) IBOutlet UIView *innerView;

View file

@ -35,7 +35,6 @@
@implementation StoryDetailObjCViewController
@synthesize appDelegate;
@synthesize activeStoryId;
@synthesize activeStory;
@synthesize innerView;
@ -71,8 +70,6 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
@ -314,6 +311,11 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
#if TARGET_OS_MACCATALYST
[self.navigationController setNavigationBarHidden:YES animated:animated];
[self.navigationController setToolbarHidden:YES animated:animated];
#endif
if (!self.isPhoneOrCompact) {
[appDelegate.feedDetailViewController.view endEditing:YES];
}
@ -1421,6 +1423,7 @@
}
}
#if !TARGET_OS_MACCATALYST
if (!isNavBarHidden && self.canHideNavigationBar && !nearTop) {
[appDelegate.storyPagesViewController setNavigationBarHidden:YES];
}
@ -1428,6 +1431,7 @@
if (isNavBarHidden && pullingDown) {
[appDelegate.storyPagesViewController setNavigationBarHidden:NO];
}
#endif
if (!atTop && !atBottom && !singlePage) {
BOOL traversalVisible = appDelegate.storyPagesViewController.traverseView.alpha > 0;

View file

@ -16,7 +16,6 @@
@interface StoryPagesObjCViewController : BaseViewController
<UIScrollViewDelegate, UIPopoverControllerDelegate, UIPopoverPresentationControllerDelegate, UIGestureRecognizerDelegate> {
NewsBlurAppDelegate *appDelegate;
THCircularProgressView *circularProgressView;
UIButton *buttonPrevious;
UIButton *buttonNext;
@ -37,7 +36,6 @@
CGFloat scrollPct;
}
@property (nonatomic, strong) NewsBlurAppDelegate *appDelegate;
@property (nonatomic) StoryDetailViewController *currentPage;
@property (nonatomic) StoryDetailViewController *nextPage;
@property (nonatomic) StoryDetailViewController *previousPage;

View file

@ -36,7 +36,6 @@
@implementation StoryPagesObjCViewController
@synthesize appDelegate;
@synthesize currentPage, nextPage, previousPage;
@synthesize circularProgressView;
@synthesize separatorBarButton;
@ -76,7 +75,6 @@
- (void)viewDidLoad {
[super viewDidLoad];
appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
currentPage = [[StoryDetailViewController alloc]
initWithNibName:@"StoryDetailViewController"
bundle:nil];
@ -251,6 +249,11 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
#if TARGET_OS_MACCATALYST
[self.navigationController setNavigationBarHidden:YES animated:animated];
[self.navigationController setToolbarHidden:YES animated:animated];
#endif
[self updateTheme];
[self updateAutoscrollButtons];
@ -390,7 +393,10 @@
previousPage.view.hidden = YES;
appDelegate.detailViewController.parentNavigationController.interactivePopGestureRecognizer.enabled = YES;
#if !TARGET_OS_MACCATALYST
[appDelegate.detailViewController.parentNavigationController setNavigationBarHidden:NO animated:YES];
#endif
self.autoscrollActive = NO;
}
@ -484,7 +490,7 @@
}
- (void)setNavigationBarHidden:(BOOL)hide alsoTraverse:(BOOL)alsoTraverse {
if (self.navigationController == nil || self.navigationController.navigationBarHidden == hide || self.currentlyTogglingNavigationBar) {
if (appDelegate.isMac || self.navigationController == nil || self.navigationController.navigationBarHidden == hide || self.currentlyTogglingNavigationBar) {
return;
}

View file

@ -0,0 +1,71 @@
//
// ToolbarDelegate.swift
// NewsBlur
//
// Created by David Sinclair on 2024-01-05.
// Copyright © 2024 NewsBlur. All rights reserved.
//
import UIKit
#if targetEnvironment(macCatalyst)
class ToolbarDelegate: NSObject {
}
extension NSToolbarItem.Identifier {
static let reloadFeeds = NSToolbarItem.Identifier("com.newsblur.reloadFeeds")
static let feedDetailSettings = NSToolbarItem.Identifier("com.newsblur.feedDetailSettings")
}
extension ToolbarDelegate: NSToolbarDelegate {
func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
let identifiers: [NSToolbarItem.Identifier] = [
.toggleSidebar,
.reloadFeeds,
.flexibleSpace,
.feedDetailSettings
]
return identifiers
}
func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
return toolbarDefaultItemIdentifiers(toolbar)
}
func toolbar(_ toolbar: NSToolbar,
itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier,
willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? {
switch itemIdentifier {
case .reloadFeeds:
return makeToolbarItem(itemIdentifier,
image: UIImage(systemName: "arrow.clockwise"),
label: "Reload Sites",
action: #selector(BaseViewController.reloadFeeds(_:)))
case .feedDetailSettings:
return makeToolbarItem(itemIdentifier,
image: Utilities.imageNamed("settings", sized: 24),
label: "Site Settings",
action: #selector(FeedDetailViewController.doOpenSettingsMenu(_:)))
default:
return nil
}
}
func makeToolbarItem(_ identifier: NSToolbarItem.Identifier,
image: UIImage?,
label: String,
action: Selector,
target: AnyObject? = nil) -> NSToolbarItem {
let item = NSToolbarItem(itemIdentifier: identifier)
item.image = image
item.label = label
item.action = action
item.target = target
return item
}
}
#endif

View file

@ -22,8 +22,6 @@
@interface TrainerViewController : BaseViewController <WKNavigationDelegate> {
NewsBlurAppDelegate *appDelegate;
IBOutlet UIBarButtonItem * closeButton;
TrainerWebView *webView;
IBOutlet UINavigationBar *navBar;
@ -33,7 +31,6 @@
BOOL storyTrainer;
}
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) IBOutlet UIBarButtonItem *closeButton;
@property (nonatomic) IBOutlet TrainerWebView *webView;
@property (nonatomic) IBOutlet UINavigationBar *navBar;

View file

@ -17,7 +17,6 @@
@synthesize closeButton;
@synthesize webView;
@synthesize navBar;
@synthesize appDelegate;
@synthesize feedTrainer;
@synthesize storyTrainer;
@synthesize feedLoaded;
@ -35,8 +34,6 @@
{
[super viewDidLoad];
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
UIBarButtonItem *done = [[UIBarButtonItem alloc]
initWithTitle:@"Done Training"
style:UIBarButtonItemStyleDone

View file

@ -10,13 +10,10 @@
#import "NewsBlurAppDelegate.h"
#import "NewsBlur-Swift.h"
@class NewsBlurAppDelegate;
@class ProfileBadge;
@interface UserProfileViewController : BaseViewController
<UITableViewDataSource, UITableViewDelegate> {
NewsBlurAppDelegate *appDelegate;
UILabel *followingCount;
UILabel *followersCount;
ProfileBadge *profileBadge;
@ -26,7 +23,6 @@
NSDictionary *userProfile;
}
@property (nonatomic) NewsBlurAppDelegate *appDelegate;
@property (nonatomic) ProfileBadge *profileBadge;
@property (nonatomic) UITableView *profileTable;
@property (nonatomic) NSArray *activitiesArray;

View file

@ -17,7 +17,6 @@
@implementation UserProfileViewController
@synthesize appDelegate;
@synthesize profileBadge;
@synthesize profileTable;
@synthesize activitiesArray;
@ -40,9 +39,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.appDelegate = (NewsBlurAppDelegate *)[[UIApplication sharedApplication] delegate];
UITableView *profiles = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
self.profileTable = profiles;
self.profileTable.dataSource = self;
@ -89,7 +86,6 @@
// self.view.frame = self.view.bounds;
self.preferredContentSize = CGSizeMake(320, 454);
self.appDelegate = (NewsBlurAppDelegate *)[[UIApplication sharedApplication] delegate];
[MBProgressHUD hideHUDForView:self.view animated:YES];
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
HUD.labelText = @"Profiling...";

View file

@ -753,6 +753,8 @@
1788939D249332E6004CBA4E /* g_icn_search.png in Resources */ = {isa = PBXBuildFile; fileRef = 1788939C249332E6004CBA4E /* g_icn_search.png */; };
1791C21526C4C7BC00D815AA /* WidgetStoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1791C21426C4C7BC00D815AA /* WidgetStoryView.swift */; };
17997C5827A8FDD100483E69 /* WidgetDebugTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17997C5727A8FDD100483E69 /* WidgetDebugTimer.swift */; };
179A88022B48E64A00916CF4 /* ToolbarDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179A88012B48E64900916CF4 /* ToolbarDelegate.swift */; };
179A88032B48E64A00916CF4 /* ToolbarDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179A88012B48E64900916CF4 /* ToolbarDelegate.swift */; };
179DD9CF23DFDD51007BFD21 /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 179DD9CE23DFDD51007BFD21 /* CloudKit.framework */; };
17A396D924F86A8F0023C9E2 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 17A396D824F86A8F0023C9E2 /* MainInterface.storyboard */; };
17A92A3C289B7C6B00AB0A78 /* saved-stories@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 17A92A3B289B7C6B00AB0A78 /* saved-stories@2x.png */; };
@ -1534,6 +1536,7 @@
1788939C249332E6004CBA4E /* g_icn_search.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = g_icn_search.png; sourceTree = "<group>"; };
1791C21426C4C7BC00D815AA /* WidgetStoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetStoryView.swift; sourceTree = "<group>"; };
17997C5727A8FDD100483E69 /* WidgetDebugTimer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetDebugTimer.swift; sourceTree = "<group>"; };
179A88012B48E64900916CF4 /* ToolbarDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolbarDelegate.swift; sourceTree = "<group>"; };
179DD9CC23DFD20E007BFD21 /* BridgingHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = BridgingHeader.h; path = "Other Sources/BridgingHeader.h"; sourceTree = "<group>"; };
179DD9CE23DFDD51007BFD21 /* CloudKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CloudKit.framework; path = System/Library/Frameworks/CloudKit.framework; sourceTree = SDKROOT; };
17A396D824F86A8F0023C9E2 /* MainInterface.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = MainInterface.storyboard; sourceTree = "<group>"; };
@ -3329,6 +3332,7 @@
1D3623240D0F684500981E51 /* NewsBlurAppDelegate.h */,
1D3623250D0F684500981E51 /* NewsBlurAppDelegate.m */,
17150E1D2B05775A004D5309 /* SceneDelegate.swift */,
179A88012B48E64900916CF4 /* ToolbarDelegate.swift */,
FFD1D72F1459B63500E46F89 /* BaseViewController.h */,
FFD1D7301459B63500E46F89 /* BaseViewController.m */,
17C074941C14C46B00CFCDB7 /* ThemeManager.h */,
@ -5026,6 +5030,7 @@
1757926D2930605500490924 /* UserTagsViewController.m in Sources */,
1757926E2930605500490924 /* StringHelper.m in Sources */,
1757926F2930605500490924 /* TransparentToolbar.m in Sources */,
179A88032B48E64A00916CF4 /* ToolbarDelegate.swift in Sources */,
175792702930605500490924 /* THCircularProgressView.m in Sources */,
175792712930605500490924 /* IASKSpecifier.m in Sources */,
175792722930605500490924 /* UIView+ViewController.m in Sources */,
@ -5226,6 +5231,7 @@
FF6282151A11613900271FDB /* UserTagsViewController.m in Sources */,
43A4C3E315B00966008787B5 /* StringHelper.m in Sources */,
43A4C3E415B00966008787B5 /* TransparentToolbar.m in Sources */,
179A88022B48E64A00916CF4 /* ToolbarDelegate.swift in Sources */,
FFD6604C1BACA45D006E4B8D /* THCircularProgressView.m in Sources */,
FF34FD681E9D93CB0062F8ED /* IASKSpecifier.m in Sources */,
FFA0484419CA73B700618DC4 /* UIView+ViewController.m in Sources */,

View file

@ -267,7 +267,7 @@
<command title="Reload Sites" input="r" id="9ee-Z4-HxV">
<keyModifierFlags key="modifierFlags" command="YES"/>
<connections>
<action selector="reloadFeeds:" destination="J28-e1-gcC" id="Ry7-2F-Wl3"/>
<action selector="reloadFeeds:" destination="J28-e1-gcC" id="Mn6-7w-6qY"/>
</connections>
</command>
</children>