Show dialog to choose Photo or Video when clicking camera button

pull/307/head
Xin Yao 4 years ago
parent 853aea3820
commit 887a1f4ded
  1. 32
      lib/src/widgets/toolbar/camera_button.dart
  2. 2
      lib/src/widgets/toolbar/image_video_utils.dart

@ -63,7 +63,37 @@ class CameraButton extends StatelessWidget {
FilePickImpl? filePickImpl,
WebImagePickImpl? webImagePickImpl}) async {
if (onImagePickCallback != null && onVideoPickCallback != null) {
// TODO: show dialog to choose Image or Video
// Show dialog to choose Photo or Video
return await showDialog(
context: context,
builder: (context) {
return AlertDialog(
contentPadding: const EdgeInsets.all(0),
backgroundColor: Colors.transparent,
content: Column(mainAxisSize: MainAxisSize.min, children: [
TextButton.icon(
icon: const Icon(Icons.photo, color: Colors.cyanAccent),
label: const Text('Photo'),
onPressed: () {
ImageVideoUtils.handleImageButtonTap(context, controller,
ImageSource.camera, onImagePickCallback,
filePickImpl: filePickImpl,
webImagePickImpl: webImagePickImpl);
},
),
TextButton.icon(
icon: const Icon(Icons.movie_creation,
color: Colors.orangeAccent),
label: const Text('Video'),
onPressed: () {
ImageVideoUtils.handleVideoButtonTap(context, controller,
ImageSource.camera, onVideoPickCallback,
filePickImpl: filePickImpl,
webVideoPickImpl: webVideoPickImpl);
},
)
]));
});
}
if (onImagePickCallback != null) {

@ -80,7 +80,7 @@ class ImageVideoUtils {
'(check out example directory for how to do it)');
videoUrl = await webVideoPickImpl!(onVideoPickCallback);
} else if (Platform.isAndroid || Platform.isIOS) {
videoUrl = await _pickVideo(ImageSource.gallery, onVideoPickCallback);
videoUrl = await _pickVideo(videoSource, onVideoPickCallback);
} else {
assert(filePickImpl != null, 'Desktop must provide filePickImpl');
videoUrl =

Loading…
Cancel
Save