diff --git a/CHANGELOG.md b/CHANGELOG.md index 340ae480..b3c45eb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ -## [3.0.0] (unreleased) +## [3.0.0] + * **Feat**: [401](https://github.com/SimformSolutionsPvtLtd/chatview/pull/401) Add selection and copy options for text view. * **Breaking**: [318](https://github.com/SimformSolutionsPvtLtd/chatview/issues/318) @@ -53,6 +54,11 @@ * **Breaking**: [390](https://github.com/SimformSolutionsPvtLtd/chatview/pull/390) `playIcon` and `pauseIcon` Now accepts a callback that provides different icons based on whether the message is by the sender or not. accept `Widget`. +* **Feat**: [390](https://github.com/SimformSolutionsPvtLtd/chatview/pull/406) Updated + audio_waveforms version to `2.0.0` +* **Breaking**: [390](https://github.com/SimformSolutionsPvtLtd/chatview/pull/406) Moved recording + audio settings from `VoiceRecordingConfiguration` to `RecorderSettings`. Check out the migration + guide [here](https://simform-flutter-packages.web.app/chatView/migration-guide). ## [2.5.0] diff --git a/doc/documentation.md b/doc/documentation.md index 78bd5cc8..db1a2f61 100644 --- a/doc/documentation.md +++ b/doc/documentation.md @@ -1145,6 +1145,45 @@ This guide will help you migrate your code from previous versions of ChatView to ## Key Changes +### Voice Recording Configuration + +The `VoiceRecordingConfiguration` class has been updated to utilize `RecorderSettings`, which now +encapsulates the recorder settings for both iOS and Android platforms. The `androidOutputFormat` +property has been removed so whatever format will be given by the encoder that will be used. + +Previous Usage: +```dart +ChatView( + sendMessageConfig: SendMessageConfiguration( + voiceRecordingConfiguration: VoiceRecordingConfiguration( + sampleRate: 44100, + bitRate: 128000, + iosEncoder: IosEncoder.kAudioFormatMPEG4AAC, + androidEncoder: AndroidEncoder.aacLc, + androidOutputFormat: AndroidOutputFormat.mpeg4, + ), +), +``` + +New Usage: +```dart +ChatView( + sendMessageConfig: SendMessageConfiguration( + voiceRecordingConfiguration: VoiceRecordingConfiguration( + recorderSettings: RecorderSettings( + bitRate: 128000, + sampleRate: 44100, + androidEncoderSettings: AndroidEncoderSettings( + androidEncoder: AndroidEncoder.aacLc, + ), + iosEncoderSettings: IosEncoderSetting( + iosEncoder: IosEncoder.kAudioFormatMPEG4AAC, + ), + ), + ), +), +``` + ### Text Field Action Items You can now add action buttons to the input field using two builders: diff --git a/example/lib/widgets/custom_chat_bar.dart b/example/lib/widgets/custom_chat_bar.dart index 507026a4..84b14d59 100644 --- a/example/lib/widgets/custom_chat_bar.dart +++ b/example/lib/widgets/custom_chat_bar.dart @@ -375,11 +375,8 @@ class _CustomChatBarState extends State { Future _recordOrStop() async { if (!isRecording.value) { await controller?.record( - sampleRate: voiceRecordingConfig.sampleRate, - bitRate: voiceRecordingConfig.bitRate, - androidEncoder: voiceRecordingConfig.androidEncoder, - iosEncoder: voiceRecordingConfig.iosEncoder, - androidOutputFormat: voiceRecordingConfig.androidOutputFormat, + recorderSettings: + voiceRecordingConfig.recorderSettings ?? const RecorderSettings(), ); isRecording.value = true; } else { diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 4c15f737..fb755f4f 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: sdk: flutter cupertino_icons: ^1.0.5 flutter_svg: ^2.2.1 - audio_waveforms: ^1.3.0 + audio_waveforms: ^2.0.0 chatview: path: ../ intl: diff --git a/lib/chatview.dart b/lib/chatview.dart index ef6ea51e..5677b8c2 100644 --- a/lib/chatview.dart +++ b/lib/chatview.dart @@ -25,9 +25,11 @@ library chatview; export 'package:audio_waveforms/audio_waveforms.dart' show AndroidEncoder, - AndroidOutputFormat, + AndroidEncoderSettings, IosEncoder, + IosEncoderSetting, PlayerWaveStyle, + RecorderSettings, WaveStyle; export 'package:chatview_utils/chatview_utils.dart' hide diff --git a/lib/src/models/config_models/send_message_configuration.dart b/lib/src/models/config_models/send_message_configuration.dart index a5aca289..cfd2a3e3 100644 --- a/lib/src/models/config_models/send_message_configuration.dart +++ b/lib/src/models/config_models/send_message_configuration.dart @@ -271,6 +271,7 @@ class VoiceRecordingConfiguration { /// Styling configuration for the recorder widget as well as /// configuring the audio recording quality. const VoiceRecordingConfiguration({ + this.recorderSettings, this.waveStyle, this.padding, this.margin, @@ -279,11 +280,6 @@ class VoiceRecordingConfiguration { this.micIcon, this.recorderIconColor, this.stopIcon, - this.sampleRate, - this.bitRate, - this.androidEncoder, - this.iosEncoder, - this.androidOutputFormat, }); /// Applies styles to waveform. @@ -311,24 +307,10 @@ class VoiceRecordingConfiguration { /// Applies color to mic and stop icon. final Color? recorderIconColor; - /// The sample rate for audio is measured in samples per second. - /// A higher sample rate generates more samples per second, - /// resulting in better audio quality but also larger file sizes. - final int? sampleRate; - - /// Bitrate is the amount of data per second that the codec uses to - /// encode the audio. A higher bitrate results in better quality - /// but also larger file sizes. - final int? bitRate; - - /// Audio encoder to be used for recording for IOS. - final IosEncoder? iosEncoder; - - /// Audio encoder to be used for recording for Android. - final AndroidEncoder? androidEncoder; - - /// The audio output format to be used for recorded audio files on Android. - final AndroidOutputFormat? androidOutputFormat; + /// Configures audio recording settings for Android and iOS. + /// + /// if null, default settings will be used. + final RecorderSettings? recorderSettings; } class CancelRecordConfiguration { diff --git a/lib/src/widgets/chatui_textfield.dart b/lib/src/widgets/chatui_textfield.dart index 7778663c..97882ea6 100644 --- a/lib/src/widgets/chatui_textfield.dart +++ b/lib/src/widgets/chatui_textfield.dart @@ -428,11 +428,8 @@ class _ChatUITextFieldState extends State { ); if (!isRecording.value) { await controller?.record( - sampleRate: voiceRecordingConfig?.sampleRate, - bitRate: voiceRecordingConfig?.bitRate, - androidEncoder: voiceRecordingConfig?.androidEncoder, - iosEncoder: voiceRecordingConfig?.iosEncoder, - androidOutputFormat: voiceRecordingConfig?.androidOutputFormat, + recorderSettings: + voiceRecordingConfig?.recorderSettings ?? const RecorderSettings(), ); isRecording.value = true; } else { diff --git a/pubspec.yaml b/pubspec.yaml index 8a8924fc..cfd4c2a3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ environment: dependencies: any_link_preview: ^3.0.2 - audio_waveforms: ^1.2.0 + audio_waveforms: ^2.0.0 cached_network_image: ^3.4.1 chatview_utils: ^0.0.2