Open dialpad on people tab

This commit is contained in:
ismailgulek
2021-01-13 22:30:03 +03:00
parent 06294825d5
commit 4b8ea3b431
+99 -3
View File
@@ -29,7 +29,7 @@
#import "Riot-Swift.h"
@interface PeopleViewController ()
@interface PeopleViewController () <DialpadViewControllerDelegate>
{
NSInteger directRoomsSectionNumber;
@@ -39,6 +39,8 @@
RecentsDataSource *recentsDataSource;
}
@property (nonatomic, strong) CustomSizedPresentationController *customSizedPresentationController;
@end
@implementation PeopleViewController
@@ -428,8 +430,102 @@
- (void)onPlusButtonPressed
{
// directly open the new chat screen
[self performSegueWithIdentifier:@"presentStartChat" sender:self];
__weak typeof(self) weakSelf = self;
[currentAlert dismissViewControllerAnimated:NO completion:nil];
currentAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"room_recents_start_chat_with", @"Vector", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;
[self performSegueWithIdentifier:@"presentStartChat" sender:self];
}
}]];
[currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"room_recents_dialpad", @"Vector", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;
[self openDialpad];
}
}]];
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;
}
}]];
[currentAlert popoverPresentationController].sourceView = plusButtonImageView;
[currentAlert popoverPresentationController].sourceRect = plusButtonImageView.bounds;
[currentAlert mxk_setAccessibilityIdentifier:@"PeopleVCActionsAlert"];
[self presentViewController:currentAlert animated:YES completion:nil];
}
#pragma mark - Dialpad
- (void)openDialpad
{
DialpadViewController *controller = [DialpadViewController instantiate];
controller.delegate = self;
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
self.customSizedPresentationController = [[CustomSizedPresentationController alloc] initWithPresentedViewController:controller presentingViewController:self];
self.customSizedPresentationController.dismissOnBackgroundTap = NO;
controller.transitioningDelegate = self.customSizedPresentationController;
}
[self presentViewController:controller animated:YES completion:nil];
}
#pragma mark - DialpadViewControllerDelegate
- (void)dialpadViewControllerDidTapCall:(DialpadViewController *)viewController withPhoneNumber:(NSString *)phoneNumber
{
if (self.mainSession.callManager && phoneNumber)
{
[self startActivityIndicator];
[viewController dismissViewControllerAnimated:YES completion:^{
MXWeakify(self);
[self.mainSession.callManager placeCallAgainst:phoneNumber withVideo:NO success:^(MXCall * _Nonnull call) {
MXStrongifyAndReturnIfNil(self);
[self stopActivityIndicator];
// do nothing extra here. UI will be handled automatically by the CallService.
} failure:^(NSError * _Nullable error) {
MXStrongifyAndReturnIfNil(self);
[self stopActivityIndicator];
}];
}];
}
}
- (void)dialpadViewControllerDidTapClose:(DialpadViewController *)viewController
{
[viewController dismissViewControllerAnimated:YES completion:nil];
self.customSizedPresentationController = nil;
}
#pragma mark -