Skip to content

Commit

Permalink
Feature request: Search function #482
Browse files Browse the repository at this point in the history
1. Fix the problem which still scroll down even user scroll up.
2. Fix the problem which macOS not show the toolbar.
  • Loading branch information
poormusic2001 authored and tmolitor-stud-tu committed Dec 2, 2020
1 parent f8e3b62 commit 0e41bf5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions Monal/Classes/MLSearchViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- (void) doReloadActionForAllTableView;
- (void) doReloadHistoryForSearch;
- (void) doGetMsgData;
- (void) doShowLoadingHistory:(NSString* _Nonnull) title;
@end

NS_ASSUME_NONNULL_BEGIN
Expand Down
13 changes: 11 additions & 2 deletions Monal/Classes/MLSearchViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,17 @@ - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
if ([self.searchResultMessageList count] >0)
{
self.toolbar.items = @[self.epmtyItem, self.prevItem, self.nextItem, self.searchResultIndicatorItem];
self.searchBar.inputAccessoryView = self.toolbar;
#if TARGET_OS_MACCATALYST
CGFloat yAxis = self.view.frame.size.height - self.searchBar.frame.size.height;
[self.toolbar setFrame:CGRectMake(0, yAxis, self.searchBar.frame.size.width, self.searchBar.frame.size.height)];
[self.view addSubview:self.toolbar];
#else
self.searchBar.inputAccessoryView = self.toolbar;
#endif
self.curIdxHistory = (int)[self.searchResultMessageList count] - 1;

[self setResultIndicatorTitle:@"" onlyHint:NO];
[self.searchBar reloadInputViews];
}
else
{
Expand Down Expand Up @@ -146,6 +153,7 @@ - (void)doNextAction
self.isLoadingHistory = YES;
self.curIdxHistory -= 1;
[self.searchResultDelegate doReloadHistoryForSearch];
[self setResultIndicatorTitle:NSLocalizedString(@"Loading more Messages from Server", @"") onlyHint:YES];
}
}
else
Expand Down Expand Up @@ -173,6 +181,7 @@ - (void)doPreviousAction
self.curIdxHistory += 1;
self.isLoadingHistory = YES;
[self.searchResultDelegate doReloadHistoryForSearch];
[self setResultIndicatorTitle:NSLocalizedString(@"Loading more Messages from Server", @"") onlyHint:YES];
}
}
else
Expand All @@ -192,10 +201,10 @@ - (void)setResultIndicatorTitle:(NSString*)title onlyHint:(BOOL)isOnlyHint
else
{
finalTitle = title;
[self.searchResultDelegate doShowLoadingHistory:finalTitle];
}

[self.searchResultIndicatorItem setTitle:finalTitle];
[self.searchBar reloadInputViews];
[self.searchResultDelegate doReloadActionForAllTableView];
}

Expand Down
21 changes: 13 additions & 8 deletions Monal/Classes/chatViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -349,18 +349,23 @@ -(void) doSetNotLoadingHistory
{
self.searchController.isLoadingHistory = NO;
[self.searchController setResultToolBar];
if (self.searchController.isGoingUp)
{
[self.searchController doPreviousAction];
}
else
{
[self.searchController doNextAction];
}
}
[self doGetMsgData];
}

-(void)doShowLoadingHistory:(NSString *)title
{
UIAlertController *loadingWarning = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Hint", @"")
message:title preferredStyle:UIAlertControllerStyleAlert];

[self presentViewController:loadingWarning animated:YES completion:^{
dispatch_queue_t queue = dispatch_get_main_queue();
dispatch_after(2.0, queue, ^{
[loadingWarning dismissViewControllerAnimated:YES completion:nil];
});
}];
}


-(void) doSetMsgPathIdx:(NSInteger) pathIdx withDBId:(NSNumber *) messageDBId
{
Expand Down

0 comments on commit 0e41bf5

Please sign in to comment.