mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Public rooms search: Directory page starts to work (with cells from MatrixKit)
This commit is contained in:
parent
10de4757d3
commit
e71a4a090d
11 changed files with 108 additions and 37 deletions
|
@ -158,6 +158,9 @@
|
||||||
"media_picker_choose_from_library" = "Choose from library";
|
"media_picker_choose_from_library" = "Choose from library";
|
||||||
"media_picker_library" = "Library";
|
"media_picker_library" = "Library";
|
||||||
|
|
||||||
|
// Directory
|
||||||
|
"directory_title" = "Directory";
|
||||||
|
|
||||||
// Others
|
// Others
|
||||||
"you" = "You";
|
"you" = "You";
|
||||||
"public_room_section_title" = "Public Rooms (at %@):";
|
"public_room_section_title" = "Public Rooms (at %@):";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="H1p-Uh-vWS">
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="H1p-Uh-vWS">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment identifier="iOS"/>
|
<deployment identifier="iOS"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
|
||||||
|
@ -201,7 +201,7 @@
|
||||||
<segue destination="cLJ-Zo-cIe" kind="presentation" identifier="presentRoomCreationStep1" id="EwV-tH-4jl"/>
|
<segue destination="cLJ-Zo-cIe" kind="presentation" identifier="presentRoomCreationStep1" id="EwV-tH-4jl"/>
|
||||||
<segue destination="vC3-pB-5Vb" kind="showDetail" identifier="showDetails" id="agy-3r-khl"/>
|
<segue destination="vC3-pB-5Vb" kind="showDetail" identifier="showDetails" id="agy-3r-khl"/>
|
||||||
<segue destination="ZlD-EU-ncw" kind="presentation" identifier="showAuth" id="vfC-8C-AsT"/>
|
<segue destination="ZlD-EU-ncw" kind="presentation" identifier="showAuth" id="vfC-8C-AsT"/>
|
||||||
<segue destination="dP6-5F-5s0" kind="show" identifier="showDirectory" id="hvq-zV-OB7"/>
|
<segue destination="dP6-5F-5s0" kind="showDetail" identifier="showDirectory" action="showViewController:sender:" id="hvq-zV-OB7"/>
|
||||||
</connections>
|
</connections>
|
||||||
</viewController>
|
</viewController>
|
||||||
<placeholder placeholderIdentifier="IBFirstResponder" id="pF2-9z-Wl6" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
<placeholder placeholderIdentifier="IBFirstResponder" id="pF2-9z-Wl6" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
@ -216,20 +216,6 @@
|
||||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||||
<prototypes>
|
|
||||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="sgB-0b-hbe">
|
|
||||||
<rect key="frame" x="0.0" y="92" width="600" height="44"/>
|
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
|
||||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="sgB-0b-hbe" id="29k-1a-GRN">
|
|
||||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
|
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
|
||||||
</tableViewCellContentView>
|
|
||||||
</tableViewCell>
|
|
||||||
</prototypes>
|
|
||||||
<connections>
|
|
||||||
<outlet property="dataSource" destination="dP6-5F-5s0" id="977-CD-fdo"/>
|
|
||||||
<outlet property="delegate" destination="dP6-5F-5s0" id="ycx-Nj-kqv"/>
|
|
||||||
</connections>
|
|
||||||
</tableView>
|
</tableView>
|
||||||
</tableViewController>
|
</tableViewController>
|
||||||
<placeholder placeholderIdentifier="IBFirstResponder" id="yn2-Xd-dn4" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
<placeholder placeholderIdentifier="IBFirstResponder" id="yn2-Xd-dn4" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
There is no way in Matrix to be notified when there is a change in the public room directory.
|
There is no way in Matrix to be notified when there is a change in the public room directory.
|
||||||
As a workaround, the data source refreshes its data when there are more than 10s old.
|
As a workaround, the data source refreshes its data when there are more than 10s old.
|
||||||
*/
|
*/
|
||||||
@interface PublicRoomsDirectoryDataSource : MXKDataSource <UITableViewDataSource, MXKDataSourceDelegate>
|
@interface PublicRoomsDirectoryDataSource : MXKDataSource <UITableViewDataSource>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
All public rooms of the directory.
|
All public rooms of the directory.
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
#import "PublicRoomsDirectoryDataSource.h"
|
#import "PublicRoomsDirectoryDataSource.h"
|
||||||
|
|
||||||
|
#import "MXKPublicRoomTableViewCell.h"
|
||||||
|
|
||||||
#pragma mark - Constants definitions
|
#pragma mark - Constants definitions
|
||||||
|
|
||||||
// Time in seconds from which public rooms data is considered as obsolete
|
// Time in seconds from which public rooms data is considered as obsolete
|
||||||
|
@ -124,4 +126,26 @@ double const kPublicRoomsDirectoryDataExpiration = 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - UITableViewDataSource
|
||||||
|
|
||||||
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||||
|
{
|
||||||
|
return _filteredRooms.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
|
{
|
||||||
|
// For now reuse MatrixKit cells
|
||||||
|
// TODO: use custom cells and manage a mechanism a la MatrixKit with cellData
|
||||||
|
MXKPublicRoomTableViewCell *publicRoomCell = [tableView dequeueReusableCellWithIdentifier:[MXKPublicRoomTableViewCell defaultReuseIdentifier]];
|
||||||
|
if (!publicRoomCell)
|
||||||
|
{
|
||||||
|
publicRoomCell = [[MXKPublicRoomTableViewCell alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
[publicRoomCell render:_filteredRooms[indexPath.row]];
|
||||||
|
|
||||||
|
return publicRoomCell;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
#import <MatrixKit/MatrixKit.h>
|
#import <MatrixKit/MatrixKit.h>
|
||||||
|
|
||||||
|
@class PublicRoomsDirectoryDataSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
'RecentsDataSource' class inherits from 'MXKInterleavedRecentsDataSource' to define Vector recents source.
|
'RecentsDataSource' class inherits from 'MXKInterleavedRecentsDataSource' to define Vector recents source.
|
||||||
*/
|
*/
|
||||||
|
@ -44,10 +46,15 @@
|
||||||
@property (nonatomic, copy) NSIndexPath* droppingCellIndexPath;
|
@property (nonatomic, copy) NSIndexPath* droppingCellIndexPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The movingCellBackgroundImage;
|
The movingCellBackgroundImage.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic) UIImageView* droppingCellBackGroundView;
|
@property (nonatomic) UIImageView* droppingCellBackGroundView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The data source used to manage search in public rooms.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, readonly) PublicRoomsDirectoryDataSource *publicRoomsDirectoryDataSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return the header height from the section.
|
Return the header height from the section.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,8 +32,6 @@
|
||||||
NSMutableArray* conversationCellDataArray;
|
NSMutableArray* conversationCellDataArray;
|
||||||
NSMutableArray* lowPriorityCellDataArray;
|
NSMutableArray* lowPriorityCellDataArray;
|
||||||
|
|
||||||
PublicRoomsDirectoryDataSource *publicRoomsDirectoryDataSource;
|
|
||||||
|
|
||||||
NSInteger directorySection;
|
NSInteger directorySection;
|
||||||
NSInteger invitesSection;
|
NSInteger invitesSection;
|
||||||
NSInteger favoritesSection;
|
NSInteger favoritesSection;
|
||||||
|
@ -80,10 +78,10 @@
|
||||||
|
|
||||||
// Initialise the public room directory data source
|
// Initialise the public room directory data source
|
||||||
// Note that it is single matrix session only for now
|
// Note that it is single matrix session only for now
|
||||||
if (!publicRoomsDirectoryDataSource)
|
if (!_publicRoomsDirectoryDataSource)
|
||||||
{
|
{
|
||||||
publicRoomsDirectoryDataSource = [[PublicRoomsDirectoryDataSource alloc] initWithMatrixSession:mxSession];
|
_publicRoomsDirectoryDataSource = [[PublicRoomsDirectoryDataSource alloc] initWithMatrixSession:mxSession];
|
||||||
publicRoomsDirectoryDataSource.delegate = self;
|
_publicRoomsDirectoryDataSource.delegate = self;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,17 +100,17 @@
|
||||||
[roomTagsListenerByUserId removeObjectForKey:matrixSession.myUser.userId];
|
[roomTagsListenerByUserId removeObjectForKey:matrixSession.myUser.userId];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (publicRoomsDirectoryDataSource.mxSession == matrixSession)
|
if (_publicRoomsDirectoryDataSource.mxSession == matrixSession)
|
||||||
{
|
{
|
||||||
[publicRoomsDirectoryDataSource destroy];
|
[_publicRoomsDirectoryDataSource destroy];
|
||||||
publicRoomsDirectoryDataSource = nil;
|
_publicRoomsDirectoryDataSource = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dataSource:(MXKDataSource*)dataSource didStateChange:(MXKDataSourceState)aState
|
- (void)dataSource:(MXKDataSource*)dataSource didStateChange:(MXKDataSourceState)aState
|
||||||
{
|
{
|
||||||
if (dataSource == publicRoomsDirectoryDataSource)
|
if (dataSource == _publicRoomsDirectoryDataSource)
|
||||||
{
|
{
|
||||||
[self refreshRoomsSectionsAndReload];
|
[self refreshRoomsSectionsAndReload];
|
||||||
}
|
}
|
||||||
|
@ -294,7 +292,7 @@
|
||||||
directoryCell = [[DirectoryRecentTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[DirectoryRecentTableViewCell defaultReuseIdentifier]];
|
directoryCell = [[DirectoryRecentTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[DirectoryRecentTableViewCell defaultReuseIdentifier]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[directoryCell render:publicRoomsDirectoryDataSource];
|
[directoryCell render:_publicRoomsDirectoryDataSource];
|
||||||
|
|
||||||
return directoryCell;
|
return directoryCell;
|
||||||
}
|
}
|
||||||
|
@ -529,7 +527,7 @@
|
||||||
// Manage the public room search results cell outside the recents.
|
// Manage the public room search results cell outside the recents.
|
||||||
// Show the cell showing the public rooms directory search result
|
// Show the cell showing the public rooms directory search result
|
||||||
// once a search is active
|
// once a search is active
|
||||||
if (publicRoomsDirectoryDataSource.filter)
|
if (_publicRoomsDirectoryDataSource.filter)
|
||||||
{
|
{
|
||||||
directorySection = sectionIndex;
|
directorySection = sectionIndex;
|
||||||
sectionIndex++;
|
sectionIndex++;
|
||||||
|
@ -653,11 +651,11 @@
|
||||||
{
|
{
|
||||||
[super searchWithPatterns:patternsList];
|
[super searchWithPatterns:patternsList];
|
||||||
|
|
||||||
if (patternsList && publicRoomsDirectoryDataSource)
|
if (patternsList && _publicRoomsDirectoryDataSource)
|
||||||
{
|
{
|
||||||
// Search only on the first pattern
|
// Search only on the first pattern
|
||||||
// XXX: Why is it an array?
|
// XXX: Why is it an array?
|
||||||
publicRoomsDirectoryDataSource.filter = patternsList[0];
|
_publicRoomsDirectoryDataSource.filter = patternsList[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,15 @@
|
||||||
|
|
||||||
#import <MatrixKit/MatrixKit.h>
|
#import <MatrixKit/MatrixKit.h>
|
||||||
|
|
||||||
@interface DirectoryViewController : MXKTableViewController
|
@class PublicRoomsDirectoryDataSource;
|
||||||
|
|
||||||
|
@interface DirectoryViewController : MXKTableViewController <UITableViewDelegate>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Display data managed by the passed `PublicRoomsDirectoryDataSource`.
|
||||||
|
|
||||||
|
@param dataSource the data source serving the data.
|
||||||
|
*/
|
||||||
|
- (void)displayWitDataSource:(PublicRoomsDirectoryDataSource*)dataSource;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -16,20 +16,35 @@
|
||||||
|
|
||||||
#import "DirectoryViewController.h"
|
#import "DirectoryViewController.h"
|
||||||
|
|
||||||
|
#import "PublicRoomsDirectoryDataSource.h"
|
||||||
|
|
||||||
@interface DirectoryViewController ()
|
@interface DirectoryViewController ()
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation DirectoryViewController
|
@implementation DirectoryViewController
|
||||||
|
|
||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad
|
||||||
|
{
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
// Do any additional setup after loading the view.
|
|
||||||
|
self.title = NSLocalizedStringFromTable(@"directory_title", @"Vector", nil);
|
||||||
|
|
||||||
|
self.tableView.delegate = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didReceiveMemoryWarning {
|
|
||||||
[super didReceiveMemoryWarning];
|
- (void)viewWillAppear:(BOOL)animated
|
||||||
// Dispose of any resources that can be recreated.
|
{
|
||||||
|
[super viewWillAppear:animated];
|
||||||
|
|
||||||
|
[self.tableView reloadData];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)displayWitDataSource:(PublicRoomsDirectoryDataSource *)dataSource
|
||||||
|
{
|
||||||
|
// Let the data source provide cells
|
||||||
|
self.tableView.dataSource = dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -42,4 +57,10 @@
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma mark - UITableViewDelegate
|
||||||
|
|
||||||
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
|
{
|
||||||
|
return 72;
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -53,6 +53,12 @@
|
||||||
*/
|
*/
|
||||||
- (void)closeSelectedRoom;
|
- (void)closeSelectedRoom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Open the public rooms directory page.
|
||||||
|
It uses the `publicRoomsDirectoryDataSource` managed by the recents view controller data source
|
||||||
|
*/
|
||||||
|
- (void)showPublicRoomsDirectory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Action registered on `UIControlEventTouchUpInside` event for both buttons.
|
Action registered on `UIControlEventTouchUpInside` event for both buttons.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#import "RecentsViewController.h"
|
#import "RecentsViewController.h"
|
||||||
|
|
||||||
#import "RoomViewController.h"
|
#import "RoomViewController.h"
|
||||||
|
#import "DirectoryViewController.h"
|
||||||
|
|
||||||
@interface HomeViewController ()
|
@interface HomeViewController ()
|
||||||
{
|
{
|
||||||
|
@ -312,6 +313,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)showPublicRoomsDirectory
|
||||||
|
{
|
||||||
|
[self performSegueWithIdentifier:@"showDirectory" sender:self];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Internal methods
|
#pragma mark - Internal methods
|
||||||
|
|
||||||
// Made the currently displayed child update its selected cell
|
// Made the currently displayed child update its selected cell
|
||||||
|
@ -379,6 +385,11 @@
|
||||||
controller.navigationItem.leftItemsSupplementBackButton = YES;
|
controller.navigationItem.leftItemsSupplementBackButton = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ([[segue identifier] isEqualToString:@"showDirectory"])
|
||||||
|
{
|
||||||
|
DirectoryViewController *directoryViewController = segue.destinationViewController;
|
||||||
|
[directoryViewController displayWitDataSource:recentsDataSource.publicRoomsDirectoryDataSource];
|
||||||
|
}
|
||||||
|
|
||||||
// Hide back button title
|
// Hide back button title
|
||||||
self.navigationItem.backBarButtonItem =[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
|
self.navigationItem.backBarButtonItem =[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#import "VectorDesignValues.h"
|
#import "VectorDesignValues.h"
|
||||||
|
|
||||||
#import "InviteRecentTableViewCell.h"
|
#import "InviteRecentTableViewCell.h"
|
||||||
|
#import "DirectoryRecentTableViewCell.h"
|
||||||
|
|
||||||
@interface RecentsViewController ()
|
@interface RecentsViewController ()
|
||||||
{
|
{
|
||||||
|
@ -458,6 +459,11 @@ static NSMutableDictionary* backgroundByImageNameDict;
|
||||||
// hide the selection
|
// hide the selection
|
||||||
[tableView deselectRowAtIndexPath:indexPath animated:NO];
|
[tableView deselectRowAtIndexPath:indexPath animated:NO];
|
||||||
}
|
}
|
||||||
|
else if ([cell isKindOfClass:[DirectoryRecentTableViewCell class]])
|
||||||
|
{
|
||||||
|
// Show the directory screen
|
||||||
|
[homeViewController showPublicRoomsDirectory];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
|
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
|
||||||
|
|
Loading…
Reference in a new issue