diff --git a/Riot/Modules/Home/HomeViewController.m b/Riot/Modules/Home/HomeViewController.m index 069c24efc..c7a7b5288 100644 --- a/Riot/Modules/Home/HomeViewController.m +++ b/Riot/Modules/Home/HomeViewController.m @@ -46,8 +46,6 @@ @property (nonatomic, strong) CrossSigningSetupBannerCell *keyVerificationSetupBannerPrototypeCell; @property (nonatomic, strong) AuthenticatedSessionViewControllerFactory *authenticatedSessionViewControllerFactory; -@property (nonatomic, weak) HomeEmptyView *homeEmptyView; - @end @implementation HomeViewController @@ -101,9 +99,7 @@ // Take the lead on the shared data source. recentsDataSource.areSectionsShrinkable = NO; [recentsDataSource setDelegate:self andRecentsDataSourceMode:RecentsDataSourceModeHome]; - } - - [self updateEmptyViewDisplayName]; + } [self moveAllCollectionsToLeft]; } @@ -281,28 +277,15 @@ { [super onMatrixSessionChange]; - [self updateEmptyViewDisplayName]; -} - -- (void)userInterfaceThemeDidChange -{ - [super userInterfaceThemeDidChange]; - - [self.homeEmptyView updateWithTheme:ThemeService.shared.theme]; + [self updateEmptyView]; } #pragma mark - UITableViewDataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - NSInteger numberOfSections = [recentsDataSource numberOfSectionsInTableView:tableView]; - - BOOL showEmptyView = [self shouldShowEmptyView]; - - [self showEmptyView:showEmptyView]; - // Return the actual number of sections prepared in recents dataSource. - return numberOfSections; + return [recentsDataSource numberOfSectionsInTableView:tableView]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section @@ -819,49 +802,19 @@ #pragma mark - Empty view management -- (void)showEmptyView:(BOOL)show -{ - if (show && !self.homeEmptyView) - { - HomeEmptyView *homeEmptyView = [HomeEmptyView instantiate]; - [homeEmptyView updateWithTheme:ThemeService.shared.theme]; - [self addEmptyView:homeEmptyView]; - - self.homeEmptyView = homeEmptyView; - - [self updateEmptyViewDisplayName]; - } - else if (!show) - { - [self.homeEmptyView removeFromSuperview]; - } - - self.recentsTableView.hidden = show; -} - -- (void)updateEmptyViewDisplayName +- (void)updateEmptyView { MXUser *myUser = self.mainSession.myUser; NSString *displayName = myUser.displayname ?: myUser.userId; + displayName = displayName ?: @""; - [self.homeEmptyView fillWith:displayName ?: @""]; + NSString *title = [NSString stringWithFormat:NSLocalizedStringFromTable(@"home_empty_view_title", @"Vector", nil), displayName]; + + [self.emptyView fillWith:[UIImage imageNamed:@"home_placeholder_artwork"] + title:title + informationText:NSLocalizedStringFromTable(@"home_empty_view_information", @"Vector", nil)]; } -- (void)addEmptyView:(UIView*)emptyView -{ - [self.view insertSubview:emptyView belowSubview:plusButtonImageView]; - - emptyView.translatesAutoresizingMaskIntoConstraints = NO; - - [NSLayoutConstraint activateConstraints:@[ - [emptyView.topAnchor constraintEqualToAnchor:emptyView.superview.topAnchor], - [emptyView.leftAnchor constraintEqualToAnchor:emptyView.superview.leftAnchor], - [emptyView.rightAnchor constraintEqualToAnchor:emptyView.superview.rightAnchor], - [emptyView.bottomAnchor constraintEqualToAnchor:plusButtonImageView.topAnchor] - ]]; -} - -// By default on fresh account - (BOOL)shouldShowEmptyView { // Check if some banners should be displayed