Add 'Dial pad' option to plus menu on homescreen

This commit is contained in:
Simon Wiedmer
2021-06-07 11:21:34 +02:00
parent bdf724c9a3
commit b04222a91c
@@ -72,6 +72,8 @@
@property (nonatomic, strong) SpaceFeatureUnavailablePresenter *spaceFeatureUnavailablePresenter;
@property (nonatomic, strong) CustomSizedPresentationController *customSizedPresentationController;
@end
@implementation RecentsViewController
@@ -1796,6 +1798,21 @@
}]];
[currentAlert addAction:[UIAlertAction
actionWithTitle:NSLocalizedStringFromTable(@"room_open_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) {
@@ -1815,6 +1832,46 @@
[self presentViewController:currentAlert animated:YES completion:nil];
}
- (void)openDialpad
{
DialpadViewController *controller = [DialpadViewController instantiateWithConfiguration:[DialpadConfiguration default]];
controller.delegate = self;
self.customSizedPresentationController = [[CustomSizedPresentationController alloc] initWithPresentedViewController:controller presentingViewController:self];
self.customSizedPresentationController.dismissOnBackgroundTap = NO;
self.customSizedPresentationController.cornerRadius = 16;
controller.transitioningDelegate = self.customSizedPresentationController;
[self presentViewController:controller animated:YES completion:nil];
}
- (void)dialpadViewControllerDidTapCall:(DialpadViewController *)viewController withPhoneNumber:(NSString *)phoneNumber
{
if (self.mainSession.callManager && phoneNumber.length > 0)
{
[self startActivityIndicator];
[viewController dismissViewControllerAnimated:YES completion:^{
MXWeakify(self);
[self.mainSession.callManager placeCallAgainst:phoneNumber withVideo:NO success:^(MXCall * _Nonnull call) {
MXStrongifyAndReturnIfNil(self);
[self stopActivityIndicator];
self.customSizedPresentationController = nil;
// 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;
}
- (void)createNewRoom
{
// Sanity check