mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 04:49:21 +00:00
Can take videos
This commit is contained in:
parent
19d4e1d31c
commit
8f7ca14586
@ -14,6 +14,8 @@
|
|||||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||||
|
|
||||||
|
<!-- Fix camera issue -->
|
||||||
|
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
||||||
|
|
||||||
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
|
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
|
||||||
calls FlutterMain.startInitialization(this); in its onCreate method.
|
calls FlutterMain.startInitialization(this); in its onCreate method.
|
||||||
|
@ -15,6 +15,8 @@ import 'package:mime/mime.dart';
|
|||||||
enum _FileChoices {
|
enum _FileChoices {
|
||||||
PICK_IMAGE,
|
PICK_IMAGE,
|
||||||
TAKE_PICTURE,
|
TAKE_PICTURE,
|
||||||
|
PICK_VIDEO,
|
||||||
|
TAKE_VIDEO,
|
||||||
PICK_OTHER_FILE,
|
PICK_OTHER_FILE,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,18 +45,32 @@ List<_PickFileOption> get _optionsList => [
|
|||||||
_PickFileOption(
|
_PickFileOption(
|
||||||
value: _FileChoices.PICK_IMAGE,
|
value: _FileChoices.PICK_IMAGE,
|
||||||
label: tr("Choose an image"),
|
label: tr("Choose an image"),
|
||||||
icon: Icons.image_search,
|
icon: Icons.image,
|
||||||
canEnable: (l) => l.any(isImage)),
|
canEnable: (l) => l.any(isImage)),
|
||||||
_PickFileOption(
|
_PickFileOption(
|
||||||
value: _FileChoices.TAKE_PICTURE,
|
value: _FileChoices.TAKE_PICTURE,
|
||||||
label: tr("Take a picture"),
|
label: tr("Take a picture"),
|
||||||
icon: Icons.camera_alt,
|
icon: Icons.camera_alt,
|
||||||
canEnable: (l) => l.any(isImage)),
|
canEnable: (l) => l.any(isImage)),
|
||||||
|
|
||||||
|
// Video
|
||||||
|
_PickFileOption(
|
||||||
|
value: _FileChoices.PICK_VIDEO,
|
||||||
|
label: tr("Choose a video"),
|
||||||
|
icon: Icons.video_library,
|
||||||
|
canEnable: (l) => l.any(isVideo)),
|
||||||
|
_PickFileOption(
|
||||||
|
value: _FileChoices.TAKE_VIDEO,
|
||||||
|
label: tr("Take a video"),
|
||||||
|
icon: Icons.videocam,
|
||||||
|
canEnable: (l) => l.any(isVideo)),
|
||||||
|
|
||||||
|
// Other
|
||||||
_PickFileOption(
|
_PickFileOption(
|
||||||
value: _FileChoices.PICK_OTHER_FILE,
|
value: _FileChoices.PICK_OTHER_FILE,
|
||||||
label: tr("Browse files"),
|
label: tr("Browse files"),
|
||||||
icon: Icons.folder_open,
|
icon: Icons.folder_open,
|
||||||
canEnable: (l) => l.any((el) => !isImage(el))),
|
canEnable: (l) => l.any((el) => !isImage(el) && !isVideo(el))),
|
||||||
];
|
];
|
||||||
|
|
||||||
Future<BytesFile> showPickFileDialog({
|
Future<BytesFile> showPickFileDialog({
|
||||||
@ -107,6 +123,21 @@ Future<BytesFile> showPickFileDialog({
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Pick an video
|
||||||
|
case _FileChoices.PICK_VIDEO:
|
||||||
|
case _FileChoices.TAKE_VIDEO:
|
||||||
|
final image = await ImagePicker().getVideo(
|
||||||
|
source: choice == _FileChoices.PICK_VIDEO
|
||||||
|
? ImageSource.gallery
|
||||||
|
: ImageSource.camera,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (image == null) return null;
|
||||||
|
|
||||||
|
file = BytesFile(image.path.split("/").last, await image.readAsBytes());
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
// Pick other files
|
// Pick other files
|
||||||
case _FileChoices.PICK_OTHER_FILE:
|
case _FileChoices.PICK_OTHER_FILE:
|
||||||
final pickedFile = await FilePicker.platform.pickFiles(
|
final pickedFile = await FilePicker.platform.pickFiles(
|
||||||
|
@ -48,3 +48,6 @@ Future<PickedFile> pickImage(BuildContext context) async {
|
|||||||
|
|
||||||
/// Check if a mime type maps to an image or not
|
/// Check if a mime type maps to an image or not
|
||||||
bool isImage(String mimeType) => mimeType.startsWith("image/");
|
bool isImage(String mimeType) => mimeType.startsWith("image/");
|
||||||
|
|
||||||
|
/// Check if a mime type maps to an image or not
|
||||||
|
bool isVideo(String mimeType) => mimeType.startsWith("video/mp4");
|
||||||
|
Loading…
Reference in New Issue
Block a user