diff --git a/lib/upload_page.dart b/lib/upload_page.dart index 4cdb527..6db6c8d 100644 --- a/lib/upload_page.dart +++ b/lib/upload_page.dart @@ -21,12 +21,12 @@ class _Uploader extends State { bool uploading = false; bool promted = false; - Widget build(BuildContext context) { - - if (file == null && promted == false){ + if (file == null && promted == false) { _selectImage(); - setState(() {promted = true;}); + setState(() { + promted = true; + }); } return file == null @@ -66,11 +66,42 @@ class _Uploader extends State { )); } - Future _selectImage() async { - File imageFile = await ImagePicker.pickImage(); - setState(() { - file = imageFile; - }); + _selectImage() async { + return showDialog( + context: context, + barrierDismissible: false, // user must tap button! + + child: new SimpleDialog( + title: const Text('Select assignment'), + children: [ + new SimpleDialogOption( + child: const Text('Take a photo'), + onPressed: () async { + Navigator.pop(context); + File imageFile = + await ImagePicker.pickImage(source: ImageSource.camera); + setState(() { + file = imageFile; + }); + }), + new SimpleDialogOption( + child: const Text('Choose from Gallery'), + onPressed: () async { + Navigator.of(context).pop(); + File imageFile = + await ImagePicker.pickImage(source: ImageSource.gallery); + setState(() { + file = imageFile; + }); + }), + new SimpleDialogOption( + child: const Text("Cancel"), + onPressed: () { + Navigator.pop(context); + }, + ) + ], + )); } void compressImage() async { diff --git a/pubspec.yaml b/pubspec.yaml index 73cb439..37b5950 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ dependencies: flutter: sdk: flutter cloud_firestore: 0.3.0 - image_picker: 0.1.1 + image_picker: 0.4.1 firebase_storage: 0.2.0 firebase_auth: 0.5.0 google_sign_in: 3.0.0