Empty screens: Update home empty screen.

This commit is contained in:
SBiOSoftWhare
2020-11-26 11:28:14 +01:00
parent 47b5fa1661
commit ec79cde2f1
+10 -57
View File
@@ -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