cedula y certificado

This commit is contained in:
Felipe
2023-07-31 18:16:05 -05:00
parent 3290ccd00d
commit 381cedf3ac
2 changed files with 34 additions and 51 deletions
+3 -6
View File
@@ -132,7 +132,7 @@ class _DrawerProfessionalState extends State<DrawerProfessional> {
Navigator.of(context).push( Navigator.of(context).push(
CupertinoPageRoute( CupertinoPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return MyServicesProScreen(); return const MyServicesProScreen();
}, },
), ),
); );
@@ -226,7 +226,7 @@ class _DrawerProfessionalState extends State<DrawerProfessional> {
Navigator.of(context).push( Navigator.of(context).push(
CupertinoPageRoute( CupertinoPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return MessagesScreen(); return const MessagesScreen();
}, },
), ),
); );
@@ -304,14 +304,11 @@ class _DrawerProfessionalState extends State<DrawerProfessional> {
color: Colors.white, color: Colors.white,
child: ListTile( child: ListTile(
onTap: () async { onTap: () async {
var professional =
await Professional.getProfessional(uid!);
Navigator.push( Navigator.push(
context, context,
CupertinoPageRoute( CupertinoPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return ReputationProScreen(); return const ReputationProScreen();
}, },
), ),
); );
+31 -45
View File
@@ -1,16 +1,16 @@
import 'dart:io'; import 'dart:io';
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart'; import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:prosappco/src/authentication/authentication_repository.dart'; import 'package:prosappco/src/authentication/authentication_repository.dart';
import 'package:prosappco/src/components/photo_view.dart'; import 'package:prosappco/src/components/photo_view.dart';
import 'package:prosappco/src/components/pop_appbar.dart'; import 'package:prosappco/src/components/pop_appbar.dart';
import 'package:prosappco/src/controllers/info_%20professional.dart'; import 'package:prosappco/src/controllers/info_%20professional.dart';
import 'package:prosappco/src/services/select_image_profile.dart'; import 'package:prosappco/src/services/select_image_profile.dart';
import 'package:file_picker/file_picker.dart';
class ProfessionalProfileScreen extends StatefulWidget { class ProfessionalProfileScreen extends StatefulWidget {
const ProfessionalProfileScreen({super.key}); const ProfessionalProfileScreen({super.key});
@@ -62,6 +62,20 @@ class ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
} }
} }
Future<File?> getPdf() async {
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['pdf'],
);
if (result != null) {
File file = File(result.files.single.path!);
return file;
} else {
return null;
}
}
Future<void> _showChoiceDialog(BuildContext context) async { Future<void> _showChoiceDialog(BuildContext context) async {
return showDialog( return showDialog(
context: context, context: context,
@@ -115,21 +129,6 @@ class ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
content: SingleChildScrollView( content: SingleChildScrollView(
child: ListBody( child: ListBody(
children: [ children: [
GestureDetector(
child: const Text(
textAlign: TextAlign.center,
"Tomar foto",
style: TextStyle(color: Color(0xFF2BA4EC)),
),
onTap: () async {
final imagen = await getImage(1);
setState(() {
image_cedula = File(imagen[0]!.path);
});
Navigator.of(context).pop();
},
),
const Divider(color: Colors.black54),
GestureDetector( GestureDetector(
child: const Text( child: const Text(
textAlign: TextAlign.center, textAlign: TextAlign.center,
@@ -137,9 +136,9 @@ class ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
style: TextStyle(color: Color(0xFF2BA4EC)), style: TextStyle(color: Color(0xFF2BA4EC)),
), ),
onTap: () async { onTap: () async {
final imagen = await getImage(2); final imagen = await getPdf();
setState(() { setState(() {
image_cedula = File(imagen[0]!.path); image_cedula = File(imagen!.path);
}); });
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
@@ -160,21 +159,6 @@ class ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
content: SingleChildScrollView( content: SingleChildScrollView(
child: ListBody( child: ListBody(
children: [ children: [
GestureDetector(
child: const Text(
textAlign: TextAlign.center,
"Tomar foto",
style: TextStyle(color: Color(0xFF2BA4EC)),
),
onTap: () async {
final imagen = await getImage(1);
setState(() {
image_certificado = File(imagen[0]!.path);
});
Navigator.of(context).pop();
},
),
const Divider(color: Colors.black54),
GestureDetector( GestureDetector(
child: const Text( child: const Text(
textAlign: TextAlign.center, textAlign: TextAlign.center,
@@ -182,9 +166,9 @@ class ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
style: TextStyle(color: Color(0xFF2BA4EC)), style: TextStyle(color: Color(0xFF2BA4EC)),
), ),
onTap: () async { onTap: () async {
final imagen = await getImage(2); final imagen = await getPdf();
setState(() { setState(() {
image_certificado = File(imagen[0]!.path); image_certificado = File(imagen!.path);
}); });
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
@@ -198,14 +182,13 @@ class ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
} }
Future<bool> uploadCedula(File image) async { Future<bool> uploadCedula(File image) async {
final String namefile = image.path.split('/').last; final now = DateTime.now();
final formattedDate = DateFormat('HHmmssddMMyyyy').format(now);
final milliseconds = (now.microsecondsSinceEpoch / 1000).round();
final random = 'c$formattedDate$milliseconds';
Reference ref = storage Reference ref =
.ref() storage.ref().child('users').child(uid!).child('cedula').child(random);
.child('users')
.child(uid!)
.child('cedula')
.child(namefile);
final UploadTask uploadTask = ref.putFile(image); final UploadTask uploadTask = ref.putFile(image);
@@ -240,14 +223,17 @@ class ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
} }
Future<bool> uploadCertificado(File image) async { Future<bool> uploadCertificado(File image) async {
final String namefile = image.path.split('/').last; final now = DateTime.now();
final formattedDate = DateFormat('HHmmssddMMyyyy').format(now);
final milliseconds = (now.microsecondsSinceEpoch / 1000).round();
final random = 'f$formattedDate$milliseconds';
Reference ref = storage Reference ref = storage
.ref() .ref()
.child('users') .child('users')
.child(uid!) .child(uid!)
.child('certificado_profesional') .child('certificado_profesional')
.child(namefile); .child(random);
final UploadTask uploadTask = ref.putFile(image); final UploadTask uploadTask = ref.putFile(image);