From e3764f77b0d9c5364acbf10ffe9d2d16212cf823 Mon Sep 17 00:00:00 2001 From: Terence ZAFINDRATAFA <31937920+Te-Z@users.noreply.github.com> Date: Mon, 26 Feb 2024 09:46:21 +0000 Subject: [PATCH] [TW-1472] Prevent user can select video in Change Avatar function (#1501) --- lib/pages/chat_details/chat_details_edit.dart | 7 ++++--- lib/presentation/mixins/single_image_picker_mixin.dart | 6 ++++-- pubspec.lock | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/pages/chat_details/chat_details_edit.dart b/lib/pages/chat_details/chat_details_edit.dart index 0d066bd4c3..54127a3669 100644 --- a/lib/pages/chat_details/chat_details_edit.dart +++ b/lib/pages/chat_details/chat_details_edit.dart @@ -27,7 +27,7 @@ import 'package:linagora_design_flutter/images_picker/asset_counter.dart'; import 'package:linagora_design_flutter/images_picker/images_picker_grid.dart'; import 'package:matrix/matrix.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; -import 'package:photo_manager/photo_manager.dart'; +import 'package:photo_manager/photo_manager.dart' as photo_manager; class ChatDetailsEdit extends StatefulWidget { final String roomId; @@ -65,7 +65,7 @@ class ChatDetailsEditController extends State Right(ChatDetailsUploadAvatarInitial()), ); FilePickerResult? avatarFilePicker; - AssetEntity? avatarAssetEntity; + photo_manager.AssetEntity? avatarAssetEntity; final MenuController menuController = MenuController(); @@ -138,6 +138,7 @@ class ChatDetailsEditController extends State context, currentPermissionPhotos, imagePickerController, + type: photo_manager.RequestType.image, ); } } @@ -149,7 +150,7 @@ class ChatDetailsEditController extends State imagePickerController.addListener(() { final selectedAsset = imagePickerController.selectedAssets.firstOrNull; - if (selectedAsset?.asset.type == AssetType.image) { + if (selectedAsset?.asset.type == photo_manager.AssetType.image) { if (!imagePickerController.pickFromCamera()) { Navigator.pop(context); } diff --git a/lib/presentation/mixins/single_image_picker_mixin.dart b/lib/presentation/mixins/single_image_picker_mixin.dart index 23abda9f41..fc63f04bf3 100644 --- a/lib/presentation/mixins/single_image_picker_mixin.dart +++ b/lib/presentation/mixins/single_image_picker_mixin.dart @@ -23,8 +23,9 @@ mixin SingleImagePickerMixin on CommonMediaPickerMixin { Future showImagePickerBottomSheet( BuildContext context, PermissionStatus? permissionStatusPhotos, - ImagePickerGridController imagePickerController, - ) async { + ImagePickerGridController imagePickerController, { + RequestType type = RequestType.image, + }) async { if (permissionStatusPhotos != null) { return await linagora_image_picker.ImagePicker.showImagesGridBottomSheet( context: context, @@ -63,6 +64,7 @@ mixin SingleImagePickerMixin on CommonMediaPickerMixin { }, backgroundImage: const AssetImage("assets/verification.png"), ), + type: type, ); } } diff --git a/pubspec.lock b/pubspec.lock index 6f547cc63c..0f6efb1abb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1470,7 +1470,7 @@ packages: description: path: "." ref: master - resolved-ref: ea9d98ed3bab8f362a46cb0d48ff57eb1332630c + resolved-ref: "492b6a564e3df87dc7f0796c84e1641358460d49" url: "git@github.com:linagora/linagora-design-flutter.git" source: git version: "0.0.1"