зеркало из https://github.com/nextcloud/talk-ios.git
Show Voice Message Recording View.
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Родитель
c2d442841c
Коммит
df2fbb266c
|
@ -29,6 +29,7 @@
|
|||
|
||||
#import "AFImageDownloader.h"
|
||||
#import "FTPopOverMenu.h"
|
||||
#import "MZTimerLabel.h"
|
||||
#import "NSDate+DateTools.h"
|
||||
#import "UIImageView+AFNetworking.h"
|
||||
#import "UIImageView+Letters.h"
|
||||
|
@ -119,6 +120,8 @@ typedef enum NCChatMessageAction {
|
|||
@property (nonatomic, strong) UIView *inputbarBorderView;
|
||||
@property (nonatomic, strong) UILongPressGestureRecognizer *voiceMessageLongPressGesture;
|
||||
@property (nonatomic, strong) AVAudioRecorder *recorder;
|
||||
@property (nonatomic, strong) UIView *voiceMessageRecordingView;
|
||||
@property (nonatomic, strong) MZTimerLabel *recordingTimerLabel;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -1296,6 +1299,51 @@ NSString * const NCChatViewControllerReplyPrivatelyNotification = @"NCChatViewCo
|
|||
[self.view makeToast:NSLocalizedString(@"Tap and hold to record a voice message, release the button to send it.", nil) duration:3 position:CSToastPositionBottom];
|
||||
}
|
||||
|
||||
- (void)showVoiceMessageRecordingView
|
||||
{
|
||||
_voiceMessageRecordingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 250, self.textInputbar.frame.size.height)];
|
||||
_voiceMessageRecordingView.backgroundColor = [UIColor whiteColor];
|
||||
if (@available(iOS 13.0, *)) {
|
||||
_voiceMessageRecordingView.backgroundColor = [UIColor systemBackgroundColor];
|
||||
}
|
||||
_voiceMessageRecordingView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
|
||||
_recordingTimerLabel = [[MZTimerLabel alloc] initWithFrame:CGRectMake(30, 0, 150, _voiceMessageRecordingView.frame.size.height)];
|
||||
[_recordingTimerLabel setTimerType:MZTimerLabelTypeStopWatch];
|
||||
[_recordingTimerLabel setTimeFormat:@"mm:ss"];
|
||||
[_recordingTimerLabel start];
|
||||
|
||||
UIImageView *blinkingMicView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 12, 26, 26)];
|
||||
[blinkingMicView setImage:[[UIImage imageNamed:@"audio"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
|
||||
[blinkingMicView setTintColor:[UIColor systemRedColor]];
|
||||
[blinkingMicView setContentMode:UIViewContentModeScaleAspectFit];
|
||||
[UIImageView animateWithDuration:0.5
|
||||
delay:0
|
||||
options:(UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse)
|
||||
animations:^{blinkingMicView.alpha = 0;}
|
||||
completion:nil];
|
||||
|
||||
[_voiceMessageRecordingView addSubview:blinkingMicView];
|
||||
[_voiceMessageRecordingView addSubview:_recordingTimerLabel];
|
||||
|
||||
[self.view addSubview:_voiceMessageRecordingView];
|
||||
[self.view bringSubviewToFront:_voiceMessageRecordingView];
|
||||
|
||||
NSDictionary *views = @{@"voiceMessageRecordingView": _voiceMessageRecordingView,
|
||||
@"textInputbar": self.textInputbar};
|
||||
NSDictionary *metrics = @{@"buttonWidth": @(self.rightButton.frame.size.width),
|
||||
@"height" : @(self.textInputbar.frame.size.height)};
|
||||
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(>=0)-[voiceMessageRecordingView(height)]-|" options:0 metrics:metrics views:views]];
|
||||
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[voiceMessageRecordingView(>=0)]-(buttonWidth)-|" options:0 metrics:metrics views:views]];
|
||||
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual
|
||||
toItem:_voiceMessageRecordingView attribute:NSLayoutAttributeCenterX multiplier:1.f constant:0.f]];
|
||||
}
|
||||
|
||||
- (void)hideVoiceMessageRecordingView
|
||||
{
|
||||
_voiceMessageRecordingView.hidden = YES;
|
||||
}
|
||||
|
||||
- (void)setupAudioRecorder
|
||||
{
|
||||
// Set the audio file
|
||||
|
@ -1351,11 +1399,13 @@ NSString * const NCChatViewControllerReplyPrivatelyNotification = @"NCChatViewCo
|
|||
([gestureRecognizer state] == UIGestureRecognizerStateFailed)) {
|
||||
NSLog(@"Stop recording audio message");
|
||||
[_recorder stop];
|
||||
[self hideVoiceMessageRecordingView];
|
||||
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
|
||||
[audioSession setActive:NO error:nil];
|
||||
} else if ([gestureRecognizer state] == UIGestureRecognizerStateBegan) {
|
||||
NSLog(@"Start recording audio message");
|
||||
[self setupAudioRecorder];
|
||||
[self showVoiceMessageRecordingView];
|
||||
if (!_recorder.recording) {
|
||||
AVAudioSession *session = [AVAudioSession sharedInstance];
|
||||
[session setActive:YES error:nil];
|
||||
|
|
1
Podfile
1
Podfile
|
@ -18,6 +18,7 @@ pod "PulsingHalo"
|
|||
pod 'MBProgressHUD', '~> 1.2.0'
|
||||
pod 'TOCropViewController', '~> 2.6.0'
|
||||
pod 'libPhoneNumber-iOS'
|
||||
pod 'MZTimerLabel'
|
||||
end
|
||||
|
||||
target "NotificationServiceExtension" do
|
||||
|
|
Загрузка…
Ссылка в новой задаче