botones
This commit is contained in:
@@ -27,7 +27,9 @@ class AuthenticationRepository extends GetxController {
|
||||
}
|
||||
|
||||
_setInitialScreen(User? user) {
|
||||
user == null ? Get.offAll(LoginScreen()) : Get.offAll(WelcomeScreen());
|
||||
user == null
|
||||
? Get.offAll(const LoginScreen())
|
||||
: Get.offAll(const WelcomeScreen());
|
||||
}
|
||||
|
||||
Future<void> phoneAuthentication(String phoneNo) async {
|
||||
@@ -156,4 +158,17 @@ class AuthenticationRepository extends GetxController {
|
||||
}
|
||||
return photo;
|
||||
}
|
||||
|
||||
Future<String> getState(String uid) async {
|
||||
String state = '';
|
||||
try {
|
||||
final snapshot =
|
||||
await FirebaseFirestore.instance.collection('users').doc(uid).get();
|
||||
final Map<String, dynamic>? data = snapshot.data();
|
||||
state = data?['estado'] ?? '';
|
||||
} catch (e) {
|
||||
print('Error getting estado: $e');
|
||||
}
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
Navigator.pushReplacementNamed(context, '/profile');
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
iconTheme: IconThemeData(
|
||||
|
||||
@@ -19,7 +19,7 @@ class _ProfessionalRevisionScreenState
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
Navigator.pushReplacementNamed(context, '/profile');
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
iconTheme: IconThemeData(
|
||||
|
||||
@@ -33,6 +33,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
var photoTemp = '';
|
||||
var _ciudad = '...';
|
||||
var _photo = '...';
|
||||
var _estado = '...';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -68,6 +69,13 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
_photo = s;
|
||||
}));
|
||||
}
|
||||
if (_estado == '...') {
|
||||
AuthenticationRepository.instance
|
||||
.getState(uid.toString())
|
||||
.then((String s) => setState(() {
|
||||
_estado = s;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateImage(image) async {
|
||||
@@ -320,6 +328,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
final User? user = FirebaseAuth.instance.currentUser;
|
||||
|
||||
String city = _ciudad.toString();
|
||||
String state = _estado.toString();
|
||||
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
@@ -508,7 +517,11 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
SizedBox(width: 5),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, '/profesionalRevision');
|
||||
if (state == 'pendiente') {
|
||||
Navigator.pushNamed(context, '/profesionalProfile');
|
||||
} else if (state == 'revision') {
|
||||
Navigator.pushNamed(context, '/profesionalRevision');
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
'Modo profesional',
|
||||
|
||||
+104
-94
@@ -1,11 +1,10 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:firebase_storage/firebase_storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:prosappco/src/controllers/add_name_email_city.dart';
|
||||
import 'package:prosappco/src/screens/profile.dart';
|
||||
|
||||
import '../components/photo_view.dart';
|
||||
|
||||
@@ -19,15 +18,29 @@ class WelcomeScreen extends StatefulWidget {
|
||||
class _WelcomeScreenState extends State<WelcomeScreen> {
|
||||
final FirebaseStorage storage = FirebaseStorage.instance;
|
||||
final uid = AuthenticationRepository.instance.getCurrentUserUid();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final controller = Get.put(NameEmailCityController());
|
||||
var _ciudad = '';
|
||||
var _photo = '...';
|
||||
var _estado = '...';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final Reference ref = storage.ref().child(_photo);
|
||||
|
||||
if (_estado == '...') {
|
||||
AuthenticationRepository.instance
|
||||
.getState(uid.toString())
|
||||
.then((String s) => setState(() {
|
||||
_estado = s;
|
||||
|
||||
if (_estado.isEmpty) {
|
||||
FirebaseFirestore.instance
|
||||
.collection('users')
|
||||
.doc(uid)
|
||||
.update({'estado': 'pendiente'});
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
if (_ciudad == '') {
|
||||
AuthenticationRepository.instance
|
||||
@@ -36,6 +49,7 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
|
||||
_ciudad = s;
|
||||
}));
|
||||
}
|
||||
|
||||
if (_photo == '...') {
|
||||
AuthenticationRepository.instance
|
||||
.getPhoto(uid.toString())
|
||||
@@ -51,6 +65,7 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
|
||||
|
||||
// String name = _nombre.toString();
|
||||
String city = _ciudad.toString();
|
||||
String state = _estado.toString();
|
||||
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
@@ -62,48 +77,46 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, '/profile');
|
||||
},
|
||||
title: Text(user?.displayName ?? '',
|
||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
user?.phoneNumber ?? '',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
Text(
|
||||
city,
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
leading: ReferencePhoto(
|
||||
ref: storage.ref().child(_photo),
|
||||
size: 50,
|
||||
),
|
||||
trailing: Icon(Icons.keyboard_arrow_right,
|
||||
color: Colors.black),
|
||||
contentPadding:
|
||||
EdgeInsets.symmetric(vertical: 20, horizontal: 16),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, '/profile');
|
||||
},
|
||||
title: Text(user?.displayName ?? '',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
user?.phoneNumber ?? '',
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
Text(
|
||||
city,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
leading: ReferencePhoto(
|
||||
ref: storage.ref().child(_photo),
|
||||
size: 50,
|
||||
),
|
||||
trailing: const Icon(Icons.keyboard_arrow_right,
|
||||
color: Colors.black),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
vertical: 20, horizontal: 16),
|
||||
),
|
||||
], // padding: const EdgeInsets.only(top: 20, bottom: 15),
|
||||
),
|
||||
Divider(height: 0, color: Colors.grey),
|
||||
const Divider(height: 0, color: Colors.grey),
|
||||
Column(
|
||||
children: [
|
||||
ListTile(
|
||||
onTap: () {},
|
||||
leading: Icon(
|
||||
leading: const Icon(
|
||||
Icons.history,
|
||||
color: Colors.black,
|
||||
),
|
||||
title: Text(
|
||||
title: const Text(
|
||||
'Mis servicios',
|
||||
style: TextStyle(fontSize: 15),
|
||||
),
|
||||
@@ -112,44 +125,44 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, '/profile');
|
||||
},
|
||||
leading: Icon(
|
||||
leading: const Icon(
|
||||
Icons.person_outline,
|
||||
color: Colors.black,
|
||||
),
|
||||
title: Text(
|
||||
title: const Text(
|
||||
'Mi perfil',
|
||||
style: TextStyle(fontSize: 15),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {},
|
||||
leading: Icon(
|
||||
leading: const Icon(
|
||||
Icons.construction_outlined,
|
||||
color: Colors.black,
|
||||
),
|
||||
title: Text(
|
||||
title: const Text(
|
||||
'Configuración',
|
||||
style: TextStyle(fontSize: 15),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {},
|
||||
leading: Icon(
|
||||
leading: const Icon(
|
||||
Icons.question_mark_rounded,
|
||||
color: Colors.black,
|
||||
),
|
||||
title: Text(
|
||||
title: const Text(
|
||||
'Soporte',
|
||||
style: TextStyle(fontSize: 15),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {},
|
||||
leading: Icon(
|
||||
leading: const Icon(
|
||||
Icons.messenger_outline,
|
||||
color: Colors.black,
|
||||
),
|
||||
title: Text(
|
||||
title: const Text(
|
||||
'Mensajes',
|
||||
style: TextStyle(fontSize: 15),
|
||||
),
|
||||
@@ -159,20 +172,20 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
|
||||
onTap: () {
|
||||
Scaffold.of(context).openEndDrawer();
|
||||
},
|
||||
trailing: Icon(
|
||||
trailing: const Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
color: Colors.white,
|
||||
),
|
||||
title: Text(
|
||||
title: const Text(
|
||||
'Solicitar servicio',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
tileColor: Color(0xFF2BA4EC),
|
||||
contentPadding:
|
||||
EdgeInsets.symmetric(vertical: 5, horizontal: 16),
|
||||
tileColor: const Color(0xFF2BA4EC),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
vertical: 5, horizontal: 16),
|
||||
);
|
||||
}),
|
||||
],
|
||||
@@ -203,43 +216,47 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
|
||||
padding: const EdgeInsets.only(top: 200),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 10),
|
||||
const SizedBox(width: 10),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
AuthenticationRepository.instance.logout();
|
||||
},
|
||||
child: Icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
shape: const CircleBorder(),
|
||||
elevation: 3,
|
||||
minimumSize: const Size(45, 45),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.logout_outlined,
|
||||
color: Colors.red,
|
||||
size: 35,
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Colors.white,
|
||||
shape: CircleBorder(),
|
||||
elevation: 3,
|
||||
minimumSize: Size(45, 45),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5),
|
||||
const SizedBox(width: 5),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, '/profesionalProfile');
|
||||
if (state == 'pendiente') {
|
||||
Navigator.pushNamed(context, '/profesionalProfile');
|
||||
} else if (state == 'revision') {
|
||||
Navigator.pushNamed(context, '/profesionalRevision');
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF2BA4EC),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
),
|
||||
elevation: 0,
|
||||
minimumSize: const Size(200, 45),
|
||||
),
|
||||
child: const Text(
|
||||
'Modo profesional',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Color(0xFF2BA4EC),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
),
|
||||
elevation: 0,
|
||||
minimumSize: Size(200, 45),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -248,7 +265,7 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
|
||||
),
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: Color(0xFFD6F4FF),
|
||||
backgroundColor: const Color(0xFFD6F4FF),
|
||||
body: Stack(
|
||||
children: [
|
||||
Container(
|
||||
@@ -270,12 +287,12 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
|
||||
Builder(
|
||||
builder: (context) => ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Colors.white,
|
||||
shape: CircleBorder(),
|
||||
backgroundColor: Colors.white,
|
||||
shape: const CircleBorder(),
|
||||
elevation: 3,
|
||||
minimumSize: Size(50, 50),
|
||||
minimumSize: const Size(50, 50),
|
||||
),
|
||||
child: Icon(
|
||||
child: const Icon(
|
||||
Icons.menu,
|
||||
color: Colors.black,
|
||||
size: 30,
|
||||
@@ -285,12 +302,12 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
width: 150,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 50),
|
||||
child: const Image(
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 50),
|
||||
child: Image(
|
||||
image: AssetImage('images/logo_prosapp.png'),
|
||||
width: 120,
|
||||
height: 50,
|
||||
@@ -303,7 +320,7 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 20),
|
||||
margin: const EdgeInsets.only(top: 170),
|
||||
child: Align(
|
||||
child: const Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: Text(
|
||||
'Bienvenido',
|
||||
@@ -323,15 +340,16 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
|
||||
padding: const EdgeInsets.only(bottom: 40),
|
||||
child: Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
// AuthenticationRepository.instance.addNameAndEmail(
|
||||
// uid,
|
||||
// controller.name.text.trim(),
|
||||
// controller.email.text.trim(),
|
||||
// controller.city.text.trim(),
|
||||
// );
|
||||
},
|
||||
child: Text(
|
||||
onPressed: () {},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF2BA4EC),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
),
|
||||
elevation: 0,
|
||||
minimumSize: const Size(260, 60),
|
||||
),
|
||||
child: const Text(
|
||||
'Solicitar un servicio',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
@@ -339,14 +357,6 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Color(0xFF2BA4EC),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
),
|
||||
elevation: 0,
|
||||
minimumSize: Size(260, 60),
|
||||
),
|
||||
)),
|
||||
),
|
||||
]),
|
||||
|
||||
Reference in New Issue
Block a user