chore: Follow up gallery picker
This commit is contained in:
parent
cc41a3bada
commit
eb446af438
3 changed files with 86 additions and 22 deletions
|
|
@ -522,8 +522,12 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
});
|
||||
}
|
||||
|
||||
void sendFileAction() async {
|
||||
final files = await selectFiles(context, allowMultiple: true);
|
||||
void sendFileAction({FileSelectorType type = FileSelectorType.any}) async {
|
||||
final files = await selectFiles(
|
||||
context,
|
||||
allowMultiple: true,
|
||||
type: type,
|
||||
);
|
||||
if (files.isEmpty) return;
|
||||
await showAdaptiveDialog(
|
||||
context: context,
|
||||
|
|
@ -547,23 +551,6 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
);
|
||||
}
|
||||
|
||||
void sendImageAction() async {
|
||||
final files = await ImagePicker().pickMultipleMedia(
|
||||
imageQuality: null,
|
||||
requestFullMetadata: false,
|
||||
);
|
||||
if (files.isEmpty) return;
|
||||
|
||||
await showAdaptiveDialog(
|
||||
context: context,
|
||||
builder: (c) => SendFileDialog(
|
||||
files: files,
|
||||
room: room,
|
||||
outerContext: context,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void openCameraAction() async {
|
||||
// Make sure the textfield is unfocused before opening the camera
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
|
|
@ -1139,7 +1126,10 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
sendFileAction();
|
||||
}
|
||||
if (choice == 'image') {
|
||||
sendImageAction();
|
||||
sendFileAction(type: FileSelectorType.images);
|
||||
}
|
||||
if (choice == 'video') {
|
||||
sendFileAction(type: FileSelectorType.videos);
|
||||
}
|
||||
if (choice == 'camera') {
|
||||
openCameraAction();
|
||||
|
|
|
|||
|
|
@ -143,9 +143,21 @@ class ChatInputRow extends StatelessWidget {
|
|||
leading: CircleAvatar(
|
||||
backgroundColor: theme.colorScheme.onPrimaryContainer,
|
||||
foregroundColor: theme.colorScheme.primaryContainer,
|
||||
child: const Icon(Icons.photo_album_outlined),
|
||||
child: const Icon(Icons.photo_outlined),
|
||||
),
|
||||
title: Text(L10n.of(context).openGallery),
|
||||
title: Text(L10n.of(context).sendImage),
|
||||
contentPadding: const EdgeInsets.all(0),
|
||||
),
|
||||
),
|
||||
PopupMenuItem<String>(
|
||||
value: 'video',
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: theme.colorScheme.onPrimaryContainer,
|
||||
foregroundColor: theme.colorScheme.primaryContainer,
|
||||
child: const Icon(Icons.video_camera_back_outlined),
|
||||
),
|
||||
title: Text(L10n.of(context).sendVideo),
|
||||
contentPadding: const EdgeInsets.all(0),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -62,10 +62,72 @@ enum FileSelectorType {
|
|||
label: 'WEBP',
|
||||
extensions: <String>['WebP', 'WEBP'],
|
||||
),
|
||||
XTypeGroup(
|
||||
label: 'GIF',
|
||||
extensions: <String>['gif', 'GIF'],
|
||||
),
|
||||
XTypeGroup(
|
||||
label: 'BMP',
|
||||
extensions: <String>['bmp', 'BMP'],
|
||||
),
|
||||
XTypeGroup(
|
||||
label: 'TIFF',
|
||||
extensions: <String>['tiff', 'TIFF', 'tif', 'TIF'],
|
||||
),
|
||||
XTypeGroup(
|
||||
label: 'HEIC',
|
||||
extensions: <String>['heic', 'HEIC'],
|
||||
),
|
||||
XTypeGroup(
|
||||
label: 'SVG',
|
||||
extensions: <String>['svg', 'SVG'],
|
||||
),
|
||||
],
|
||||
FileType.image,
|
||||
null,
|
||||
),
|
||||
videos(
|
||||
[
|
||||
XTypeGroup(
|
||||
label: 'MP4',
|
||||
extensions: <String>['mp4', 'MP4'],
|
||||
),
|
||||
XTypeGroup(
|
||||
label: 'AVI',
|
||||
extensions: <String>['avi', 'AVI'],
|
||||
),
|
||||
XTypeGroup(
|
||||
label: 'MOV',
|
||||
extensions: <String>['mov', 'MOV'],
|
||||
),
|
||||
XTypeGroup(
|
||||
label: 'MKV',
|
||||
extensions: <String>['mkv', 'MKV'],
|
||||
),
|
||||
XTypeGroup(
|
||||
label: 'WMV',
|
||||
extensions: <String>['wmv', 'WMV'],
|
||||
),
|
||||
XTypeGroup(
|
||||
label: 'FLV',
|
||||
extensions: <String>['flv', 'FLV'],
|
||||
),
|
||||
XTypeGroup(
|
||||
label: 'MPEG',
|
||||
extensions: <String>['mpeg', 'MPEG'],
|
||||
),
|
||||
XTypeGroup(
|
||||
label: '3GP',
|
||||
extensions: <String>['3gp', '3GP'],
|
||||
),
|
||||
XTypeGroup(
|
||||
label: 'OGG',
|
||||
extensions: <String>['ogg', 'OGG'],
|
||||
),
|
||||
],
|
||||
FileType.video,
|
||||
null,
|
||||
),
|
||||
zip(
|
||||
[
|
||||
XTypeGroup(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue