This commit is contained in:
Juan Felipe Duarte
2023-04-19 09:38:18 -05:00
parent 6b09ce2f3a
commit 3b28febfec
8 changed files with 66 additions and 112 deletions
-89
View File
@@ -1,89 +0,0 @@
import 'dart:io';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:prosappco/src/authentication/authentication_repository.dart';
import 'package:prosappco/src/components/drawer_professional.dart';
class PruebaScreen extends StatefulWidget {
const PruebaScreen({super.key});
@override
State<PruebaScreen> createState() => _PruebaScreenState();
}
class _PruebaScreenState extends State<PruebaScreen> {
File? imagen_to_upload;
final uid = AuthenticationRepository.instance.getCurrentUserUid();
late final FirebaseAuth _auth;
final FirebaseStorage storage = FirebaseStorage.instance;
var photoTemp = '';
var _ciudad = '...';
var _photo = '...';
var _estado = '...';
@override
void initState() {
super.initState();
final uid = AuthenticationRepository.instance.getCurrentUserUid();
_auth = FirebaseAuth.instance;
final currentUser = _auth.currentUser;
if (_ciudad == '...') {
AuthenticationRepository.instance
.getCity(uid.toString())
.then((String s) => setState(() {
_ciudad = s;
}));
}
if (_photo == '...') {
AuthenticationRepository.instance
.getPhoto(uid.toString())
.then((String s) => setState(() {
_photo = s;
}));
}
if (_estado == '...') {
AuthenticationRepository.instance
.getState(uid.toString())
.then((String s) => setState(() {
_estado = s;
}));
}
}
@override
Widget build(BuildContext context) {
final User? user = FirebaseAuth.instance.currentUser;
String city = _ciudad.toString();
String state = _estado.toString();
return SafeArea(
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
iconTheme: const IconThemeData(
color: Colors.black,
),
title: const Text(
'Perfil',
style: TextStyle(
color: Colors.black,
),
),
),
drawer: DrawerProfessional(
ref: storage.ref().child(_photo),
userName: user?.displayName ?? '',
userPhoneNumber: user?.phoneNumber ?? '',
userCity: city,
userState: state),
));
}
}