Skip to content

Commit

Permalink
Update All chats screen with latest design #6407
Browse files Browse the repository at this point in the history
- Update after code review
  • Loading branch information
gileluard committed Aug 1, 2022
1 parent ad7e61f commit 9d3c49a
Show file tree
Hide file tree
Showing 25 changed files with 228 additions and 348 deletions.
8 changes: 4 additions & 4 deletions Riot/Managers/Theme/Themes/DarkTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DarkTheme: NSObject, Theme {

var backgroundColor: UIColor = UIColor(rgb: 0x15191E)

var baseColor: UIColor = BuildSettings.newAppLayoutEnaled ? UIColor(rgb: 0x15191E) : UIColor(rgb: 0x21262C)
var baseColor: UIColor = BuildSettings.newAppLayoutEnabled ? UIColor(rgb: 0x15191E) : UIColor(rgb: 0x21262C)
var baseIconPrimaryColor: UIColor = UIColor(rgb: 0xEDF3FF)
var baseTextPrimaryColor: UIColor = UIColor(rgb: 0xFFFFFF)
var baseTextSecondaryColor: UIColor = UIColor(rgb: 0xA9B2BC)
Expand All @@ -35,7 +35,7 @@ class DarkTheme: NSObject, Theme {
var searchPlaceholderColor: UIColor = UIColor(rgb: 0xA9B2BC)
var searchResultHighlightColor: UIColor = UIColor(rgb: 0xFCC639).withAlphaComponent(0.3)

var headerBackgroundColor: UIColor = BuildSettings.newAppLayoutEnaled ? UIColor(rgb: 0x15191E) : UIColor(rgb: 0x21262C)
var headerBackgroundColor: UIColor = BuildSettings.newAppLayoutEnabled ? UIColor(rgb: 0x15191E) : UIColor(rgb: 0x21262C)
var headerBorderColor: UIColor = UIColor(rgb: 0x15191E)
var headerTextPrimaryColor: UIColor = UIColor(rgb: 0xFFFFFF)
var headerTextSecondaryColor: UIColor = UIColor(rgb: 0xA9B2BC)
Expand Down Expand Up @@ -129,7 +129,7 @@ class DarkTheme: NSObject, Theme {
if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()

if BuildSettings.newAppLayoutEnaled {
if BuildSettings.newAppLayoutEnabled {
appearance.configureWithDefaultBackground()
} else {
appearance.configureWithOpaqueBackground()
Expand All @@ -146,7 +146,7 @@ class DarkTheme: NSObject, Theme {

navigationBar.standardAppearance = appearance

if BuildSettings.newAppLayoutEnaled {
if BuildSettings.newAppLayoutEnabled {
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = baseColor
appearance.shadowColor = nil
Expand Down
10 changes: 5 additions & 5 deletions Riot/Managers/Theme/Themes/DefaultTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DefaultTheme: NSObject, Theme {

var backgroundColor: UIColor = UIColor(rgb: 0xFFFFFF)

var baseColor: UIColor = BuildSettings.newAppLayoutEnaled ? UIColor(rgb: 0xFFFFFF) : UIColor(rgb: 0xF5F7FA)
var baseColor: UIColor = BuildSettings.newAppLayoutEnabled ? UIColor(rgb: 0xFFFFFF) : UIColor(rgb: 0xF5F7FA)
var baseIconPrimaryColor: UIColor = UIColor(rgb: 0xFFFFFF)
var baseTextPrimaryColor: UIColor = UIColor(rgb: 0xFFFFFF)
var baseTextSecondaryColor: UIColor = UIColor(rgb: 0x8F97A3)
Expand All @@ -34,7 +34,7 @@ class DefaultTheme: NSObject, Theme {
var searchPlaceholderColor: UIColor = UIColor(rgb: 0x8F97A3)
var searchResultHighlightColor: UIColor = UIColor(rgb: 0xFCC639).withAlphaComponent(0.2)

var headerBackgroundColor: UIColor = BuildSettings.newAppLayoutEnaled ? UIColor(rgb: 0xFFFFFF) : UIColor(rgb: 0xF5F7FA)
var headerBackgroundColor: UIColor = BuildSettings.newAppLayoutEnabled ? UIColor(rgb: 0xFFFFFF) : UIColor(rgb: 0xF5F7FA)
var headerBorderColor: UIColor = UIColor(rgb: 0xE9EDF1)
var headerTextPrimaryColor: UIColor = UIColor(rgb: 0x17191C)
var headerTextSecondaryColor: UIColor = UIColor(rgb: 0x737D8C)
Expand Down Expand Up @@ -134,7 +134,7 @@ class DefaultTheme: NSObject, Theme {
if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()

if BuildSettings.newAppLayoutEnaled {
if BuildSettings.newAppLayoutEnabled {
appearance.configureWithDefaultBackground()
} else {
appearance.configureWithOpaqueBackground()
Expand All @@ -150,7 +150,7 @@ class DefaultTheme: NSObject, Theme {

navigationBar.standardAppearance = appearance

if BuildSettings.newAppLayoutEnaled {
if BuildSettings.newAppLayoutEnabled {
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = baseColor
appearance.shadowColor = nil
Expand Down Expand Up @@ -178,7 +178,7 @@ class DefaultTheme: NSObject, Theme {
searchBar.backgroundImage = UIImage() // Remove top and bottom shadow
searchBar.tintColor = self.tintColor

guard !BuildSettings.newAppLayoutEnaled else {
guard !BuildSettings.newAppLayoutEnabled else {
return
}

Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/Application/LegacyAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -4286,7 +4286,7 @@ - (void)setupUserDefaults
}

// Need to set `showAllRoomsInHomeSpace` to `true` for the new App Layout
if (BuildSettings.newAppLayoutEnaled)
if (BuildSettings.newAppLayoutEnabled)
{
RiotSettings.shared.showAllRoomsInHomeSpace = YES;
}
Expand Down
28 changes: 13 additions & 15 deletions Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ - (instancetype)initWithMatrixSession:(MXSession *)mxSession
_crossSigningBannerDisplay = CrossSigningBannerDisplayNone;
_secureBackupBannerDisplay = SecureBackupBannerDisplayNone;

_areSectionsShrinkable = !BuildSettings.newAppLayoutEnaled;
_areSectionsShrinkable = !BuildSettings.newAppLayoutEnabled;
shrinkedSectionsBitMask = 0;

roomTagsListenerByUserId = [[NSMutableDictionary alloc] init];
Expand Down Expand Up @@ -660,17 +660,15 @@ - (CGFloat)heightForHeaderInSection:(NSInteger)section
return 0.0;
}

CGFloat baseHeight = 0;

if (sectionType == RecentsDataSourceSectionTypeAllChats && _recentsDataSourceMode == RecentsDataSourceModeAllChats)
{
if (self.allChatsFilterOptions.optionsCount)
{
return baseHeight + RECENTSDATASOURCE_ALL_CHATS_SECTION_BOTTOM_VIEW_HEIGHT;
return RECENTSDATASOURCE_ALL_CHATS_SECTION_BOTTOM_VIEW_HEIGHT;
}
}

return baseHeight + RECENTSDATASOURCE_DEFAULT_SECTION_HEADER_HEIGHT;
return RECENTSDATASOURCE_DEFAULT_SECTION_HEADER_HEIGHT;
}

- (NSAttributedString *)attributedStringForHeaderTitleInSection:(NSInteger)section
Expand Down Expand Up @@ -747,24 +745,24 @@ - (NSAttributedString *)attributedStringForHeaderTitleInSection:(NSInteger)secti
}


if (count && !(sectionType == RecentsDataSourceSectionTypeInvites) && !BuildSettings.newAppLayoutEnaled)
if (count && !(sectionType == RecentsDataSourceSectionTypeInvites) && !BuildSettings.newAppLayoutEnabled)
{
NSString *roomCount = [NSString stringWithFormat:@" %tu", count];

NSMutableAttributedString *mutableSectionTitle = [[NSMutableAttributedString alloc] initWithString:title
attributes:@{NSForegroundColorAttributeName : ThemeService.shared.theme.headerTextPrimaryColor,
NSFontAttributeName: [UIFont boldSystemFontOfSize:15.0]}];
attributes:@{NSForegroundColorAttributeName : ThemeService.shared.theme.headerTextPrimaryColor,
NSFontAttributeName: [UIFont boldSystemFontOfSize:15.0]}];
[mutableSectionTitle appendAttributedString:[[NSMutableAttributedString alloc] initWithString:roomCount
attributes:@{NSForegroundColorAttributeName : ThemeService.shared.theme.headerTextSecondaryColor,
NSFontAttributeName: [UIFont boldSystemFontOfSize:15.0]}]];
attributes:@{NSForegroundColorAttributeName : ThemeService.shared.theme.headerTextSecondaryColor,
NSFontAttributeName: [UIFont boldSystemFontOfSize:15.0]}]];

sectionTitle = mutableSectionTitle;
}
else if (title)
{
sectionTitle = [[NSAttributedString alloc] initWithString:[title capitalizedString]
attributes:@{NSForegroundColorAttributeName : ThemeService.shared.theme.headerTextPrimaryColor,
NSFontAttributeName: [ThemeService shared].theme.fonts.calloutSB}];
attributes:@{NSForegroundColorAttributeName : ThemeService.shared.theme.headerTextPrimaryColor,
NSFontAttributeName: [ThemeService shared].theme.fonts.calloutSB}];
}

return sectionTitle;
Expand Down Expand Up @@ -851,7 +849,7 @@ - (UIView *)badgeViewForHeaderTitleInSection:(NSInteger)section

- (UIView *)viewForHeaderInSection:(NSInteger)section withFrame:(CGRect)frame inTableView:(UITableView*)tableView
{
// No header view in key backup banner section
// No header view in key backup banner section, in cross signing banner section, in recent section, nor in all chats section if flters are disabled
RecentsDataSourceSectionType sectionType = [self.sections sectionTypeForSectionIndex:section];
if (sectionType == RecentsDataSourceSectionTypeSecureBackupBanner ||
sectionType == RecentsDataSourceSectionTypeCrossSigningBanner ||
Expand All @@ -870,7 +868,7 @@ - (UIView *)viewForHeaderInSection:(NSInteger)section withFrame:(CGRect)frame in
sectionHeader.frame = frame;
sectionHeader.backgroundView.backgroundColor = ThemeService.shared.theme.headerBackgroundColor;
sectionHeader.topPadding = 0;
sectionHeader.topViewHeight = RECENTSDATASOURCE_DEFAULT_SECTION_HEADER_HEIGHT + sectionHeader.topPadding;
sectionHeader.topViewHeight = RECENTSDATASOURCE_DEFAULT_SECTION_HEADER_HEIGHT;
NSInteger sectionBitwise = 0;

if (_areSectionsShrinkable)
Expand Down Expand Up @@ -971,7 +969,7 @@ - (UIView *)viewForHeaderInSection:(NSInteger)section withFrame:(CGRect)frame in
sectionHeader.bottomView = nil;
}

if (!BuildSettings.newAppLayoutEnaled || !sectionHeader.bottomView)
if (!BuildSettings.newAppLayoutEnabled || !sectionHeader.bottomView)
{
// Add label
frame.size.height = RECENTSDATASOURCE_DEFAULT_SECTION_HEADER_HEIGHT - 10;
Expand Down
14 changes: 9 additions & 5 deletions Riot/Modules/Common/Recents/RecentsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewControllerDataReadyNotification";

@interface RecentsViewController () <CreateRoomCoordinatorBridgePresenterDelegate, RoomsDirectoryCoordinatorBridgePresenterDelegate, RoomNotificationSettingsCoordinatorBridgePresenterDelegate, DialpadViewControllerDelegate, ExploreRoomCoordinatorBridgePresenterDelegate, SpaceChildRoomDetailBridgePresenterDelegate, RoomContextActionServiceDelegate>
@interface RecentsViewController () <CreateRoomCoordinatorBridgePresenterDelegate, RoomsDirectoryCoordinatorBridgePresenterDelegate, RoomNotificationSettingsCoordinatorBridgePresenterDelegate, DialpadViewControllerDelegate, ExploreRoomCoordinatorBridgePresenterDelegate, SpaceChildRoomDetailBridgePresenterDelegate, RoomContextActionServiceDelegate, RecentCellContextMenuProviderDelegate>
{
// Tell whether a recents refresh is pending (suspended during editing mode).
BOOL isRefreshPending;
Expand Down Expand Up @@ -140,6 +140,7 @@ - (void)finalizeInit

_contextMenuProvider = [RecentCellContextMenuProvider new];
self.contextMenuProvider.serviceDelegate = self;
self.contextMenuProvider.menuProviderDelegate = self;

// Set itself as delegate by default.
self.delegate = self;
Expand Down Expand Up @@ -2549,10 +2550,6 @@ - (UIContextMenuConfiguration *)tableView:(UITableView *)tableView contextMenuCo
return nil;
}

#if TARGET_IPHONE_SIMULATOR
#else
self.recentsUpdateEnabled = NO;
#endif
return [self.contextMenuProvider contextMenuConfigurationWith:cellData from:cell session:self.dataSource.mxSession];
}

Expand Down Expand Up @@ -2614,4 +2611,11 @@ - (void)roomContextActionService:(id<RoomContextActionServiceProtocol>)service s
editedRoomId = nil;
}

#pragma mark - RecentCellContextMenuProviderDelegate

- (void)recentCellContextMenuProviderDidStartShowingPreview:(RecentCellContextMenuProvider *)menuProvider
{
self.recentsUpdateEnabled = NO;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public class RecentsListService: NSObject, RecentsListServiceProtocol {
}
}

allChatLayoutSettingsObserver = NotificationCenter.default.addObserver(forName: AllChatsLayoutSettings.didUpdateFilters, object: nil, queue: OperationQueue.main) { [weak self] notification in
allChatLayoutSettingsObserver = NotificationCenter.default.addObserver(forName: AllChatsLayoutSettingsManager.didUpdateActiveFilters, object: nil, queue: OperationQueue.main) { [weak self] notification in
guard let self = self else { return }
if let fetcher = self.allChatsRoomListDataFetcher {
self.updateConversationFetcher(fetcher, for: .allChats)
Expand Down Expand Up @@ -714,25 +714,25 @@ public class RecentsListService: NSObject, RecentsListServiceProtocol {
case .rooms:
fetcher.fetchOptions.filterOptions.notDataTypes = notDataTypes
case .allChats:
let settingsManager = AllChatsLayoutSettingsManager.shared
let settings = AllChatsLayoutSettingsManager.shared.allChatLayoutSettings
if settings.sections.contains(.favourites) && !settings.filters.contains(.favourites) {
notDataTypes.insert(.favorited)
}
if settings.filters.contains(.rooms) && settingsManager.activeFilters.contains(.rooms) {
notDataTypes.insert(.direct)
}
fetcher.fetchOptions.filterOptions.notDataTypes = notDataTypes

if settings.filters.contains(.unreads) && settings.activeFilters.contains(.unreads) {
if settings.filters.contains(.unreads) && settingsManager.activeFilters.contains(.unreads) {
fetcher.fetchOptions.filterOptions.dataTypes = [.unread]
return
}
if settings.filters.contains(.rooms) && settings.activeFilters.contains(.rooms) {
fetcher.fetchOptions.filterOptions.dataTypes = [.notDirect]
return
}
if settings.filters.contains(.people) && settings.activeFilters.contains(.people) {
if settings.filters.contains(.people) && settingsManager.activeFilters.contains(.people) {
fetcher.fetchOptions.filterOptions.dataTypes = [.direct]
return
}
if settings.filters.contains(.favourites) && settings.activeFilters.contains(.favourites) {
if settings.filters.contains(.favourites) && settingsManager.activeFilters.contains(.favourites) {
fetcher.fetchOptions.filterOptions.dataTypes = [.favorited]
return
}
Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/Common/Recents/Views/RecentTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ - (void)render:(MXKCellData *)cellData
// Notify unreads and bing
if (roomCellData.hasUnread)
{
self.missedNotifAndUnreadIndicator.hidden = BuildSettings.newAppLayoutEnaled;
self.missedNotifAndUnreadIndicator.hidden = BuildSettings.newAppLayoutEnabled;

if (0 < roomCellData.notificationCount)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class AllChatsFilterOptionListView: UIView, Themable {
// MARK: - Lifecycle

override init(frame: CGRect) {
super .init(frame: frame)
super.init(frame: frame)
setupView()
}

Expand Down
4 changes: 2 additions & 2 deletions Riot/Modules/Common/SectionHeaders/SectionHeaderView.m
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ - (void)layoutSubviews
if (_bottomView)
{
// reset margins
leftMargin = MAX(_leftInset, 0);
rightMargin = MAX(_rightInset, 0);
leftMargin = MAX(_leftInset, 16);
rightMargin = MAX(_rightInset, 16);

CGRect frame = _bottomView.frame;
frame.origin.x = leftMargin;
Expand Down
19 changes: 8 additions & 11 deletions Riot/Modules/Common/SectionHeaders/TabListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TabListView: UIView {
updateCursor()
}
}
var unselectedItemColor: UIColor! = .lightGray {
var unselectedItemColor: UIColor = .lightGray {
didSet {
updateCursor()
}
Expand Down Expand Up @@ -86,13 +86,10 @@ class TabListView: UIView {
setupView()
}

override func willMove(toSuperview newSuperview: UIView?) {
super.willMove(toSuperview: newSuperview)
}

override func layoutSubviews() {
super.layoutSubviews()

itemsContentView.layoutIfNeeded()
updateCursor()
}

Expand Down Expand Up @@ -190,18 +187,18 @@ class TabListView: UIView {
return
}

let focusedbutton = itemViews[Int(integral)]
let focusedButton = itemViews[Int(integral)]
let nextButtonIndex = Int(integral) + 1

let x: Double
let width: Double
if nextButtonIndex < itemViews.count {
let nextButton = itemViews[nextButtonIndex]
x = focusedbutton.frame.minX + (nextButton.frame.minX - focusedbutton.frame.minX) * fractional
width = focusedbutton.frame.width + (nextButton.frame.width - focusedbutton.frame.width) * fractional
x = focusedButton.frame.minX + (nextButton.frame.minX - focusedButton.frame.minX) * fractional
width = focusedButton.frame.width + (nextButton.frame.width - focusedButton.frame.width) * fractional
} else {
x = focusedbutton.frame.minX
width = focusedbutton.frame.width
x = focusedButton.frame.minX
width = focusedButton.frame.width
}

cursorView.frame = CGRect(x: x,
Expand All @@ -210,7 +207,7 @@ class TabListView: UIView {
height: Constants.cursorHeight)

for button in self.itemViews {
if button == focusedbutton {
if button == focusedButton {
button.tintColor = self.tintColor
} else {
button.tintColor = self.unselectedItemColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@

import Foundation

@objc
protocol RecentCellContextMenuProviderDelegate: AnyObject {
func recentCellContextMenuProviderDidStartShowingPreview(_ menuProvider: RecentCellContextMenuProvider)
}

/// Helper class `RecentCellContextMenuProvider` that provides an instace of `UIContextMenuConfiguration` from an instance of `MXKRecentCellDataStoring`
@objcMembers
class RecentCellContextMenuProvider: NSObject {

weak var serviceDelegate: RoomContextActionServiceDelegate?
weak var menuProviderDelegate: RecentCellContextMenuProviderDelegate?
private var currentService: RoomContextActionServiceProtocol?

@available(iOS 13.0, *)
Expand All @@ -39,7 +45,11 @@ class RecentCellContextMenuProvider: NSObject {
let service = RoomContextActionService(room: room, delegate: serviceDelegate)
self.currentService = service
let actionProvider = RoomActionProvider(service: service)
return UIContextMenuConfiguration(identifier: cellData.roomIdentifier as NSString) {
return UIContextMenuConfiguration(identifier: cellData.roomIdentifier as NSString) { [weak self] in
if let self = self {
self.menuProviderDelegate?.recentCellContextMenuProviderDidStartShowingPreview(self)
}

if room.summary?.isJoined == true {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
guard let roomViewController = storyboard.instantiateViewController(withIdentifier: "RoomViewControllerStoryboardId") as? RoomViewController else {
Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/GlobalSearch/UnifiedSearchViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ - (void)viewWillAppear:(BOOL)animated

[self updateSearch];

if (BuildSettings.newAppLayoutEnaled)
if (BuildSettings.newAppLayoutEnabled)
{
[self.searchBar vc_searchTextField].backgroundColor = nil;
[self vc_setLargeTitleDisplayMode: UINavigationItemLargeTitleDisplayModeAutomatic];
Expand Down
Loading

0 comments on commit 9d3c49a

Please sign in to comment.