subir y recoger pdf
This commit is contained in:
@@ -174,7 +174,7 @@ class _ProfessionalProfileWebScreenState
|
|||||||
if (uploadedPhotoPaths.isNotEmpty) {
|
if (uploadedPhotoPaths.isNotEmpty) {
|
||||||
// Las imágenes se cargaron correctamente
|
// Las imágenes se cargaron correctamente
|
||||||
// Actualiza las imágenes en Firestore
|
// Actualiza las imágenes en Firestore
|
||||||
await updateImagesEspecializaciones(uploadedPhotoPaths);
|
await updateFilesEspecializaciones(uploadedPhotoPaths);
|
||||||
|
|
||||||
// Navega a la siguiente pantalla
|
// Navega a la siguiente pantalla
|
||||||
Navigator.pushReplacementNamed(context, '/solicitudEnviada');
|
Navigator.pushReplacementNamed(context, '/solicitudEnviada');
|
||||||
@@ -310,31 +310,61 @@ class _ProfessionalProfileWebScreenState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<String>> uploadEspecializaciones(List<Uint8List> images) async {
|
// Future<List<String>> uploadEspecializaciones(List<Uint8List> images) async {
|
||||||
List<String> photoPaths = [];
|
// List<String> photoPaths = [];
|
||||||
|
|
||||||
for (Uint8List imageBytes in images) {
|
// for (Uint8List imageBytes in images) {
|
||||||
Reference ref = storage
|
// Reference ref = storage
|
||||||
|
// .ref()
|
||||||
|
// .child('users')
|
||||||
|
// .child(uid!)
|
||||||
|
// .child('especializaciones')
|
||||||
|
// .child('e${DateTime.now().millisecondsSinceEpoch}.jpg');
|
||||||
|
|
||||||
|
// final UploadTask uploadTask = ref.putData(imageBytes);
|
||||||
|
|
||||||
|
// final TaskSnapshot snapshot = await uploadTask.whenComplete(() => true);
|
||||||
|
|
||||||
|
// if (snapshot.state == TaskState.success) {
|
||||||
|
// photoPaths.add(ref.fullPath);
|
||||||
|
// } else {
|
||||||
|
// await updateImagesEspecializaciones(photoPaths);
|
||||||
|
// return [];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// await updateImagesEspecializaciones(photoPaths);
|
||||||
|
// return photoPaths;
|
||||||
|
// }
|
||||||
|
|
||||||
|
Future<List<String>> uploadEspecializaciones(List<Uint8List> files) async {
|
||||||
|
List<String> filePaths = [];
|
||||||
|
|
||||||
|
for (Uint8List fileBytes in files) {
|
||||||
|
final Reference ref = FirebaseStorage.instance
|
||||||
.ref()
|
.ref()
|
||||||
.child('users')
|
.child('users')
|
||||||
.child(uid!)
|
.child(uid!)
|
||||||
.child('especializaciones')
|
.child('especializaciones')
|
||||||
.child('e${DateTime.now().millisecondsSinceEpoch}.jpg');
|
.child('e${DateTime.now().millisecondsSinceEpoch}.pdf');
|
||||||
|
|
||||||
final UploadTask uploadTask = ref.putData(imageBytes);
|
final SettableMetadata metaData =
|
||||||
|
SettableMetadata(contentType: 'application/pdf');
|
||||||
|
|
||||||
|
final UploadTask uploadTask = ref.putData(fileBytes, metaData);
|
||||||
|
|
||||||
final TaskSnapshot snapshot = await uploadTask.whenComplete(() => true);
|
final TaskSnapshot snapshot = await uploadTask.whenComplete(() => true);
|
||||||
|
|
||||||
if (snapshot.state == TaskState.success) {
|
if (snapshot.state == TaskState.success) {
|
||||||
photoPaths.add(ref.fullPath);
|
filePaths.add(ref.fullPath);
|
||||||
} else {
|
} else {
|
||||||
await updateImagesEspecializaciones(photoPaths);
|
await updateFilesEspecializaciones(filePaths);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await updateImagesEspecializaciones(photoPaths);
|
await updateFilesEspecializaciones(filePaths);
|
||||||
return photoPaths;
|
return filePaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateImageCedula(image) async {
|
Future<void> updateImageCedula(image) async {
|
||||||
@@ -393,21 +423,41 @@ class _ProfessionalProfileWebScreenState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateImagesEspecializaciones(List<String> photoPaths) async {
|
// Future<void> updateImagesEspecializaciones(List<String> photoPaths) async {
|
||||||
|
// try {
|
||||||
|
// final userRef = FirebaseFirestore.instance.collection('users').doc(uid);
|
||||||
|
// final userSnapshot = await userRef.get();
|
||||||
|
|
||||||
|
// if (userSnapshot.exists) {
|
||||||
|
// await userRef.update({'imgEspecializaciones': photoPaths});
|
||||||
|
// print('¡Imágenes de especializaciones actualizadas correctamente!');
|
||||||
|
// } else {
|
||||||
|
// await userRef.set({'imgEspecializaciones': photoPaths});
|
||||||
|
// print('¡Imágenes de especializaciones agregadas correctamente!');
|
||||||
|
// }
|
||||||
|
// } catch (e) {
|
||||||
|
// print(
|
||||||
|
// 'Error al agregar o actualizar las imágenes de especializaciones: $e');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
Future<void> updateFilesEspecializaciones(List<String> filePaths) async {
|
||||||
try {
|
try {
|
||||||
final userRef = FirebaseFirestore.instance.collection('users').doc(uid);
|
final userRef = FirebaseFirestore.instance.collection('users').doc(uid);
|
||||||
final userSnapshot = await userRef.get();
|
final userSnapshot = await userRef.get();
|
||||||
|
|
||||||
if (userSnapshot.exists) {
|
if (userSnapshot.exists) {
|
||||||
await userRef.update({'imgEspecializaciones': photoPaths});
|
await userRef.update({'imgEspecializaciones': filePaths});
|
||||||
|
|
||||||
print('¡Imágenes de especializaciones actualizadas correctamente!');
|
print('¡Imágenes de especializaciones actualizadas correctamente!');
|
||||||
} else {
|
} else {
|
||||||
await userRef.set({'imgEspecializaciones': photoPaths});
|
await userRef.set({'imgEspecializaciones': filePaths});
|
||||||
print('¡Imágenes de especializaciones agregadas correctamente!');
|
print('¡Imágenes de especializaciones agregadas correctamente!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print('Archivos de especializaciones actualizados correctamente');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(
|
print('Error al actualizar los archivos de especializaciones: $e');
|
||||||
'Error al agregar o actualizar las imágenes de especializaciones: $e');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:flutter_animate/flutter_animate.dart';
|
import 'package:flutter_animate/flutter_animate.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
||||||
import 'package:prosappco/src/components/banner_photo.dart';
|
|
||||||
import 'package:prosappco/src/components/pop_appbar.dart';
|
import 'package:prosappco/src/components/pop_appbar.dart';
|
||||||
import 'package:prosappco/src/components/primary_btn.dart';
|
import 'package:prosappco/src/components/primary_btn.dart';
|
||||||
import 'package:prosappco/src/components/schedule_picker.dart';
|
import 'package:prosappco/src/components/schedule_picker.dart';
|
||||||
@@ -15,7 +14,6 @@ import 'package:prosappco/src/models/setting_model.dart';
|
|||||||
import 'package:prosappco/src/screens/horario.dart';
|
import 'package:prosappco/src/screens/horario.dart';
|
||||||
import 'package:prosappco/src/screens/professional.dart';
|
import 'package:prosappco/src/screens/professional.dart';
|
||||||
import 'package:prosappco/src/screens/ubicacion.dart';
|
import 'package:prosappco/src/screens/ubicacion.dart';
|
||||||
import 'package:prosappco/src/services/select_image_profile.dart';
|
|
||||||
|
|
||||||
class ProfileProWebScreen extends StatefulWidget {
|
class ProfileProWebScreen extends StatefulWidget {
|
||||||
const ProfileProWebScreen({super.key});
|
const ProfileProWebScreen({super.key});
|
||||||
@@ -399,7 +397,7 @@ class _ProfileProWebScreenState extends State<ProfileProWebScreen> {
|
|||||||
TableCell(
|
TableCell(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Text('Lunes'),
|
child: const Text('Lunes'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TableCell(
|
TableCell(
|
||||||
|
|||||||
@@ -192,6 +192,15 @@ class _ProfileWebScreenState extends State<ProfileWebScreen> {
|
|||||||
print('e');
|
print('e');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await FirebaseFirestore.instance
|
||||||
|
.collection('users')
|
||||||
|
.doc(uid)
|
||||||
|
.update({'email': newEmail});
|
||||||
|
} catch (e) {
|
||||||
|
print('e');
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (selectedImagInBytes == null) {
|
if (selectedImagInBytes == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user