#1659 (full screen button doesn't work when story titles on bottom)

- Fixed feeds list disappearing when selecting a feed.
- Fixed non-functional full-screen buttons in top and bottom layout.
- In top/bottom full-screen mode, a Sites button appears to show the sidebar (or can use edge swipe).
This commit is contained in:
David Sinclair 2022-04-01 17:54:01 -07:00 committed by Samuel Clay
parent 946461ea35
commit b8453fe985
4 changed files with 86 additions and 19 deletions

View file

@ -20,6 +20,9 @@ class DetailViewController: BaseViewController {
/// Layout of the story titles and story pages.
static let layout = "story_titles_position"
/// Behavior of the split controller.
static let behavior = "split_behavior"
/// Position of the divider between the views when in horizontal orientation. Only used for `.top` and `.bottom` layouts.
static let horizontalPosition = "story_titles_divider_horizontal"
@ -28,7 +31,7 @@ class DetailViewController: BaseViewController {
}
/// Preference values.
enum Value {
enum LayoutValue {
static let left = "titles_on_left"
static let top = "titles_on_top"
static let bottom = "titles_on_bottom"
@ -50,9 +53,9 @@ class DetailViewController: BaseViewController {
var layout: Layout {
get {
switch UserDefaults.standard.string(forKey: Key.layout) {
case Value.top:
case LayoutValue.top:
return .top
case Value.bottom:
case LayoutValue.bottom:
return .bottom
default:
return .left
@ -65,11 +68,11 @@ class DetailViewController: BaseViewController {
switch newValue {
case .top:
UserDefaults.standard.set(Value.top, forKey: Key.layout)
UserDefaults.standard.set(LayoutValue.top, forKey: Key.layout)
case .bottom:
UserDefaults.standard.set(Value.bottom, forKey: Key.layout)
UserDefaults.standard.set(LayoutValue.bottom, forKey: Key.layout)
default:
UserDefaults.standard.set(Value.left, forKey: Key.layout)
UserDefaults.standard.set(LayoutValue.left, forKey: Key.layout)
}
updateLayout(reload: true)
@ -86,6 +89,43 @@ class DetailViewController: BaseViewController {
return layout == .top
}
/// Preference values.
enum BehaviorValue {
static let auto = "auto"
static let tile = "tile"
static let displace = "displace"
static let overlay = "overlay"
}
/// How the split controller behaves.
enum Behavior {
/// The split controller figures out the best behavior.
case auto
/// The split controller arranges the views side-by-side.
case tile
/// The split controller pushes the detail view aside.
case displace
/// The split controller puts the left columns over the detail view.
case overlay
}
/// How the split controller behaves.
var behavior: Behavior {
switch UserDefaults.standard.string(forKey: Key.behavior) {
case BehaviorValue.tile:
return .tile
case BehaviorValue.displace:
return .displace
case BehaviorValue.overlay:
return .overlay
default:
return .auto
}
}
/// Returns `true` if the window is in portrait orientation, otherwise `false`.
@objc var isPortraitOrientation: Bool {
return view.window?.windowScene?.interfaceOrientation.isPortrait ?? false
@ -166,7 +206,11 @@ class DetailViewController: BaseViewController {
appDelegate.feedsViewController.loadOfflineFeeds(false)
if layout != .left, let controller = feedDetailViewController {
navigationItem.leftBarButtonItems = [controller.settingsBarButton]
if behavior == .overlay {
navigationItem.leftBarButtonItems = [controller.feedsBarButton, controller.settingsBarButton]
} else {
navigationItem.leftBarButtonItems = [controller.settingsBarButton]
}
} else {
navigationItem.leftBarButtonItems = []
}
@ -331,6 +375,8 @@ private extension DetailViewController {
}
dividerViewBottomConstraint.constant = dividerPosition
appDelegate.updateSplitBehavior()
}
guard let storyPagesViewController = storyPagesViewController else {

View file

@ -42,6 +42,7 @@
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic, strong) IBOutlet UITableView *storyTitlesTable;
@property (nonatomic) IBOutlet UIBarButtonItem * feedMarkReadButton;
@property (nonatomic) IBOutlet UIBarButtonItem * feedsBarButton;
@property (nonatomic) IBOutlet UIBarButtonItem * settingsBarButton;
@property (nonatomic) IBOutlet UIBarButtonItem * spacerBarButton;
@property (nonatomic) IBOutlet UIBarButtonItem * spacer2BarButton;

View file

@ -139,6 +139,9 @@ typedef NS_ENUM(NSUInteger, MarkReadShowMenu)
[separatorBarButton setEnabled:NO];
separatorBarButton.isAccessibilityElement = NO;
self.feedsBarButton = [[UIBarButtonItem alloc] initWithTitle:@"Sites" style:UIBarButtonItemStylePlain target:self action:@selector(doShowFeeds:)];
self.feedsBarButton.accessibilityLabel = @"Show Sites";
UIImage *settingsImage = [UIImage imageNamed:@"nav_icn_settings.png"];
settingsBarButton = [UIBarButtonItem barItemWithImage:settingsImage target:self action:@selector(doOpenSettingsMenu:)];
settingsBarButton.accessibilityLabel = @"Settings";
@ -2207,6 +2210,10 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
[appDelegate.storiesCollection.activeFolder isEqualToString:@"infrequent"];
}
- (IBAction)doShowFeeds:(id)sender {
[self.appDelegate showColumn:UISplitViewControllerColumnPrimary debugInfo:@"showFeeds"];
}
- (IBAction)doOpenSettingsMenu:(id)sender {
if (self.presentedViewController) {
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];

View file

@ -814,18 +814,28 @@
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
NSString *behavior = [preferences stringForKey:@"split_behavior"];
if ([behavior isEqualToString:@"tile"]) {
self.splitViewController.preferredSplitBehavior = UISplitViewControllerSplitBehaviorTile;
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeTwoBesideSecondary;
} else if ([behavior isEqualToString:@"displace"]) {
self.splitViewController.preferredSplitBehavior = UISplitViewControllerSplitBehaviorDisplace;
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeTwoDisplaceSecondary;
} else if ([behavior isEqualToString:@"overlay"]) {
self.splitViewController.preferredSplitBehavior = UISplitViewControllerSplitBehaviorOverlay;
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeTwoOverSecondary;
if (self.detailViewController.storyTitlesOnLeft) {
if ([behavior isEqualToString:@"tile"]) {
self.splitViewController.preferredSplitBehavior = UISplitViewControllerSplitBehaviorTile;
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeTwoBesideSecondary;
} else if ([behavior isEqualToString:@"displace"]) {
self.splitViewController.preferredSplitBehavior = UISplitViewControllerSplitBehaviorDisplace;
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeTwoDisplaceSecondary;
} else if ([behavior isEqualToString:@"overlay"]) {
self.splitViewController.preferredSplitBehavior = UISplitViewControllerSplitBehaviorOverlay;
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeTwoOverSecondary;
} else {
self.splitViewController.preferredSplitBehavior = UISplitViewControllerSplitBehaviorAutomatic;
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAutomatic;
}
} else {
self.splitViewController.preferredSplitBehavior = UISplitViewControllerSplitBehaviorAutomatic;
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAutomatic;
if ([behavior isEqualToString:@"overlay"]) {
self.splitViewController.preferredSplitBehavior = UISplitViewControllerSplitBehaviorOverlay;
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeOneOverSecondary;
} else {
self.splitViewController.preferredSplitBehavior = UISplitViewControllerSplitBehaviorDisplace;
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeTwoDisplaceSecondary;
}
}
[storyPagesViewController refreshPages];
@ -840,6 +850,7 @@
[UIView animateWithDuration:0.5 animations:^{
[self updateSplitBehavior];
}];
[self.detailViewController updateLayoutWithReload:NO];
}];
}
@ -1591,7 +1602,9 @@
[self adjustStoryDetailWebView];
[self.feedDetailViewController.storyTitlesTable reloadData];
[self showColumn:UISplitViewControllerColumnSupplementary debugInfo:@"loadFeedDetailView"];
if (detailViewController.storyTitlesOnLeft) {
[self showColumn:UISplitViewControllerColumnSupplementary debugInfo:@"loadFeedDetailView"];
}
}
[self flushQueuedReadStories:NO withCallback:^{