Image can not be upload through document in iOs #484

This commit is contained in:
Hillel Coren 2023-05-31 08:49:25 +03:00
parent 9506dfe15d
commit 346812c56f
3 changed files with 48 additions and 9 deletions

View File

@ -2,6 +2,7 @@
import 'dart:io'; import 'dart:io';
// Flutter imports: // Flutter imports:
import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -65,8 +66,10 @@ class DocumentGrid extends StatelessWidget {
if (isMobileOS()) ...[ if (isMobileOS()) ...[
Expanded( Expanded(
child: AppButton( child: AppButton(
iconData: Icons.camera_alt, iconData: isIOS() ? null : Icons.camera_alt,
label: localization.takePicture, label: isIOS()
? localization.camera
: localization.takePicture,
onPressed: () async { onPressed: () async {
final status = await Permission.camera.request(); final status = await Permission.camera.request();
if (status == PermissionStatus.granted) { if (status == PermissionStatus.granted) {
@ -88,18 +91,18 @@ class DocumentGrid extends StatelessWidget {
}, },
), ),
), ),
SizedBox( SizedBox(width: isIOS() ? 8 : 14),
width: 14,
),
], ],
Expanded( Expanded(
child: AppButton( child: AppButton(
iconData: Icons.insert_drive_file, iconData: isIOS() ? null : Icons.insert_drive_file,
label: localization.uploadFile, label:
isIOS() ? localization.files : localization.uploadFile,
onPressed: () async { onPressed: () async {
final multipartFile = await pickFile( final multipartFile = await pickFile(
fileIndex: 'documents[]', fileIndex: 'documents[]',
allowedExtensions: DocumentEntity.ALLOWED_EXTENSIONS); allowedExtensions: DocumentEntity.ALLOWED_EXTENSIONS,
);
if (multipartFile != null) { if (multipartFile != null) {
onUploadDocument(multipartFile); onUploadDocument(multipartFile);
@ -107,6 +110,25 @@ class DocumentGrid extends StatelessWidget {
}, },
), ),
), ),
if (isIOS()) ...[
SizedBox(width: isIOS() ? 8 : 14),
Expanded(
child: AppButton(
label: localization.gallery,
onPressed: () async {
final multipartFile = await pickFile(
fileIndex: 'documents[]',
allowedExtensions: DocumentEntity.ALLOWED_EXTENSIONS,
fileType: FileType.image,
);
if (multipartFile != null) {
onUploadDocument(multipartFile);
}
},
),
),
],
], ],
), ),
) )

View File

@ -18,6 +18,9 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = { static final Map<String, Map<String, String>> _localizedValues = {
'en': { 'en': {
// STARTER: lang key - do not remove comment // STARTER: lang key - do not remove comment
'files': 'Files',
'camera': 'Camera',
'gallery': 'Gallery',
'email_count_invoices': 'Email :count invoices', 'email_count_invoices': 'Email :count invoices',
'location': 'Location', 'location': 'Location',
'invoice_task_item_description': 'Invoice Task Item Description', 'invoice_task_item_description': 'Invoice Task Item Description',
@ -102526,6 +102529,19 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['email_count_invoices'] ?? _localizedValues[localeCode]['email_count_invoices'] ??
_localizedValues['en']['email_count_invoices']; _localizedValues['en']['email_count_invoices'];
String get gallery =>
_localizedValues[localeCode]['gallery'] ??
_localizedValues['en']['gallery'];
String get files =>
_localizedValues[localeCode]['files'] ??
_localizedValues['en']['files'];
String get camera =>
_localizedValues[localeCode]['camera'] ??
_localizedValues['en']['camera'];
// STARTER: lang field - do not remove comment // STARTER: lang field - do not remove comment
String lookup(String key) { String lookup(String key) {

View File

@ -120,6 +120,7 @@ bool isAndroid() {
} }
bool isIOS() { bool isIOS() {
return true;
if (kIsWeb) { if (kIsWeb) {
return false; return false;
} }