mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-20 22:52:12 +02:00
HomeVC: Killed SearchVC as HomeVC fully replaces it now
This commit is contained in:
@@ -236,32 +236,12 @@
|
||||
<connections>
|
||||
<segue destination="vC3-pB-5Vb" kind="showDetail" identifier="showDetails" id="Vo4-8x-dtH"/>
|
||||
<segue destination="ZlD-EU-ncw" kind="presentation" identifier="showAuth" id="vqM-5M-ctF"/>
|
||||
<segue destination="Z3B-Hn-xls" kind="show" identifier="presentSearch" id="qSw-cw-b9m"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Po3-cj-dhS" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="2188" y="-2350"/>
|
||||
</scene>
|
||||
<!--Search View Controller-->
|
||||
<scene sceneID="8iN-4m-YPt">
|
||||
<objects>
|
||||
<viewController id="Z3B-Hn-xls" customClass="SearchViewController" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="dW9-Ul-v50"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="59X-hG-qRJ"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="bwK-gl-okx">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<animations/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="C8X-sk-odI" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="2796" y="-2319"/>
|
||||
</scene>
|
||||
<!--RoomNav-->
|
||||
<scene sceneID="r7l-gg-dq7">
|
||||
<objects>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#import "SegmentedViewController.h"
|
||||
|
||||
@interface HomeViewController : SegmentedViewController <UISearchBarDelegate>
|
||||
@interface HomeViewController : SegmentedViewController <UISearchBarDelegate, UIGestureRecognizerDelegate>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIBarButtonItem *settingsBarButtonItem;
|
||||
@property (weak, nonatomic) IBOutlet UIBarButtonItem *searchBarButtonIem;
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
|
||||
#import "VectorDesignValues.h"
|
||||
|
||||
#import "SearchViewController.h"
|
||||
|
||||
@interface RecentsViewController ()
|
||||
{
|
||||
// Recents refresh handling
|
||||
@@ -303,11 +301,6 @@
|
||||
controller.navigationItem.leftItemsSupplementBackButton = YES;
|
||||
}
|
||||
}
|
||||
else if ([[segue identifier] isEqualToString:@"presentSearch"])
|
||||
{
|
||||
SearchViewController *searchViewController = (SearchViewController*)segue.destinationViewController;
|
||||
[searchViewController displayWithSession:self.dataSource.mxSession];
|
||||
}
|
||||
|
||||
// Hide back button title
|
||||
self.navigationItem.backBarButtonItem =[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 OpenMarket Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "SegmentedViewController.h"
|
||||
|
||||
@class MXSession;
|
||||
|
||||
@interface SearchViewController : SegmentedViewController <UISearchBarDelegate>
|
||||
|
||||
- (void)displayWithSession:(MXSession*)session;
|
||||
|
||||
@end
|
||||
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 OpenMarket Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "SearchViewController.h"
|
||||
|
||||
#import "RecentsViewController.h"
|
||||
#import "RecentsDataSource.h"
|
||||
|
||||
@interface SearchViewController ()
|
||||
{
|
||||
// The search bar
|
||||
UISearchBar *searchBar;
|
||||
|
||||
// The view controller used under the "rooms" tab.
|
||||
// This is a RecentsViewController which is used only for its search feature.
|
||||
// This means that the search is done locally
|
||||
RecentsViewController *roomsSearchViewController;
|
||||
RecentsDataSource *roomsSearchDataSource;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation SearchViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
searchBar = [[UISearchBar alloc] initWithFrame:self.navigationController.navigationBar.frame];
|
||||
searchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
searchBar.showsCancelButton = YES;
|
||||
searchBar.returnKeyType = UIReturnKeyDone; // UIReturnKeySearch
|
||||
searchBar.delegate = self;
|
||||
|
||||
self.navigationItem.leftBarButtonItem = [UIBarButtonItem new];
|
||||
self.navigationItem.titleView = searchBar;
|
||||
|
||||
self.backgroundImageView.image = [UIImage imageNamed:@"search_bg"];
|
||||
|
||||
// This is a VC for searching. So, show the keyboard with the VC
|
||||
[searchBar becomeFirstResponder];
|
||||
}
|
||||
|
||||
- (void)displayWithSession:(MXSession *)session
|
||||
{
|
||||
NSMutableArray* viewControllers = [[NSMutableArray alloc] init];
|
||||
NSMutableArray* titles = [[NSMutableArray alloc] init];
|
||||
|
||||
[titles addObject: NSLocalizedStringFromTable(@"Rooms", @"Vector", nil)];
|
||||
roomsSearchViewController = [RecentsViewController recentListViewController];
|
||||
roomsSearchDataSource = [[RecentsDataSource alloc] initWithMatrixSession:session];
|
||||
[roomsSearchViewController displayList:roomsSearchDataSource];
|
||||
[viewControllers addObject:roomsSearchViewController];
|
||||
|
||||
[titles addObject: NSLocalizedStringFromTable(@"Messages", @"Vector", nil)];
|
||||
RecentsViewController *recentsViewController = [RecentsViewController recentListViewController];
|
||||
RecentsDataSource *recentlistDataSource = [[RecentsDataSource alloc] initWithMatrixSession:session];
|
||||
[recentsViewController displayList:recentlistDataSource];
|
||||
[viewControllers addObject:recentsViewController];
|
||||
|
||||
[titles addObject: NSLocalizedStringFromTable(@"People", @"Vector", nil)];
|
||||
/*RecentsViewController**/ recentsViewController = [RecentsViewController recentListViewController];
|
||||
/*RecentsDataSource **/recentlistDataSource = [[RecentsDataSource alloc] initWithMatrixSession:session];
|
||||
[recentsViewController displayList:recentlistDataSource];
|
||||
[viewControllers addObject:recentsViewController];
|
||||
|
||||
//segmentedViewController.title = NSLocalizedStringFromTable(@"room_details_title", @"Vector", nil);
|
||||
[self initWithTitles:titles viewControllers:viewControllers defaultSelected:0];
|
||||
|
||||
// to display a red navbar when the home server cannot be reached.
|
||||
[self addMatrixSession:session];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
// Reset current results
|
||||
[self updateSearch];
|
||||
}
|
||||
|
||||
// Update search results under the currently selected tab
|
||||
- (void)updateSearch
|
||||
{
|
||||
if (searchBar.text.length)
|
||||
{
|
||||
self.displayedViewController.view.hidden = NO;
|
||||
|
||||
// Forward the search request to the data source
|
||||
if (self.displayedViewController == roomsSearchViewController)
|
||||
{
|
||||
[roomsSearchDataSource searchWithPatterns:@[searchBar.text]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Nothing to search = Show nothing
|
||||
self.displayedViewController.view.hidden = YES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - UISearchBarDelegate
|
||||
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
|
||||
{
|
||||
if (self.displayedViewController == roomsSearchViewController)
|
||||
{
|
||||
// As the search is local, it can be updated on each text change
|
||||
[self updateSearch];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar2
|
||||
{
|
||||
// "Done" key has been pressed
|
||||
[searchBar resignFirstResponder];
|
||||
}
|
||||
|
||||
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar2
|
||||
{
|
||||
// Leave search
|
||||
[searchBar resignFirstResponder];
|
||||
|
||||
// Leave this VC
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user