Skip to content

Commit

Permalink
#1247 (Mac Catalyst edition)
Browse files Browse the repository at this point in the history
- Migrated to modern window scene support.
- Customized the menu bar, with Theme submenu, and new Site and Story menus (some items not implemented yet).
  • Loading branch information
Dejal committed Nov 16, 2023
1 parent b4c4aa5 commit f316f39
Show file tree
Hide file tree
Showing 20 changed files with 283 additions and 51 deletions.
10 changes: 6 additions & 4 deletions clients/ios/Classes/FeedDetailObjCViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@
- (IBAction)doOpenSettingsMenu:(id)sender;
- (void)deleteSite;
- (void)deleteFolder;
- (void)muteSite;
- (void)openTrainSite;
- (IBAction)muteSite;
- (IBAction)openTrainSite;
- (IBAction)openNotifications:(id)sender;
- (void)openNotificationsWithFeed:(NSString *)feedId;
- (void)openRenameSite;
- (IBAction)openStatistics:(id)sender;
- (IBAction)openRenameSite;
- (void)showUserProfile;
- (void)changeActiveFeedDetailRow;
- (void)instafetchFeed;
- (IBAction)instafetchFeed;
- (void)changeActiveStoryTitleCellLayout;
- (void)didSelectItemAtIndexPath:(NSIndexPath *)indexPath;
- (void)loadFaviconsFromActiveFeed;
Expand Down
20 changes: 16 additions & 4 deletions clients/ios/Classes/FeedDetailObjCViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -2824,7 +2824,7 @@ - (void)deleteFolder {
}];
}

