Skip to content

Commit 00710a6

Browse files
authored
Merge pull request #21602 from wordpress-mobile/fix/split-view-support-2
Fix split view support on large iPhones
2 parents c0a2a49 + ea15c82 commit 00710a6

File tree

5 files changed

+37
-15
lines changed

5 files changed

+37
-15
lines changed

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/BlogDashboardViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ extension BlogDashboardViewController {
248248
trailing: horizontalInset)
249249

250250
section.interGroupSpacing = Constants.cellSpacing
251+
section.contentInsetsReference = .readableContent
251252

252253
return section
253254
}
@@ -322,7 +323,7 @@ extension BlogDashboardViewController {
322323
private enum Constants {
323324
static let estimatedWidth: CGFloat = 100
324325
static let estimatedHeight: CGFloat = 44
325-
static let horizontalSectionInset: CGFloat = 20
326+
static let horizontalSectionInset: CGFloat = 12
326327
static let verticalSectionInset: CGFloat = 20
327328
static var bottomSectionInset: CGFloat {
328329
// Make room for FAB on iPhone

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Actions/DashboardQuickActionsCardCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ extension DashboardQuickActionsCardCell: BlogDetailsPresentationDelegate {
131131
}
132132

133133
func presentBlogDetailsViewController(_ viewController: UIViewController) {
134-
self.parentViewController?.showDetailViewController(viewController, sender: nil)
134+
self.blogDetailsViewController?.show(viewController, sender: nil)
135135
}
136136
}
137137

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ - (void)viewDidLoad
384384
[self.tableView registerClass:[MigrationSuccessCell class] forCellReuseIdentifier:BlogDetailsMigrationSuccessCellIdentifier];
385385
[self.tableView registerClass:[JetpackBrandingMenuCardCell class] forCellReuseIdentifier:BlogDetailsJetpackBrandingCardCellIdentifier];
386386
[self.tableView registerClass:[JetpackRemoteInstallTableViewCell class] forCellReuseIdentifier:BlogDetailsJetpackInstallCardCellIdentifier];
387+
388+
self.tableView.cellLayoutMarginsFollowReadableWidth = YES;
387389

388390
self.hasLoggedDomainCreditPromptShownEvent = NO;
389391

@@ -409,7 +411,7 @@ - (void)viewWillAppear:(BOOL)animated
409411

410412
[self observeWillEnterForegroundNotification];
411413

412-
if (self.splitViewControllerIsHorizontallyCompact) {
414+
if (!self.isSplitViewDisplayed) {
413415
self.restorableSelectedIndexPath = nil;
414416
}
415417

@@ -994,7 +996,7 @@ - (void)reloadTableViewPreservingSelection
994996

995997
BOOL isValidIndexPath = self.restorableSelectedIndexPath.section < self.tableView.numberOfSections &&
996998
self.restorableSelectedIndexPath.row < [self.tableView numberOfRowsInSection:self.restorableSelectedIndexPath.section];
997-
if (isValidIndexPath && ![self splitViewControllerIsHorizontallyCompact]) {
999+
if (isValidIndexPath && [self isSplitViewDisplayed]) {
9981000
// And finally we'll reselect the selected row, if there is one
9991001
[self.tableView selectRowAtIndexPath:self.restorableSelectedIndexPath
10001002
animated:NO
@@ -1038,7 +1040,7 @@ - (void)configureTableViewData
10381040
if ([self shouldShowQuickStartChecklist]) {
10391041
[marr addNullableObject:[self quickStartSectionViewModel]];
10401042
}
1041-
if ([self isDashboardEnabled] && ![self splitViewControllerIsHorizontallyCompact]) {
1043+
if ([self isDashboardEnabled] && [self isSplitViewDisplayed]) {
10421044
[marr addNullableObject:[self homeSectionViewModel]];
10431045
}
10441046

@@ -1077,6 +1079,10 @@ - (void)configureTableViewData
10771079
self.tableSections = [NSArray arrayWithArray:marr];
10781080
}
10791081

1082+
- (Boolean)isSplitViewDisplayed {
1083+
return ![self splitViewControllerIsHorizontallyCompact] && [MySitesCoordinator isSplitViewEnabled];
1084+
}
1085+
10801086
/// This section is available on Jetpack only.
10811087
- (BlogDetailsSection *)contentSectionViewModel
10821088
{
@@ -1511,7 +1517,7 @@ - (void)switchToBlog:(Blog*)blog
15111517

15121518
- (void)showInitialDetailsForBlog
15131519
{
1514-
if ([self splitViewControllerIsHorizontallyCompact]) {
1520+
if (![self isSplitViewDisplayed]) {
15151521
return;
15161522
}
15171523

@@ -1617,7 +1623,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
16171623
[WPStyleGuide configureTableViewDestructiveActionCell:cell];
16181624
} else {
16191625
if (row.showsDisclosureIndicator) {
1620-
cell.accessoryType = [self splitViewControllerIsHorizontallyCompact] ? UITableViewCellAccessoryDisclosureIndicator : UITableViewCellAccessoryNone;
1626+
cell.accessoryType = [self isSplitViewDisplayed] ? UITableViewCellAccessoryNone : UITableViewCellAccessoryDisclosureIndicator;
16211627
} else {
16221628
cell.accessoryType = UITableViewCellAccessoryNone;
16231629
}
@@ -1654,7 +1660,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
16541660
if (row.showsSelectionState) {
16551661
self.restorableSelectedIndexPath = indexPath;
16561662
} else {
1657-
if ([self splitViewControllerIsHorizontallyCompact]) {
1663+
if (![self isSplitViewDisplayed]) {
16581664
// Deselect current row when not in split view layout
16591665
[tableView deselectRowAtIndexPath:indexPath animated:YES];
16601666
} else {

WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class MySiteViewController: UIViewController, UIScrollViewDelegate, NoSite
3131
private func getSection(for blog: Blog) -> Section {
3232
if JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() &&
3333
blog.isAccessibleThroughWPCom() &&
34-
splitViewControllerIsHorizontallyCompact {
34+
(splitViewControllerIsHorizontallyCompact || !MySitesCoordinator.isSplitViewEnabled) {
3535
return .dashboard
3636
} else {
3737
return .siteMenu
@@ -893,11 +893,15 @@ extension MySiteViewController: BlogDetailsPresentationDelegate {
893893
}
894894

895895
func presentBlogDetailsViewController(_ viewController: UIViewController) {
896-
switch currentSection {
897-
case .dashboard:
898-
blogDashboardViewController?.showDetailViewController(viewController, sender: blogDashboardViewController)
899-
case .siteMenu:
900-
blogDetailsViewController?.showDetailViewController(viewController, sender: blogDetailsViewController)
896+
if MySitesCoordinator.isSplitViewEnabled {
897+
switch currentSection {
898+
case .dashboard:
899+
blogDashboardViewController?.showDetailViewController(viewController, sender: blogDashboardViewController)
900+
case .siteMenu:
901+
blogDetailsViewController?.showDetailViewController(viewController, sender: blogDetailsViewController)
902+
}
903+
} else {
904+
blogDetailsViewController?.show(viewController, sender: nil)
901905
}
902906
}
903907
}

WordPress/Classes/ViewRelated/System/Coordinators/MySitesCoordinator.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,17 @@ class MySitesCoordinator: NSObject {
3636
///
3737
@objc
3838
var rootViewController: UIViewController {
39-
return splitViewController
39+
if MySitesCoordinator.isSplitViewEnabled {
40+
return splitViewController
41+
} else {
42+
// `hidesBottomBarWhenPushed` doesn't work with `UISplitViewController`,
43+
// so it we have to use `UINavigationController` directly.
44+
return navigationController
45+
}
46+
}
47+
48+
@objc class var isSplitViewEnabled: Bool {
49+
UIDevice.current.userInterfaceIdiom == .pad
4050
}
4151

4252
@objc
@@ -65,6 +75,7 @@ class MySitesCoordinator: NSObject {
6575
navigationController.tabBarItem.accessibilityLabel = NSLocalizedString("My Site", comment: "The accessibility value of the my site tab.")
6676
navigationController.tabBarItem.accessibilityIdentifier = "mySitesTabButton"
6777
navigationController.tabBarItem.title = NSLocalizedString("My Site", comment: "The accessibility value of the my site tab.")
78+
navigationController.extendedLayoutIncludesOpaqueBars = true
6879

6980
return navigationController
7081
}()

0 commit comments

Comments
 (0)