#817 (three column layout): top & bottom layout

This commit is contained in:
David Sinclair 2020-12-21 20:53:08 -08:00
parent aee59c87cf
commit a583194d8a
12 changed files with 94 additions and 46 deletions

View file

@ -43,7 +43,6 @@
//@property (nonatomic) StoryDetailViewController *previousPage;
@property (nonatomic, strong) IBOutlet UIScrollView *scrollView;
@property (nonatomic, strong) IBOutlet UIPageControl *pageControl;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *scrollViewTopConstraint;
@property (weak, nonatomic) IBOutlet UIView *autoscrollView;
@property (weak, nonatomic) IBOutlet UIImageView *autoscrollBackgroundImageView;
@ -51,7 +50,8 @@
@property (weak, nonatomic) IBOutlet UIButton *autoscrollPauseResumeButton;
@property (weak, nonatomic) IBOutlet UIButton *autoscrollSlowerButton;
@property (weak, nonatomic) IBOutlet UIButton *autoscrollFasterButton;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *autoscrollBottomConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *autoscrollTopContainerBottomConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *autoscrollBottomContainerBottomConstraint;
@property (nonatomic, strong) IBOutlet UIActivityIndicatorView *loadingIndicator;
@property (nonatomic) IBOutlet UIImageView *textStorySendBackgroundImageView;
@ -76,8 +76,8 @@
@property (nonatomic) IBOutlet UIBarButtonItem *originalStoryButton;
@property (nonatomic, strong) IBOutlet UIBarButtonItem *subscribeButton;
@property (nonatomic) IBOutlet UIImageView *dragBarImageView;
@property (nonatomic) IBOutlet NSLayoutConstraint *traverseBottomConstraint;
@property (nonatomic) IBOutlet NSLayoutConstraint *scrollBottomConstraint;
@property (nonatomic) IBOutlet NSLayoutConstraint *traverseTopContainerBottomConstraint;
@property (nonatomic) IBOutlet NSLayoutConstraint *traverseBottomContainerBottomConstraint;
@property (nonatomic) IBOutlet UIView *statusBarBackgroundView;
@property (nonatomic) BOOL autoscrollAvailable;
@property (nonatomic) BOOL autoscrollActive;
@ -145,6 +145,9 @@
- (void)flashCheckmarkHud:(NSString *)messageType;
- (void)adjustTraversePosition:(CGFloat)position;
- (void)adjustAutoscrollPosition:(CGFloat)position;
- (void)tappedStory;
- (void)showAutoscrollBriefly:(BOOL)briefly;
- (void)hideAutoscrollAfterDelay;

View file

