Skip to content

Commit

Permalink
fix: 🐛 Added support to hide/Un-hide image picker & camera icon #109 (#…
Browse files Browse the repository at this point in the history
…110)

Co-authored-by: Jaimin Rana <[email protected]>
  • Loading branch information
Jaiminrana and jaiminrana05 authored Aug 22, 2023
1 parent 8f51995 commit 31eedc2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 33 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
##(Unreleased)
## [1.3.1]

* **Feat**: [105](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/105) Allow user
to get callback when image is picked so user can perform operation like crop. Allow user to pass
configuration like height, width, image quality and preferredCameraDevice.
* **Fix**: [95](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/95) Fix issue of
chat is added to bottom while `loadMoreData` callback.

* **Fix**: [109](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/109) Added
support for the hiding/Un-hiding gallery and camera buttons

## [1.3.0]

* **Feat**: [71](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/71) Added Callback
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,13 @@ ChatView(
)
```

14. Add image picker icon configuration.
14. Add image picker configuration.
```dart
ChatView(
...
sendMessageConfig: SendMessageConfiguration(
enableCameraImagePicker: false,
enableGalleryImagePicker: true,
imagePickerIconsConfig: ImagePickerIconsConfiguration(
cameraIconColor: Colors.black,
galleryIconColor: Colors.black,
Expand Down
8 changes: 8 additions & 0 deletions lib/src/models/send_message_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ class SendMessageConfiguration {
/// Enable/disable voice recording. Enabled by default.
final bool allowRecordingVoice;

/// Enable/disable image picker from gallery. Enabled by default.
final bool enableGalleryImagePicker;

/// Enable/disable send image from camera. Enabled by default.
final bool enableCameraImagePicker;

/// Color of mic icon when replying to some voice message.
final Color? micIconColor;

Expand All @@ -77,6 +83,8 @@ class SendMessageConfiguration {
this.replyMessageColor,
this.closeIconColor,
this.allowRecordingVoice = true,
this.enableCameraImagePicker = true,
this.enableGalleryImagePicker = true,
this.voiceRecordingConfiguration,
this.micIconColor,
});
Expand Down
62 changes: 33 additions & 29 deletions lib/src/widgets/chatui_textfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,38 +219,42 @@ class _ChatUITextFieldState extends State<ChatUITextField> {
return Row(
children: [
if (!isRecordingValue) ...[
IconButton(
constraints: const BoxConstraints(),
onPressed: () => _onIconPressed(
ImageSource.camera,
config: widget
.sendMessageConfig?.imagePickerConfiguration,
if (sendMessageConfig?.enableCameraImagePicker ??
true)
IconButton(
constraints: const BoxConstraints(),
onPressed: () => _onIconPressed(
ImageSource.camera,
config:
sendMessageConfig?.imagePickerConfiguration,
),
icon: imagePickerIconsConfig
?.cameraImagePickerIcon ??
Icon(
Icons.camera_alt_outlined,
color:
imagePickerIconsConfig?.cameraIconColor,
),
),
icon:
imagePickerIconsConfig?.cameraImagePickerIcon ??
Icon(
Icons.camera_alt_outlined,
color: imagePickerIconsConfig
?.cameraIconColor,
),
),
IconButton(
constraints: const BoxConstraints(),
onPressed: () => _onIconPressed(
ImageSource.gallery,
config: widget
.sendMessageConfig?.imagePickerConfiguration,
if (sendMessageConfig?.enableGalleryImagePicker ??
true)
IconButton(
constraints: const BoxConstraints(),
onPressed: () => _onIconPressed(
ImageSource.gallery,
config:
sendMessageConfig?.imagePickerConfiguration,
),
icon: imagePickerIconsConfig
?.galleryImagePickerIcon ??
Icon(
Icons.image,
color: imagePickerIconsConfig
?.galleryIconColor,
),
),
icon: imagePickerIconsConfig
?.galleryImagePickerIcon ??
Icon(
Icons.image,
color:
imagePickerIconsConfig?.galleryIconColor,
),
),
],
if (widget.sendMessageConfig?.allowRecordingVoice ??
if (sendMessageConfig?.allowRecordingVoice ??
true &&
Platform.isIOS &&
Platform.isAndroid &&
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: chatview
description: A Flutter package that allows you to integrate Chat View with highly customization options.
version: 1.3.0
version: 1.3.1
issue_tracker: https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues
repository: https://github.com/SimformSolutionsPvtLtd/flutter_chatview

Expand Down

0 comments on commit 31eedc2

Please sign in to comment.