diff --git a/Riot/AppDelegate.h b/Riot/AppDelegate.h index 55b3cd54e..6fc781d75 100644 --- a/Riot/AppDelegate.h +++ b/Riot/AppDelegate.h @@ -85,6 +85,11 @@ extern NSString *const kAppDelegateNetworkStatusDidChangeNotification; - (void)restoreInitialDisplay:(void (^)())completion; +/** + Replace the secondary view controller of the split view controller (if any) with the default empty details view controller. + */ +- (void)restoreEmptyDetailsViewController; + - (UIAlertController*)showErrorAsAlert:(NSError*)error; #pragma mark - Matrix Sessions handling diff --git a/Riot/AppDelegate.m b/Riot/AppDelegate.m index 907a98b97..e002b3b14 100644 --- a/Riot/AppDelegate.m +++ b/Riot/AppDelegate.m @@ -737,6 +737,36 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN } } +- (void)restoreEmptyDetailsViewController +{ + UIViewController* rootViewController = self.window.rootViewController; + + if ([rootViewController isKindOfClass:[UISplitViewController class]]) + { + UISplitViewController *splitViewController = (UISplitViewController *)rootViewController; + + // Be sure that the primary is then visible too. + if (splitViewController.displayMode == UISplitViewControllerDisplayModePrimaryHidden) + { + splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible; + } + + if (splitViewController.viewControllers.count == 2) + { + UIViewController *mainViewController = splitViewController.viewControllers[0]; + + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]]; + UIViewController *emptyDetailsViewController = [storyboard instantiateViewControllerWithIdentifier:@"EmptyDetailsViewControllerStoryboardId"]; + emptyDetailsViewController.view.backgroundColor = kRiotPrimaryBgColor; + + splitViewController.viewControllers = @[mainViewController, emptyDetailsViewController]; + } + } + + // Release the current selected item (room/contact/group...). + [_masterTabBarController releaseSelectedItem]; +} + - (UIAlertController*)showErrorAsAlert:(NSError*)error { // Ignore fake error, or connection cancellation error diff --git a/Riot/ViewController/GroupDetailsViewController.m b/Riot/ViewController/GroupDetailsViewController.m index fd0e18e87..0317b6307 100644 --- a/Riot/ViewController/GroupDetailsViewController.m +++ b/Riot/ViewController/GroupDetailsViewController.m @@ -155,4 +155,16 @@ } } +- (void)withdrawViewControllerAnimated:(BOOL)animated completion:(void (^)(void))completion +{ + [super withdrawViewControllerAnimated:animated completion:completion]; + + // Fill the secondary navigation view controller of the split view controller if it is empty. + UINavigationController *secondaryNavigationController = [AppDelegate theDelegate].secondaryNavigationController; + if (secondaryNavigationController && !secondaryNavigationController.viewControllers.count) + { + [[AppDelegate theDelegate] restoreEmptyDetailsViewController]; + } +} + @end diff --git a/Riot/ViewController/GroupHomeViewController.m b/Riot/ViewController/GroupHomeViewController.m index 181ba2ba1..e15461604 100644 --- a/Riot/ViewController/GroupHomeViewController.m +++ b/Riot/ViewController/GroupHomeViewController.m @@ -265,12 +265,21 @@ } [self.inviteContainer layoutIfNeeded]; - _separatorViewTopConstraint.constant = self.inviteContainer.frame.size.height; + + if (_separatorViewTopConstraint.constant != self.inviteContainer.frame.size.height) + { + _separatorViewTopConstraint.constant = self.inviteContainer.frame.size.height; + [self.view layoutIfNeeded]; + } } else { self.inviteContainer.hidden = YES; - _separatorViewTopConstraint.constant = 0; + if (_separatorViewTopConstraint.constant != 0) + { + _separatorViewTopConstraint.constant = 0; + [self.view layoutIfNeeded]; + } } if (_group.summary.profile.longDescription.length) @@ -278,6 +287,11 @@ //@TODO: implement a specific html renderer to support h1/h2 and handle the Matrix media content URI (in the form of "mxc://..."). MXKEventFormatter *eventFormatter = [[MXKEventFormatter alloc] initWithMatrixSession:self.mxSession]; _groupLongDescription.attributedText = [eventFormatter renderHTMLString:_group.summary.profile.longDescription forEvent:nil]; + _groupLongDescription.contentOffset = CGPointZero; + } + else + { + _groupLongDescription.text = nil; } } else