@ -62,8 +62,8 @@
@synthesize isAnimatedIntoPlace;
@synthesize progressView, progressViewContainer;
@synthesize traversePinned, traverseFloating;
@synthesize traverseBottomConstraint;
@synthesize scrollBottomConstraint;
@synthesize traverseTopContainerBottomConstraint;
@synthesize traverseBottomContainerBottomConstraint;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
@ -225,7 +225,7 @@
[self.view addConstraint:self.notifier.topOffsetConstraint];
[self.notifier hideNow];
self.traverseBottomConstraint.constant = 50;
[self adjustTraversePosition:50];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:
@ -471,11 +471,11 @@
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
if (self.isNavigationBarHidden && !self.shouldHideStatusBar) {
self.scrollViewTopConstraint.constant = self.statusBarHeight;
} else {
self.scrollViewTopConstraint.constant = 0;
}
// if (self.isNavigationBarHidden && !self.shouldHideStatusBar) {
// self.scrollViewTopConstraint.constant = self.statusBarHeight;
// } else {
// self.scrollViewTopConstraint.constant = 0;
// }
UIInterfaceOrientation orientation = self.view.window.windowScene.interfaceOrientation;
[self layoutForInterfaceOrientation:orientation];
@ -558,7 +558,7 @@
safeBottomMargin = -1 * self.view.safeAreaInsets.bottom/2;
}
self.traverseBottomConstraint.constant = safeBottomMargin + 20;
[self adjustTraversePosition:safeBottomMargin + 20];
[self.view layoutIfNeeded];
}
}
@ -772,6 +772,16 @@
return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone || appDelegate.isCompactWidth;
}
- (void)adjustTraversePosition:(CGFloat)position {
self.traverseTopContainerBottomConstraint.constant = position;
self.traverseBottomContainerBottomConstraint.constant = position;
}
- (void)adjustAutoscrollPosition:(CGFloat)position {
self.autoscrollTopContainerBottomConstraint.constant = position;
self.autoscrollBottomContainerBottomConstraint.constant = position;
}
- (void)updateAutoscrollButtons {
self.autoscrollBackgroundImageView.image = [[ThemeManager themeManager] themedImage:[UIImage imageNamed:@"traverse_background.png"]];
@ -1043,9 +1053,9 @@
// traversePinned = YES;
//
// if (!self.isPhoneOrCompact) {
// self.traverseBottomConstraint.constant = 0;
// self.traverseTopContainerBottomConstraint.constant = 0;
// } else {
// self.traverseBottomConstraint.constant = -1 * self.view.safeAreaInsets.bottom/2;
// self.traverseTopContainerBottomConstraint.constant = -1 * self.view.safeAreaInsets.bottom/2;
// }
//
// [UIView animateWithDuration:.24 delay:0
@ -1708,9 +1718,9 @@
if (self.autoscrollView.alpha == 0) {
if (self.isPhoneOrCompact) {
self.autoscrollBottomConstraint.constant = 50;
[self adjustAutoscrollPosition:50];
} else {
self.autoscrollBottomConstraint.constant = 0;
[self adjustAutoscrollPosition:12];
}
[self.view layoutIfNeeded];

View file

@ -261,6 +261,8 @@ class DetailViewController: DetailObjCViewController {
private extension DetailViewController {
func checkViewControllers() {
let isTop = layout == .top
if layout == .left {
if feedDetailViewController != nil {
remove(viewController: feedDetailViewController)
@ -277,12 +279,18 @@ private extension DetailViewController {
if feedDetailViewController == nil {
feedDetailViewController = Storyboards.shared.controller(withIdentifier: .feedDetail) as? FeedDetailViewController
add(viewController: feedDetailViewController, top: layout == .top)
add(viewController: feedDetailViewController, top: isTop)
supplementaryFeedDetailNavigationController = appDelegate.feedDetailNavigationController
supplementaryFeedDetailViewController = appDelegate.feedDetailViewController
appDelegate.feedDetailViewController = feedDetailViewController
appDelegate.splitViewController.setViewController(nil, for: .supplementary)
} else {
let appropriateSuperview = isTop ? topContainerView : bottomContainerView
if feedDetailViewController?.view.superview != appropriateSuperview {
add(viewController: feedDetailViewController, top: isTop)
}
}
dividerViewBottomConstraint.constant = dividerPosition
@ -292,11 +300,26 @@ private extension DetailViewController {
horizontalPageViewController = Storyboards.shared.controller(withIdentifier: .horizontalPages) as? HorizontalPageViewController
horizontalPageViewController?.detailViewController = self
add(viewController: horizontalPageViewController, top: layout != .top)
}
// appDelegate.loadFeedDetailView()
let appropriateSuperview = isTop ? bottomContainerView : topContainerView
if horizontalPageViewController?.view.superview != appropriateSuperview {
add(viewController: horizontalPageViewController, top: !isTop)
if isTop {
bottomContainerView.addSubview(traverseView)
bottomContainerView.addSubview(autoscrollView)
} else {
topContainerView.addSubview(traverseView)
topContainerView.addSubview(autoscrollView)
}
}
traverseTopContainerBottomConstraint.isActive = !isTop
traverseBottomContainerBottomConstraint.isActive = isTop
autoscrollTopContainerBottomConstraint.isActive = !isTop
autoscrollBottomContainerBottomConstraint.isActive = isTop
}
func add(viewController: UIViewController?, top: Bool) {

View file

@ -2200,13 +2200,13 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
}];
}
// NSString *preferenceKey = @"story_titles_position";
// NSArray *titles = @[@"Left", @"Top", @"Bottom"];
// NSArray *values = @[@"titles_on_left", @"titles_on_top", @"titles_on_bottom"];
//
// [viewController addSegmentedControlWithTitles:titles values:values preferenceKey:preferenceKey selectionShouldDismiss:YES handler:^(NSUInteger selectedIndex) {
// [self.appDelegate.detailViewController updateLayoutWithReload:YES];
// }];
NSString *preferenceKey = @"story_titles_position";
NSArray *titles = @[@"Left", @"Top", @"Bottom"];
NSArray *values = @[@"titles_on_left", @"titles_on_top", @"titles_on_bottom"];
[viewController addSegmentedControlWithTitles:titles values:values preferenceKey:preferenceKey selectionShouldDismiss:YES handler:^(NSUInteger selectedIndex) {
[self.appDelegate.detailViewController updateLayoutWithReload:YES];
}];
[viewController addSegmentedControlWithTitles:@[@"Newest First", @"Oldest"] selectIndex:[appDelegate.storiesCollection.activeOrder isEqualToString:@"newest"] ? 0 : 1 selectionShouldDismiss:YES handler:^(NSUInteger selectedIndex) {
if (selectedIndex == 0) {
@ -2234,9 +2234,9 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
}];
}
NSString *preferenceKey = @"story_list_preview_text_size";
NSArray *titles = @[@"Title", @"1", @"2", @"3"];
NSArray *values = @[@"title", @"short", @"medium", @"long"];
preferenceKey = @"story_list_preview_text_size";
titles = @[@"Title", @"1", @"2", @"3"];
values = @[@"title", @"short", @"medium", @"long"];
[viewController addSegmentedControlWithTitles:titles values:values preferenceKey:preferenceKey selectionShouldDismiss:YES handler:^(NSUInteger selectedIndex) {
[self.appDelegate resizePreviewSize];

View file

@ -1412,12 +1412,12 @@
appDelegate.detailViewController.traverseView.alpha = 1;
// NSLog(@" ---> Bottom position: %d", bottomPosition);
if (bottomPosition >= 0 || !isHorizontal) {
appDelegate.detailViewController.traverseBottomConstraint.constant = safeBottomMargin;
[appDelegate.detailViewController adjustTraversePosition:safeBottomMargin];
} else {
if (webpageHeight > 0) {
appDelegate.detailViewController.traverseBottomConstraint.constant = viewportHeight - (webpageHeight - topPosition) + safeBottomMargin;
[appDelegate.detailViewController adjustTraversePosition:viewportHeight - (webpageHeight - topPosition) + safeBottomMargin];
} else {
appDelegate.detailViewController.traverseBottomConstraint.constant = safeBottomMargin;
[appDelegate.detailViewController adjustTraversePosition:safeBottomMargin];
}
}
} else if (!singlePage && (atTop && !atBottom)) {
@ -1426,7 +1426,7 @@
appDelegate.detailViewController.traverseFloating = NO;
[appDelegate.detailViewController.view layoutIfNeeded];
appDelegate.detailViewController.traverseBottomConstraint.constant = safeBottomMargin;
[appDelegate.detailViewController adjustTraversePosition:safeBottomMargin];
[UIView animateWithDuration:.3 delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
@ -1439,7 +1439,7 @@
appDelegate.detailViewController.traverseFloating = YES;
[appDelegate.detailViewController.view layoutIfNeeded];
appDelegate.detailViewController.traverseBottomConstraint.constant = safeBottomMargin;
[appDelegate.detailViewController adjustTraversePosition:safeBottomMargin];
[UIView animateWithDuration:.3 delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
@ -1452,7 +1452,7 @@
appDelegate.detailViewController.traversePinned = NO;
appDelegate.detailViewController.traverseFloating = YES;
appDelegate.detailViewController.traverseView.alpha = 1;
appDelegate.detailViewController.traverseBottomConstraint.constant = viewportHeight - (webpageHeight - topPosition) + safeBottomMargin;
[appDelegate.detailViewController adjustTraversePosition:viewportHeight - (webpageHeight - topPosition) + safeBottomMargin];
}
[self storeScrollPosition:YES];

View file

@ -2837,7 +2837,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1120;
LastUpgradeCheck = 1220;
LastUpgradeCheck = 1230;
ORGANIZATIONNAME = NewsBlur;
TargetAttributes = {
1749390F1C251BFE003D98AA = {

View file

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

View file

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

View file

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

View file

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

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="6pv-7g-17r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="6pv-7g-17r">
<device id="ipad11_0rounded" orientation="landscape" layout="fullscreen" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@ -321,6 +321,7 @@
<constraints>
<constraint firstItem="4vK-W4-ayS" firstAttribute="leading" secondItem="jTZ-4O-xyT" secondAttribute="leading" id="AFV-14-jnc"/>
<constraint firstAttribute="trailing" secondItem="5M7-bO-MVK" secondAttribute="trailing" id="Bge-if-1kj"/>
<constraint firstItem="5M7-bO-MVK" firstAttribute="bottom" secondItem="hfm-Pf-oeW" secondAttribute="bottom" constant="90" id="DIG-xz-1US"/>
<constraint firstItem="hfm-Pf-oeW" firstAttribute="centerX" secondItem="jTZ-4O-xyT" secondAttribute="centerX" id="Grz-1P-qjc"/>
<constraint firstItem="rKh-Md-Ci2" firstAttribute="top" secondItem="bPa-u1-Aml" secondAttribute="top" id="JN4-aj-xiN"/>
<constraint firstAttribute="trailing" secondItem="4vK-W4-ayS" secondAttribute="trailing" id="JVw-MX-f4R"/>
@ -329,6 +330,7 @@
<constraint firstItem="5M7-bO-MVK" firstAttribute="leading" secondItem="jTZ-4O-xyT" secondAttribute="leading" id="Tg9-DU-zcP"/>
<constraint firstItem="tFd-Uv-aMP" firstAttribute="top" secondItem="4vK-W4-ayS" secondAttribute="bottom" constant="20" id="YVh-UJ-d3j"/>
<constraint firstAttribute="bottom" secondItem="tFd-Uv-aMP" secondAttribute="bottom" constant="168" id="c9d-f5-wud"/>
<constraint firstItem="5M7-bO-MVK" firstAttribute="bottom" secondItem="4vK-W4-ayS" secondAttribute="bottom" constant="32" id="efm-qO-UF1"/>
<constraint firstAttribute="trailing" secondItem="tFd-Uv-aMP" secondAttribute="trailing" id="h2I-ng-gxc"/>
<constraint firstAttribute="bottom" secondItem="5M7-bO-MVK" secondAttribute="bottom" id="nSX-TU-ART"/>
<constraint firstItem="tFd-Uv-aMP" firstAttribute="top" secondItem="hfm-Pf-oeW" secondAttribute="bottom" constant="78" id="phm-3P-lxo"/>
@ -336,15 +338,22 @@
<constraint firstItem="tFd-Uv-aMP" firstAttribute="leading" secondItem="jTZ-4O-xyT" secondAttribute="leading" id="wzt-O8-Ild"/>
<constraint firstAttribute="trailing" secondItem="bPa-u1-Aml" secondAttribute="trailing" id="xth-oH-VTF"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="DIG-xz-1US"/>
<exclude reference="efm-qO-UF1"/>
</mask>
</variation>
</view>
<navigationItem key="navigationItem" id="OyA-BF-OGR"/>
<connections>
<outlet property="autoscrollBackgroundImageView" destination="DhZ-K9-Ohx" id="JlX-4q-aYI"/>
<outlet property="autoscrollBottomConstraint" destination="phm-3P-lxo" id="7kF-8R-ggC"/>
<outlet property="autoscrollBottomContainerBottomConstraint" destination="DIG-xz-1US" id="SRV-nP-Wrx"/>
<outlet property="autoscrollDisableButton" destination="Xtc-sh-knL" id="HH8-tu-4lg"/>
<outlet property="autoscrollFasterButton" destination="xZB-Qu-u2n" id="ora-na-Jht"/>
<outlet property="autoscrollPauseResumeButton" destination="WoA-Tv-FTT" id="G89-JX-DAM"/>
<outlet property="autoscrollSlowerButton" destination="x4P-S0-dR7" id="5r5-Ix-oSv"/>
<outlet property="autoscrollTopContainerBottomConstraint" destination="phm-3P-lxo" id="1se-rX-o1p"/>
<outlet property="autoscrollView" destination="hfm-Pf-oeW" id="uLO-sQ-E0v"/>
<outlet property="bottomContainerView" destination="5M7-bO-MVK" id="Tqo-s5-kGB"/>
<outlet property="buttonNext" destination="ZoU-af-wjh" id="Bg3-Bc-32l"/>
@ -358,7 +367,8 @@
<outlet property="prevNextBackgroundImageView" destination="PLd-RZ-773" id="adi-Gt-uX1"/>
<outlet property="textStorySendBackgroundImageView" destination="zfl-mN-y0T" id="lD1-7s-izZ"/>
<outlet property="topContainerView" destination="bPa-u1-Aml" id="nUk-aR-0ix"/>
<outlet property="traverseBottomConstraint" destination="YVh-UJ-d3j" id="gGi-RC-s2Z"/>
<outlet property="traverseBottomContainerBottomConstraint" destination="efm-qO-UF1" id="cEE-UD-KiD"/>
<outlet property="traverseTopContainerBottomConstraint" destination="YVh-UJ-d3j" id="d4B-Vw-6hb"/>
<outlet property="traverseView" destination="4vK-W4-ayS" id="yvU-Yp-1YP"/>
</connections>
</viewController>

View file

@ -170,6 +170,7 @@
<key>Titles</key>
<array>
<string>Titles on left</string>
<string>Titles on top</string>
<string>Titles on bottom</string>
</array>
<key>DefaultValue</key>
@ -177,6 +178,7 @@
<key>Values</key>
<array>
<string>titles_on_left</string>
<string>titles_on_top</string>
<string>titles_on_bottom</string>
</array>
<key>Key</key>