- (void)muteSite {
- (IBAction)muteSite {
[MBProgressHUD hideHUDForView:self.view animated:YES];
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
HUD.labelText = @"Muting...";
Expand Down Expand Up @@ -2977,7 +2977,7 @@ - (void)openMoveView:(UINavigationController *)menuNavigationController {
[menuNavigationController showViewController:viewController sender:self];
}

- (void)openTrainSite {
- (IBAction)openTrainSite {
[appDelegate openTrainSite];
}

Expand All @@ -2987,15 +2987,27 @@ - (void)toggleHiddenStories {
[self reload];
}

- (IBAction)openNotifications:(id)sender {
NSString *feedId = [self.appDelegate.storiesCollection.activeFeed objectForKey:@"id"];

[appDelegate openNotificationsWithFeed:feedId];
}

- (void)openNotificationsWithFeed:(NSString *)feedId {
[appDelegate openNotificationsWithFeed:feedId];
}

- (IBAction)openStatistics:(id)sender {
NSString *feedId = [self.appDelegate.storiesCollection.activeFeed objectForKey:@"id"];

[appDelegate openStatisticsWithFeed:feedId sender:settingsBarButton];
}

- (void)openStatisticsWithFeed:(NSString *)feedId {
[appDelegate openStatisticsWithFeed:feedId sender:settingsBarButton];
}

- (void)openRenameSite {
- (IBAction)openRenameSite {
NSString *title = [NSString stringWithFormat:@"Rename \"%@\"", appDelegate.storiesCollection.isRiverView ?
[appDelegate extractFolderName:appDelegate.storiesCollection.activeFolder] : [appDelegate.storiesCollection.activeFeed objectForKey:@"feed_title"]];
NSString *subtitle = (appDelegate.storiesCollection.isRiverView ?
Expand Down Expand Up @@ -3147,7 +3159,7 @@ - (void)failedMarkAsUnread:(NSDictionary *)params {

// called when the user taps refresh button

- (void)instafetchFeed {
- (IBAction)instafetchFeed {
NSString *urlString = [NSString
stringWithFormat:@"%@/reader/refresh_feed/%@",
self.appDelegate.url,
Expand Down
2 changes: 2 additions & 0 deletions clients/ios/Classes/FeedsObjCViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ UIGestureRecognizerDelegate, UISearchBarDelegate> {
- (void)didSelectSectionHeader:(UIButton *)button;
- (void)didSelectSectionHeaderWithTag:(NSInteger)tag;
- (void)selectNextFolderOrFeed;
- (IBAction)reloadFeeds:(id)sender;
- (IBAction)selectIntelligence;
- (IBAction)chooseTheme:(id)sender;
- (void)markFeedRead:(NSString *)feedId cutoffDays:(NSInteger)days;
- (void)markFeedsRead:(NSArray *)feedIds cutoffDays:(NSInteger)days;
- (void)markEverythingReadWithDays:(NSInteger)days;
Expand Down
11 changes: 11 additions & 0 deletions clients/ios/Classes/FeedsObjCViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -2727,6 +2727,10 @@ - (void)refresh:(UIRefreshControl *)refreshControl {
}
#endif

- (IBAction)reloadFeeds:(id)sender {
[appDelegate reloadFeedsView:NO];
}

- (void)finishRefresh {
self.inPullToRefresh_ = NO;
#if !TARGET_OS_MACCATALYST
Expand Down Expand Up @@ -2856,6 +2860,13 @@ - (void)finishRefreshingFeedList:(NSDictionary *)results feedId:(NSString *)feed
});
}

- (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;
Expand Down
1 change: 1 addition & 0 deletions clients/ios/Classes/NewsBlurAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ SFSafariViewControllerDelegate> {

- (void)registerDefaultsFromSettingsBundle;
- (void)finishBackground;
- (void)prepareViewControllers;

- (void)showFirstTimeUser;
- (void)showLogin;
Expand Down
30 changes: 7 additions & 23 deletions clients/ios/Classes/NewsBlurAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -202,25 +202,10 @@ + (instancetype)shared {
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self registerDefaultsFromSettingsBundle];

// CATALYST: this is now handled by the storyboard.
// self.navigationController.delegate = self;
// self.navigationController.viewControllers = [NSArray arrayWithObject:self.feedsViewController];
self.storiesCollection = [StoriesCollection new];

// if ([[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPhond) {
// self.window.rootViewController = self.masterContainerViewController;
// } else {
// self.window.rootViewController = self.navigationController;
// }

[self prepareViewControllers];

[self clearNetworkManager];

[window makeKeyAndVisible];

[[ThemeManager themeManager] prepareForWindow:self.window];

[self createDatabaseConnection];

cachedFavicons = [[PINCache alloc] initWithName:@"NBFavicons"];
Expand All @@ -236,8 +221,6 @@ - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:
// Uncomment below line to test image caching
// [[NSURLCache sharedURLCache] removeAllCachedResponses];

[feedsViewController view];
[feedsViewController loadOfflineFeeds:NO];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
(unsigned long)NULL), ^(void) {
[self setupReachability];
Expand All @@ -249,8 +232,6 @@ - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:
}
});

// [self showFirstTimeUser];

return YES;
}

Expand Down Expand Up @@ -424,10 +405,6 @@ - (BOOL)handleShortcutItem:(UIApplicationShortcutItem *)shortcutItem {
return handled;
}

- (void)buildMenuWithBuilder:(id<UIMenuBuilder>)builder {

}

- (void)delayedAddSite {
[self.feedsViewController tapAddSite:self];
}
Expand Down Expand Up @@ -1221,6 +1198,13 @@ - (void)prepareViewControllers {
self.firstTimeUserAddNewsBlurViewController = [FirstTimeUserAddNewsBlurViewController new];

[self updateSplitBehavior:NO];

[window makeKeyAndVisible];

[[ThemeManager themeManager] prepareForWindow:self.window];

[feedsViewController view];
[feedsViewController loadOfflineFeeds:NO];
}

- (StoryPagesViewController *)storyPagesViewController {
Expand Down
20 changes: 20 additions & 0 deletions clients/ios/Classes/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// SceneDelegate.swift
// NewsBlur
//
// Created by David Sinclair on 2023-11-15.
// Copyright © 2023 NewsBlur. All rights reserved.
//

import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
let appDelegate: NewsBlurAppDelegate = .shared

var window: UIWindow?

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
appDelegate.window = window
appDelegate.prepareViewControllers()
}
}
5 changes: 5 additions & 0 deletions clients/ios/Classes/StoryPagesObjCViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@
- (IBAction)tapProgressBar:(id)sender;
- (IBAction)toggleTextView:(id)sender;

- (IBAction)toggleStorySaved:(id)sender;
- (IBAction)toggleStoryUnread:(id)sender;
- (IBAction)showTrain:(id)sender;
- (IBAction)showShare:(id)sender;

- (void)finishMarkAsSaved:(NSDictionary *)params;
- (BOOL)failedMarkAsSaved:(NSDictionary *)params;
- (void)finishMarkAsUnsaved:(NSDictionary *)params;
Expand Down
12 changes: 10 additions & 2 deletions clients/ios/Classes/StoryPagesObjCViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1473,15 +1473,23 @@ - (IBAction)toggleTextView:(id)sender {
// [self.appDelegate.feedDetailViewController changedStoryHeight:currentPage.webView.scrollView.contentSize.height];
}

- (void)toggleStorySaved:(id)sender {
- (IBAction)toggleStorySaved:(id)sender {
[appDelegate.storiesCollection toggleStorySaved];
}

- (void)toggleStoryUnread:(id)sender {
- (IBAction)toggleStoryUnread:(id)sender {
[appDelegate.storiesCollection toggleStoryUnread];
[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:) ||
Expand Down
17 changes: 12 additions & 5 deletions clients/ios/NewsBlur.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
170E3CD124F8A664009CE819 /* SplitViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 170E3CD024F8A664009CE819 /* SplitViewDelegate.swift */; };
170E3CD324F8A89B009CE819 /* HorizontalPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 170E3CD224F8A89B009CE819 /* HorizontalPageViewController.swift */; };
170E3CD724F8AB0D009CE819 /* FeedDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 170E3CD624F8AB0D009CE819 /* FeedDetailViewController.swift */; };
17150E1E2B05775A004D5309 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17150E1D2B05775A004D5309 /* SceneDelegate.swift */; };
17150E1F2B05775A004D5309 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17150E1D2B05775A004D5309 /* SceneDelegate.swift */; };
1715D02B2166B3F900227731 /* PremiumManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1715D02A2166B3F900227731 /* PremiumManager.m */; };
171B6FFD25C4C7C8008638A9 /* StoryPagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 171B6FFC25C4C7C8008638A9 /* StoryPagesViewController.swift */; };
1721C9D12497F91A00B0EDC4 /* mute_gray.png in Resources */ = {isa = PBXBuildFile; fileRef = 1721C9D02497F91900B0EDC4 /* mute_gray.png */; };
Expand Down Expand Up @@ -1429,6 +1431,7 @@
170E3CD024F8A664009CE819 /* SplitViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplitViewDelegate.swift; sourceTree = "<group>"; };
170E3CD224F8A89B009CE819 /* HorizontalPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HorizontalPageViewController.swift; sourceTree = "<group>"; };
170E3CD624F8AB0D009CE819 /* FeedDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedDetailViewController.swift; sourceTree = "<group>"; };
17150E1D2B05775A004D5309 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
1715D0292166B3F900227731 /* PremiumManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PremiumManager.h; sourceTree = "<group>"; };
1715D02A2166B3F900227731 /* PremiumManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PremiumManager.m; sourceTree = "<group>"; };
171B6FFC25C4C7C8008638A9 /* StoryPagesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StoryPagesViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3317,6 +3320,7 @@
175792E62930611B00490924 /* LaunchScreenDev.xib */,
1D3623240D0F684500981E51 /* NewsBlurAppDelegate.h */,
1D3623250D0F684500981E51 /* NewsBlurAppDelegate.m */,
17150E1D2B05775A004D5309 /* SceneDelegate.swift */,
FFD1D72F1459B63500E46F89 /* BaseViewController.h */,
FFD1D7301459B63500E46F89 /* BaseViewController.m */,
17C074941C14C46B00CFCDB7 /* ThemeManager.h */,
Expand Down Expand Up @@ -3835,8 +3839,9 @@
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1120;
LastUpgradeCheck = 1420;
LastUpgradeCheck = 1500;
ORGANIZATIONNAME = NewsBlur;
TargetAttributes = {
173CB30C26BCE94700BA872A = {
Expand Down Expand Up @@ -5091,6 +5096,7 @@
175792BA2930605500490924 /* OfflineFetchStories.m in Sources */,
175792BB2930605500490924 /* OfflineFetchText.m in Sources */,
175792BC2930605500490924 /* OfflineFetchImages.m in Sources */,
17150E1F2B05775A004D5309 /* SceneDelegate.swift in Sources */,
175792BD2930605500490924 /* SplitViewDelegate.swift in Sources */,
175792BE2930605500490924 /* Reachability.m in Sources */,
175792BF2930605500490924 /* NBSwipeableCell.m in Sources */,
Expand Down Expand Up @@ -5290,6 +5296,7 @@
FF855B5E1794B0760098D48A /* OfflineFetchStories.m in Sources */,
17362ADD23639B4E00A0FCCC /* OfflineFetchText.m in Sources */,
FF855B611794B0830098D48A /* OfflineFetchImages.m in Sources */,
17150E1E2B05775A004D5309 /* SceneDelegate.swift in Sources */,
170E3CD124F8A664009CE819 /* SplitViewDelegate.swift in Sources */,
FF8D1EA71BAA304E00725D8A /* Reachability.m in Sources */,
FFCDD90117F65A71000C6483 /* NBSwipeableCell.m in Sources */,
Expand Down Expand Up @@ -5623,7 +5630,6 @@
PRODUCT_NAME = "NB Alpha";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
STRIP_INSTALLED_PRODUCT = NO;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
Expand Down Expand Up @@ -5911,7 +5917,6 @@
PRODUCT_NAME = NewsBlur;
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
STRIP_INSTALLED_PRODUCT = NO;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_OBJC_BRIDGING_HEADER = "Other Sources/BridgingHeader.h";
Expand Down Expand Up @@ -5970,6 +5975,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO;
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
Expand All @@ -5996,6 +6002,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -6014,7 +6021,6 @@
PROVISIONING_PROFILE = "";
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
STRIP_INSTALLED_PRODUCT = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -6025,6 +6031,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO;
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
Expand All @@ -6050,6 +6057,7 @@
CURRENT_PROJECT_VERSION = 151;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -6068,7 +6076,6 @@
OTHER_LDFLAGS = "-ObjC";
PROVISIONING_PROFILE = "";
SDKROOT = iphoneos;
STRIP_INSTALLED_PRODUCT = NO;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1420"
LastUpgradeVersion = "1500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1420"
LastUpgradeVersion = "1500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1420"
LastUpgradeVersion = "1500"
wasCreatedForAppExtension = "YES"
version = "1.3">
<BuildAction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1420"
LastUpgradeVersion = "1500"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction
Expand Down
Loading

0 comments on commit f316f39

Please sign in to comment.