From 3b28febfec4d793c8d1ca0ee691040bf9bfb500b Mon Sep 17 00:00:00 2001 From: Juan Felipe Duarte <70235683+DuarteJFelipe@users.noreply.github.com> Date: Wed, 19 Apr 2023 09:38:18 -0500 Subject: [PATCH] update --- lib/main.dart | 4 +- lib/src/components/drawer_menu.dart | 2 +- lib/src/components/drawer_professional.dart | 28 +++---- lib/src/screens/profession.dart | 4 +- lib/src/screens/professional_profile.dart | 2 +- lib/src/screens/profile.dart | 1 - lib/src/screens/profile_pro.dart | 48 +++++++++++ lib/src/screens/prueba.dart | 89 --------------------- 8 files changed, 66 insertions(+), 112 deletions(-) create mode 100644 lib/src/screens/profile_pro.dart delete mode 100644 lib/src/screens/prueba.dart diff --git a/lib/main.dart b/lib/main.dart index 7e49545..ff7a683 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,7 +13,7 @@ import 'package:prosappco/src/screens/professional.dart'; import 'package:prosappco/src/screens/professional_profile.dart'; import 'package:prosappco/src/screens/professional_revision.dart'; import 'package:prosappco/src/screens/profile.dart'; -import 'package:prosappco/src/screens/prueba.dart'; +import 'package:prosappco/src/screens/profile_pro.dart'; import 'package:prosappco/src/screens/register.dart'; import 'package:prosappco/src/screens/request_sent.dart'; import 'package:prosappco/src/screens/service.dart'; @@ -58,7 +58,7 @@ class MyApp extends StatelessWidget { '/nuevaPassword': (context) => NewPasswordScreen(), '/servicio': (context) => const ServiceScreen(), '/profesional': (context) => const ProfessionalScreen(), - '/prueba': (context) => const PruebaScreen(), + '/profilePro': (context) => const ProfilePro(), }, onGenerateRoute: (settings) { throw Exception('Ruta desconocida: ${settings.name}'); diff --git a/lib/src/components/drawer_menu.dart b/lib/src/components/drawer_menu.dart index 8024335..4da2a39 100644 --- a/lib/src/components/drawer_menu.dart +++ b/lib/src/components/drawer_menu.dart @@ -292,7 +292,7 @@ class _DrawerMenuState extends State { } else if (user?.state == 'revision') { Navigator.pushNamed(context, '/profesionalRevision'); } else if (user?.state == 'activo') { - Navigator.pushNamed(context, '/prueba'); + Navigator.pushNamed(context, '/profilePro'); } }, style: ElevatedButton.styleFrom( diff --git a/lib/src/components/drawer_professional.dart b/lib/src/components/drawer_professional.dart index b7546b2..104b66d 100644 --- a/lib/src/components/drawer_professional.dart +++ b/lib/src/components/drawer_professional.dart @@ -1,27 +1,14 @@ import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_storage/firebase_storage.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:prosappco/src/authentication/authentication_repository.dart'; import 'package:prosappco/src/components/photo_view.dart'; import 'package:prosappco/src/models/user_model.dart'; +import 'package:prosappco/src/screens/profile.dart'; class DrawerProfessional extends StatefulWidget { - Reference? ref; - String userName; - String userPhoneNumber; - String userCity; - String userState; - - DrawerProfessional({ - super.key, - required this.ref, - required this.userName, - required this.userPhoneNumber, - required this.userCity, - required this.userState, - }); - @override State createState() => _DrawerProfessionalState(); } @@ -55,7 +42,16 @@ class _DrawerProfessionalState extends State { child: Column( children: [ ListTile( - onTap: () {}, + onTap: () { + Navigator.push( + context, + CupertinoPageRoute( + builder: (BuildContext context) { + return const ProfileScreen(); + }, + ), + ); + }, title: Text(user?.name ?? '', style: const TextStyle(fontWeight: FontWeight.bold)), subtitle: Column( diff --git a/lib/src/screens/profession.dart b/lib/src/screens/profession.dart index 4e9c5db..d8353d2 100644 --- a/lib/src/screens/profession.dart +++ b/lib/src/screens/profession.dart @@ -113,10 +113,10 @@ class _ProfessionScreenState extends State { body: Column( children: [ Padding( - padding: EdgeInsets.only(left: 10, right: 10, top: 10), + padding: const EdgeInsets.only(left: 10, right: 10, top: 10), child: TextField( controller: searchController, - decoration: InputDecoration( + decoration: const InputDecoration( hintText: 'Buscar su profesión', prefixIcon: Icon(Icons.assignment_ind_rounded), ), diff --git a/lib/src/screens/professional_profile.dart b/lib/src/screens/professional_profile.dart index 9f1795c..4f72e11 100644 --- a/lib/src/screens/professional_profile.dart +++ b/lib/src/screens/professional_profile.dart @@ -374,7 +374,7 @@ class ProfessionalProfileScreenState extends State { color: Color(0xFF2BA4EC), borderRadius: BorderRadius.circular(50), ), - child: Icon( + child: const Icon( Icons.person, color: Colors.white, size: 90, diff --git a/lib/src/screens/profile.dart b/lib/src/screens/profile.dart index 89fc666..5b1f409 100644 --- a/lib/src/screens/profile.dart +++ b/lib/src/screens/profile.dart @@ -350,7 +350,6 @@ class _ProfileScreenState extends State { Navigator.pop(context); }, label: 'Perfil'), - drawer: DrawerMenu(), body: SingleChildScrollView( reverse: true, child: Center( diff --git a/lib/src/screens/profile_pro.dart b/lib/src/screens/profile_pro.dart new file mode 100644 index 0000000..4f08e31 --- /dev/null +++ b/lib/src/screens/profile_pro.dart @@ -0,0 +1,48 @@ +import 'package:flutter/material.dart'; +import 'package:prosappco/src/components/drawer_professional.dart'; + +class ProfilePro extends StatefulWidget { + const ProfilePro({super.key}); + + @override + State createState() => _ProfileProState(); +} + +class _ProfileProState extends State { + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + bool switchValue = false; + return SafeArea( + child: Scaffold( + appBar: AppBar( + backgroundColor: Colors.white, + iconTheme: const IconThemeData( + color: Colors.black, + ), + title: const Text( + 'Perfil profesional', + style: TextStyle( + color: Colors.black, + ), + ), + ), + drawer: DrawerProfessional(), + body: Center( + child: Switch( + value: switchValue, + onChanged: (bool newValue) { + setState(() { + switchValue = newValue; + }); + }, + ), + ), + ), + ); + } +} diff --git a/lib/src/screens/prueba.dart b/lib/src/screens/prueba.dart deleted file mode 100644 index e2671dd..0000000 --- a/lib/src/screens/prueba.dart +++ /dev/null @@ -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 createState() => _PruebaScreenState(); -} - -class _PruebaScreenState extends State { - 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), - )); - } -}