@@ -51,11 +51,10 @@ - (instancetype)init {
5151 return self;
5252}
5353
54- - (void )setAudioRecordingIsEnabled : (BOOL )audioRecordingIsEnabled {
54+ - (void )setAudioRecordingEnabled : (BOOL )audioRecordingEnabled {
5555
56- if (_audioRecordingIsEnabled != audioRecordingIsEnabled) {
57-
58- _audioRecordingIsEnabled = audioRecordingIsEnabled;
56+ if (_audioRecordingEnabled != audioRecordingEnabled) {
57+ _audioRecordingEnabled = audioRecordingEnabled;
5958 [self toggleSendButtonEnabled ];
6059 }
6160}
@@ -126,28 +125,26 @@ - (void)toggleButtons {
126125 BOOL hasTextAttachment = [self .contentView.textView hasTextAttachment ];
127126 BOOL hasDataToSend = hasText || hasTextAttachment;
128127
128+ UIButton *buttonToUpdate;
129+ UIView *buttonContainer;
129130 if (self.sendButtonOnRight ) {
130-
131- self.contentView .rightBarButtonItem .hidden = !hasDataToSend;
132- self.contentView .rightBarButtonItem .enabled = [self .contentView.textView hasText ];
133-
134- if (!self.audioRecordButtonItem .superview ) {
135- [self .contentView.rightBarButtonContainerView addSubview: [self audioRecordButtonItem ]];
136-
137- [self audioRecordButtonItem ].translatesAutoresizingMaskIntoConstraints = false ;
138- [self addCenterConstraintsToItem: self .contentView.rightBarButtonContainerView];
139- }
131+ buttonToUpdate = self.contentView .rightBarButtonItem ;
132+ buttonContainer = self.contentView .rightBarButtonContainerView ;
140133 }
141134 else {
135+ buttonToUpdate = self.contentView .leftBarButtonItem ;
136+ buttonContainer = self.contentView .leftBarButtonContainerView ;
137+ }
138+
139+ buttonToUpdate.hidden = !hasDataToSend;
140+ buttonToUpdate.enabled = [self .contentView.textView hasText ];
141+
142+ if (!self.audioRecordButtonItem .superview ) {
142143
143- self.contentView .leftBarButtonItem .hidden = !hasDataToSend;
144- self.contentView .leftBarButtonItem .enabled = [self .contentView.textView hasText ];
144+ [buttonContainer addSubview: [self audioRecordButtonItem ]];
145145
146- if (!self.audioRecordButtonItem .superview ) {
147- [self .contentView.leftBarButtonContainerView addSubview: [self audioRecordButtonItem ]];
148- [self audioRecordButtonItem ].translatesAutoresizingMaskIntoConstraints = false ;
149- [self addCenterConstraintsToItem: self .contentView.leftBarButtonContainerView];
150- }
146+ [self audioRecordButtonItem ].translatesAutoresizingMaskIntoConstraints = false ;
147+ [self addCenterConstraintsToItem: buttonContainer];
151148 }
152149
153150 self.audioRecordButtonItem .hidden = hasDataToSend;
@@ -174,7 +171,7 @@ - (void)addCenterConstraintsToItem:(UIView *)itemToAdd {
174171
175172- (void )toggleSendButtonEnabled {
176173
177- if (self.audioRecordingIsEnabled ) {
174+ if (self.audioRecordingEnabled ) {
178175
179176 [self toggleButtons ];
180177 return ;
@@ -326,7 +323,7 @@ - (void)finishAudioRecording {
326323
327324- (void )recordButtonInteractionDidBegin {
328325
329- if ([self .delegate messagesInputToolbarAudioRecordingEnabled :self ]) {
326+ if ([self .delegate messagesInputToolbarAudioRecordingShouldStart :self ]) {
330327
331328 self.recording = YES ;
332329 [self setShowRecordingInterface: true velocity: 0 .0f ];
@@ -346,7 +343,7 @@ - (void)recordButtonInteractionDidCancel:(CGFloat)velocity {
346343 }
347344}
348345
349- - (void )forceFinishRecording {
346+ - (void )cancelAudioRecording {
350347
351348 if (self.isRecording ) {
352349 self.recording = NO ;
0 commit comments