puntaje pro

This commit is contained in:
Juan Felipe Duarte
2023-04-26 16:55:58 -05:00
parent 0a70d40d2d
commit c1747a45b9
12 changed files with 781 additions and 436 deletions
+9 -1
View File
@@ -7,6 +7,7 @@ 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/models/user_model.dart'; import 'package:prosappco/src/models/user_model.dart';
import 'package:prosappco/src/screens/profile.dart'; import 'package:prosappco/src/screens/profile.dart';
import 'package:prosappco/src/screens/prueba.dart';
class DrawerMenu extends StatefulWidget { class DrawerMenu extends StatefulWidget {
@override @override
@@ -292,7 +293,14 @@ class _DrawerMenuState extends State<DrawerMenu> {
} else if (user?.state == 'revision') { } else if (user?.state == 'revision') {
Navigator.pushNamed(context, '/profesionalRevision'); Navigator.pushNamed(context, '/profesionalRevision');
} else if (user?.state == 'activo') { } else if (user?.state == 'activo') {
Navigator.pushNamed(context, '/profilePro'); Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return const PruebaScreen();
},
),
);
} }
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
+30 -2
View File
@@ -1,3 +1,4 @@
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/cupertino.dart'; import 'package:flutter/cupertino.dart';
@@ -5,9 +6,14 @@ import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.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/models/score_model.dart';
import 'package:prosappco/src/models/user_model.dart'; import 'package:prosappco/src/models/user_model.dart';
import 'package:prosappco/src/screens/calendar.dart'; import 'package:prosappco/src/screens/calendar.dart';
import 'package:prosappco/src/screens/professional.dart';
import 'package:prosappco/src/screens/professional_profile.dart';
import 'package:prosappco/src/screens/profile.dart'; import 'package:prosappco/src/screens/profile.dart';
import 'package:prosappco/src/screens/profile_pro.dart';
import 'package:prosappco/src/screens/reputation.dart';
class DrawerProfessional extends StatefulWidget { class DrawerProfessional extends StatefulWidget {
@override @override
@@ -112,7 +118,16 @@ class _DrawerProfessionalState extends State<DrawerProfessional> {
), ),
), ),
ListTile( ListTile(
onTap: () {}, onTap: () {
Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return const ProfilePro();
},
),
);
},
leading: const Icon( leading: const Icon(
Icons.person_outline, Icons.person_outline,
color: Colors.black, color: Colors.black,
@@ -211,7 +226,20 @@ class _DrawerProfessionalState extends State<DrawerProfessional> {
child: Container( child: Container(
color: Colors.white, color: Colors.white,
child: ListTile( child: ListTile(
onTap: () {}, onTap: () async {
var professional =
await Professional.getProfessional(uid!);
Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return ReputationScreen(
professional: professional!);
},
),
);
},
trailing: const Icon(Icons.keyboard_arrow_right, trailing: const Icon(Icons.keyboard_arrow_right,
color: Colors.black), color: Colors.black),
title: const Text( title: const Text(
+6 -6
View File
@@ -13,7 +13,7 @@ class EventoService {
) async { ) async {
try { try {
await FirebaseFirestore.instance.collection('services').add({ await FirebaseFirestore.instance.collection('services').add({
'profesional_id': uid, 'user_id': uid,
'title': title, 'title': title,
'description': description, 'description': description,
'day': day, 'day': day,
@@ -34,7 +34,7 @@ Future<List<Event>> getByProId(String day) async {
try { try {
var snapshot = await FirebaseFirestore.instance var snapshot = await FirebaseFirestore.instance
.collection('services') .collection('services')
.where('profesional_id', isEqualTo: uid) .where('user_id', isEqualTo: uid)
.where('day', isEqualTo: day.toString()) .where('day', isEqualTo: day.toString())
.get(); .get();
@@ -56,7 +56,7 @@ class Event {
String? day; String? day;
String? range1Hour1; String? range1Hour1;
String? range1Hour2; String? range1Hour2;
String? profesionalId; String? userId;
Event({ Event({
this.title, this.title,
@@ -64,7 +64,7 @@ class Event {
this.day, this.day,
this.range1Hour1, this.range1Hour1,
this.range1Hour2, this.range1Hour2,
this.profesionalId, this.userId,
}); });
factory Event.fromJson(Map<String, dynamic> json) { factory Event.fromJson(Map<String, dynamic> json) {
@@ -74,7 +74,7 @@ class Event {
day: json['day'], day: json['day'],
range1Hour1: json['range1Hour1'], range1Hour1: json['range1Hour1'],
range1Hour2: json['range1Hour2'], range1Hour2: json['range1Hour2'],
profesionalId: json['profesional_id'], userId: json['user_id'],
); );
} }
@@ -82,7 +82,7 @@ class Event {
try { try {
var snapshot = await FirebaseFirestore.instance var snapshot = await FirebaseFirestore.instance
.collection('services') .collection('services')
.where('profesional_id', isEqualTo: uid) .where('user_id', isEqualTo: uid)
.get(); .get();
List<Event> eventos = []; List<Event> eventos = [];
+95
View File
@@ -0,0 +1,95 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:prosappco/src/models/user_model.dart';
class ScoresModel {
late int total;
late double average;
final List<ScoreModel2> scores;
ScoresModel(this.scores) {
total = scores.length;
average = averageScore(scores);
}
double averageScore(List<ScoreModel2> scores) {
if (scores.isEmpty) {
return 0.0;
}
final sum = scores.map((score) => score.score).reduce((a, b) => a + b);
return sum / scores.length;
}
// Me
static Future<ScoresModel> scoreTo(String userReceived, bool userInfo) async {
final receivedScoresQuery = FirebaseFirestore.instance
.collection('scores')
.where('to_user', isEqualTo: userReceived);
final receivedScoresSnapshot = await receivedScoresQuery.get();
final receivedScores = await Future.wait(receivedScoresSnapshot.docs
.map((doc) async =>
await ScoreModel2.fromDocumentSnapshot(doc, userInfo))
.toList());
return ScoresModel(receivedScores);
}
// You
static Future<ScoresModel> scoreFrom(String userGiven, bool userInfo) async {
final givenScoresQuery = FirebaseFirestore.instance
.collection('scores')
.where('from_user', isEqualTo: userGiven);
final givenScoresSnapshot = await givenScoresQuery.get();
final givenScores = await Future.wait(givenScoresSnapshot.docs
.map((doc) async =>
await ScoreModel2.fromDocumentSnapshot(doc, userInfo))
.toList());
return ScoresModel(givenScores);
}
}
class ScoreModel2 {
final String id;
final double score;
final String fromUser;
final String toUser;
final String comment;
final String name;
final Reference? avatar;
ScoreModel2({
required this.id,
required this.score,
required this.fromUser,
required this.toUser,
required this.comment,
required this.name,
required this.avatar,
});
static Future<ScoreModel2> fromDocumentSnapshot(
DocumentSnapshot<Map<String, dynamic>> snapshot, bool userInfo) async {
try {
final Map<String, dynamic> data = snapshot.data()!;
final user = userInfo ? await UserModel.getUser(data['from_user']) : null;
return ScoreModel2(
id: snapshot.id,
score: double.parse(data['score'].toString()),
fromUser: data['from_user'],
toUser: data['to_user'],
comment: data['comment'],
name: user?.name ?? "...",
avatar: user?.photo);
} catch (e) {
print('error en score $e');
rethrow;
}
}
}
+78 -63
View File
@@ -1,11 +1,10 @@
import 'dart:ffi'; import 'package:flutter/cupertino.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:prosappco/src/authentication/authentication_repository.dart'; import 'package:prosappco/src/authentication/authentication_repository.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/models/event_model.dart'; import 'package:prosappco/src/models/event_model.dart';
import 'package:prosappco/src/screens/cita.dart';
import 'package:table_calendar/table_calendar.dart'; import 'package:table_calendar/table_calendar.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
@@ -90,64 +89,62 @@ class _CalendarScreenState extends State<CalendarScreen> {
// DateTime firstDay = today.subtract(Duration(days: 365)); // DateTime firstDay = today.subtract(Duration(days: 365));
DateTime lastDay = today.add(const Duration(days: 365)); DateTime lastDay = today.add(const Duration(days: 365));
return SafeArea( return Scaffold(
child: Scaffold( resizeToAvoidBottomInset: false,
resizeToAvoidBottomInset: false, appBar: PopAppbar(
appBar: PopAppbar( onPressed: () {
onPressed: () { Navigator.pop(context);
Navigator.pop(context); },
}, label: 'Calendario',
label: 'Calendario', ),
), body: Column(
body: Column( children: [
children: [ Container(
Container( color: const Color.fromARGB(255, 224, 247, 255),
color: const Color.fromARGB(255, 224, 247, 255), child: TableCalendar(
child: TableCalendar( locale: 'es_MX',
locale: 'es_MX', firstDay: DateTime.utc(2010, 10, 16),
firstDay: DateTime.utc(2010, 10, 16), lastDay: lastDay,
lastDay: lastDay, focusedDay: today,
focusedDay: today, availableGestures: AvailableGestures.all,
availableGestures: AvailableGestures.all, onDaySelected: _onDaySelected,
onDaySelected: _onDaySelected, selectedDayPredicate: (day) => isSameDay(day, today),
selectedDayPredicate: (day) => isSameDay(day, today), calendarFormat: _calendarFormat,
calendarFormat: _calendarFormat, onFormatChanged: _onFormatChange,
onFormatChanged: _onFormatChange, eventLoader: (date) {
eventLoader: (date) { return events
return events .where((element) {
.where((element) { DateTime day = DateTime.parse(element.day ?? "");
DateTime day = DateTime.parse(element.day ?? ""); return (date.year == day.year &&
return (date.year == day.year && date.month == day.month &&
date.month == day.month && date.day == day.day);
date.day == day.day); })
}) .map((e) => e.description)
.map((e) => e.description) .toList();
.toList(); },
}, availableCalendarFormats: const {
availableCalendarFormats: const { CalendarFormat.month: 'Mes',
CalendarFormat.month: 'Mes', CalendarFormat.week: 'Semana',
CalendarFormat.week: 'Semana', CalendarFormat.twoWeeks: '2 Semanas',
CalendarFormat.twoWeeks: '2 Semanas', },
},
),
), ),
SizedBox( ),
width: double.infinity, SizedBox(
child: Padding( width: double.infinity,
padding: child: Padding(
const EdgeInsets.symmetric(horizontal: 15, vertical: 8), padding:
child: Text(DateFormat('dd MMMM yyyy', 'es').format(today)), const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
)), child: Text(DateFormat('dd MMMM yyyy', 'es').format(today)),
const Divider( )),
height: 0, const Divider(
), height: 0,
_eventList() ),
], _eventList()
), ],
floatingActionButton: FloatingActionButton( ),
onPressed: _showDialog, floatingActionButton: FloatingActionButton(
child: const Icon(Icons.add), onPressed: _showDialog,
), child: const Icon(Icons.add),
), ),
); );
} }
@@ -329,7 +326,7 @@ class _CalendarScreenState extends State<CalendarScreen> {
try { try {
eventos.addAll(snapshot.data!); eventos.addAll(snapshot.data!);
} catch (e) { } catch (e) {
print("Hola" + e.toString()); print("Error" + e.toString());
} }
if (eventos.isEmpty) { if (eventos.isEmpty) {
@@ -339,6 +336,24 @@ class _CalendarScreenState extends State<CalendarScreen> {
children: [ children: [
...eventos.map( ...eventos.map(
(e) => ListTile( (e) => ListTile(
onTap: () {
final evento = Event(
day: e.day,
description: e.description,
userId: e.userId,
range1Hour1: e.range1Hour1,
range1Hour2: e.range1Hour2,
title: e.title,
);
Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return CitaScreen(evento: evento);
},
),
);
},
leading: Text('${e.range1Hour1}'), leading: Text('${e.range1Hour1}'),
title: RichText( title: RichText(
text: TextSpan( text: TextSpan(
@@ -354,8 +369,8 @@ class _CalendarScreenState extends State<CalendarScreen> {
TextSpan( TextSpan(
text: DateFormat('dd MMM', 'es') text: DateFormat('dd MMM', 'es')
.format(DateTime.parse(e.day!)), .format(DateTime.parse(e.day!)),
style: TextStyle( style: const TextStyle(
color: Colors.grey[400], color: Colors.grey,
fontSize: 16, fontSize: 16,
), ),
), ),
+149
View File
@@ -0,0 +1,149 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:intl/intl.dart';
import 'package:prosappco/src/components/photo_view.dart';
import 'package:prosappco/src/components/pop_appbar.dart';
import 'package:prosappco/src/models/event_model.dart';
import 'package:prosappco/src/models/user_model.dart';
class CitaScreen extends StatefulWidget {
final Event evento;
const CitaScreen({super.key, required this.evento});
@override
State<CitaScreen> createState() => _CitaScreenState();
}
class _CitaScreenState extends State<CitaScreen> {
UserModel? user;
@override
String nombre = '';
Reference? ref_photo;
@override
void initState() {
super.initState();
if (user == null) {
UserModel.getUser(uid.toString()).then(
(UserModel s) => setState(() => user = s),
);
}
}
Widget build(BuildContext context) {
if (nombre == '') {
UserModel.getUser(widget.evento.userId!).then((value) {
setState(() {
nombre = value.name;
ref_photo = value.photo;
});
});
}
final User? currentUser = FirebaseAuth.instance.currentUser;
return Scaffold(
appBar: PopAppbar(
onPressed: () {
Navigator.pop(context);
},
label: 'Servicio'),
body: Column(
children: [
Expanded(
child: Column(
children: [
ListTile(
leading: ReferencePhoto(
ref: ref_photo,
size: 50,
sizeCircle: 50,
sizeIcon: 35,
),
title: RichText(
text: TextSpan(
children: [
TextSpan(
text: '${nombre}, ',
style: const TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
TextSpan(
text:
'${DateFormat('dd MMM', 'es').format(DateTime.parse(widget.evento.day!))} ${widget.evento.range1Hour1}',
style: TextStyle(
color: Colors.grey,
fontSize: 16,
),
),
],
),
),
subtitle: Row(
children: [
RatingBar.builder(
initialRating: user?.score?.average ?? 0,
minRating: 1,
direction: Axis.horizontal,
allowHalfRating: true,
itemCount: 5,
itemSize: 25,
maxRating: 5,
itemPadding: const EdgeInsets.symmetric(horizontal: 0),
itemBuilder: (context, _) => const Icon(
Icons.star,
color: Color(0xFF2BA4EC),
),
onRatingUpdate: (rating) {},
ignoreGestures: true,
),
const SizedBox(width: 5),
Text(
'(${user?.score?.total.toString()}) ${user?.score?.average.toString()}'),
],
),
),
Text(
textAlign: TextAlign.center,
'" ${widget.evento.description} "',
style: TextStyle(
color: Colors.grey, fontStyle: FontStyle.italic),
)
],
),
),
Center(
child: Padding(
padding: const EdgeInsets.only(bottom: 30),
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFFEC2B2B),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
elevation: 0,
minimumSize: const Size(230, 60),
),
child: const Text(
'Cancelar servicio',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
),
),
),
],
),
);
}
}
+41 -3
View File
@@ -9,6 +9,8 @@ import 'package:prosappco/src/components/pop_appbar.dart';
import 'package:prosappco/src/models/score_model.dart'; import 'package:prosappco/src/models/score_model.dart';
import 'package:prosappco/src/screens/professional_info.dart'; import 'package:prosappco/src/screens/professional_info.dart';
import '../models/score_model2.dart';
class ProfessionalScreen extends StatefulWidget { class ProfessionalScreen extends StatefulWidget {
const ProfessionalScreen({super.key}); const ProfessionalScreen({super.key});
@@ -29,7 +31,7 @@ class Professional {
final String cityName; final String cityName;
final String ubicacion; final String ubicacion;
final List<String> professionalEspecializado; final List<String> professionalEspecializado;
final ScoreModel puntuacion; final ScoresModel scores;
Professional({ Professional({
required this.professionalRef, required this.professionalRef,
@@ -38,7 +40,7 @@ class Professional {
required this.cityName, required this.cityName,
required this.ubicacion, required this.ubicacion,
required this.professionalEspecializado, required this.professionalEspecializado,
required this.puntuacion, required this.scores,
}); });
String getEspecializaciones() { String getEspecializaciones() {
@@ -56,6 +58,42 @@ class Professional {
' professionalEspecializado: ${getEspecializaciones()}\n' ' professionalEspecializado: ${getEspecializaciones()}\n'
'}'; '}';
} }
static Future<Professional?> getProfessional(String uid) async {
var photo = '...';
final FirebaseStorage storage = FirebaseStorage.instance;
try {
DocumentSnapshot user =
await FirebaseFirestore.instance.collection('users').doc(uid).get();
Map<String, dynamic> data = user.data() as Map<String, dynamic>;
photo = await AuthenticationRepository.instance.getPhoto(user.id);
if (data['estado'] == 'activo') {
List<String> especializaciones;
especializaciones = (data['especializaciones'] as List<dynamic>)
.map((e) => e.toString())
.toList();
Professional professional = Professional(
name: data['name'],
professionName: data['profesion'],
cityName: data['city'],
professionalRef: storage.ref().child(photo),
professionalEspecializado: especializaciones,
ubicacion: data['ubicacion'] ?? '',
scores: await ScoresModel.scoreFrom(uid, true),
);
return professional;
}
} catch (e) {
print('Error al obtener profesionales: $e');
}
return null;
}
} }
Future<List<Professional>> getProfessionals() async { Future<List<Professional>> getProfessionals() async {
@@ -84,7 +122,7 @@ Future<List<Professional>> getProfessionals() async {
professionalRef: storage.ref().child(_photo), professionalRef: storage.ref().child(_photo),
professionalEspecializado: especializaciones, professionalEspecializado: especializaciones,
ubicacion: data['ubicacion'] ?? '', ubicacion: data['ubicacion'] ?? '',
puntuacion: await ScoreModel.fromJson(data['puntuacion'], true), scores: await ScoresModel.scoreTo(user.id, true),
); );
professionals.add(professional); professionals.add(professional);
} }
+7 -8
View File
@@ -1,13 +1,13 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.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/models/score_model.dart';
import 'package:prosappco/src/screens/professional.dart'; import 'package:prosappco/src/screens/professional.dart';
import 'package:prosappco/src/screens/reputation.dart'; import 'package:prosappco/src/screens/reputation.dart';
import '../models/score_model2.dart';
class ProfessionalInfoScreen extends StatefulWidget { class ProfessionalInfoScreen extends StatefulWidget {
Professional professional; Professional professional;
@@ -153,8 +153,7 @@ class _ProfessionalInfoScreenState extends State<ProfessionalInfoScreen> {
subtitle: Row( subtitle: Row(
children: [ children: [
RatingBar.builder( RatingBar.builder(
initialRating: initialRating: widget.professional.scores.average,
widget.professional.puntuacion.average,
minRating: 1, minRating: 1,
direction: Axis.horizontal, direction: Axis.horizontal,
allowHalfRating: true, allowHalfRating: true,
@@ -172,12 +171,12 @@ class _ProfessionalInfoScreenState extends State<ProfessionalInfoScreen> {
), ),
const SizedBox(width: 5), const SizedBox(width: 5),
Text( Text(
'(${widget.professional.puntuacion.total.toString()}) ${widget.professional.puntuacion.average.toString()}'), '(${widget.professional.scores.total.toString()}) ${widget.professional.scores.average.toString()}'),
], ],
), ),
), ),
), ),
..._scoresList(widget.professional.puntuacion.details), ..._scoresList(widget.professional.scores.scores),
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
@@ -202,11 +201,11 @@ class _ProfessionalInfoScreenState extends State<ProfessionalInfoScreen> {
); );
} }
List<Widget> _scoresList(List<ScoreDetailsModel> list) { List<Widget> _scoresList(List<ScoreModel2> list) {
return list.map((e) => _scoreItem(e)).toList(); return list.map((e) => _scoreItem(e)).toList();
} }
Widget _scoreItem(ScoreDetailsModel scoreDetails) { Widget _scoreItem(ScoreModel2 scoreDetails) {
return ListTile( return ListTile(
onTap: () {}, onTap: () {},
leading: ReferencePhoto( leading: ReferencePhoto(
+154 -157
View File
@@ -341,169 +341,166 @@ class _ProfileScreenState extends State<ProfileScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
String city = _ciudad.toString(); String city = _ciudad.toString();
return SafeArea( return Scaffold(
child: Scaffold( appBar: PopAppbar(
appBar: PopAppbar( onPressed: () {
onPressed: () { Navigator.pop(context);
Navigator.pop(context); },
}, label: 'Perfil'),
label: 'Perfil'), body: SingleChildScrollView(
body: SingleChildScrollView( reverse: true,
reverse: true, child: Center(
child: Center( child: Column(
child: Column( children: [
children: [ GestureDetector(
GestureDetector( onTap: () {
onTap: () { _showChoiceDialog(context);
_showChoiceDialog(context); },
}, child: Container(
child: Container( margin: const EdgeInsets.symmetric(vertical: 50),
margin: const EdgeInsets.symmetric(vertical: 50), child: (imagen_to_upload != null)
child: (imagen_to_upload != null) ? LocalPhoto(
? LocalPhoto( file: imagen_to_upload!,
file: imagen_to_upload!, )
) : ReferencePhoto(
: ReferencePhoto( ref: storage.ref().child(_photo),
ref: storage.ref().child(_photo), )),
)), ),
), Container(
Container( width: 300,
width: 300, padding: const EdgeInsets.only(top: 0),
padding: const EdgeInsets.only(top: 0), child: Form(
child: Form( key: _formKey,
key: _formKey, child: Column(
child: Column( children: [
children: [ TextFormField(
TextFormField( controller: _nameController,
controller: _nameController, decoration: const InputDecoration(
decoration: const InputDecoration( prefixIcon: Icon(Icons.person_outline),
prefixIcon: Icon(Icons.person_outline), hintText: 'Nombre (Obligatorio)'),
hintText: 'Nombre (Obligatorio)'), ),
), const SizedBox(height: 20.0),
const SizedBox(height: 20.0), _email != null
_email != null ? TextFormField(
? TextFormField( onTap: () {
onTap: () { Navigator.push(context, CupertinoPageRoute(
Navigator.push(context, CupertinoPageRoute( builder: (BuildContext context) {
builder: (BuildContext context) { return NewPasswordScreen();
return NewPasswordScreen(); },
}, ));
)); },
}, readOnly: true,
readOnly: true, controller: _emailController,
controller: _emailController, decoration: const InputDecoration(
decoration: const InputDecoration( prefixIcon: Icon(Icons.email_outlined),
prefixIcon: Icon(Icons.email_outlined), hintText: 'Email (Obligatorio)'),
hintText: 'Email (Obligatorio)'), )
) : TextFormField(
: TextFormField( controller: _emailController,
controller: _emailController, decoration: const InputDecoration(
decoration: const InputDecoration( prefixIcon: Icon(Icons.email_outlined),
prefixIcon: Icon(Icons.email_outlined), hintText: 'Email (Obligatorio)'),
hintText: 'Email (Obligatorio)'), ),
), const SizedBox(height: 20.0),
const SizedBox(height: 20.0), _email != null
_email != null ? const SizedBox.shrink()
? const SizedBox.shrink() : TextFormField(
: TextFormField( controller: _passwordController,
controller: _passwordController, obscureText: _obscureText,
obscureText: _obscureText, decoration: InputDecoration(
decoration: InputDecoration( prefixIcon: const Icon(Icons.lock_outline),
prefixIcon: suffixIcon: IconButton(
const Icon(Icons.lock_outline), icon: Icon(
suffixIcon: IconButton( _obscureText
icon: Icon( ? Icons.visibility
_obscureText : Icons.visibility_off,
? Icons.visibility color: Colors.grey,
: Icons.visibility_off,
color: Colors.grey,
),
onPressed: () {
setState(() {
_obscureText = !_obscureText;
});
},
), ),
hintText: 'Contraseña (Obligatorio)'), onPressed: () {
), setState(() {
_email != null _obscureText = !_obscureText;
? const SizedBox.shrink() });
: const SizedBox(height: 20.0), },
TextFormField( ),
readOnly: true, hintText: 'Contraseña (Obligatorio)'),
onTap: () async { ),
final String? ciudad = await Navigator.push( _email != null
context, ? const SizedBox.shrink()
CupertinoPageRoute( : const SizedBox(height: 20.0),
builder: (BuildContext context) { TextFormField(
return const CityScreen(); readOnly: true,
}, onTap: () async {
), final String? ciudad = await Navigator.push(
) as String?; context,
CupertinoPageRoute(
builder: (BuildContext context) {
return const CityScreen();
},
),
) as String?;
if (ciudad != null) { if (ciudad != null) {
setState(() { setState(() {
_ciudad = ciudad; _ciudad = ciudad;
}); });
} }
}, },
decoration: InputDecoration( decoration: InputDecoration(
prefixIcon: const Icon(Icons.near_me), prefixIcon: const Icon(Icons.near_me),
suffixIcon: const Icon(Icons.arrow_drop_down), suffixIcon: const Icon(Icons.arrow_drop_down),
hintStyle: city == '' hintStyle: city == ''
? const TextStyle() ? const TextStyle()
: const TextStyle(color: Colors.black87), : const TextStyle(color: Colors.black87),
hintText: city == '' ? 'Ciudad' : city), hintText: city == '' ? 'Ciudad' : city),
), ),
const SizedBox(height: 20.0), const SizedBox(height: 20.0),
TextFormField( TextFormField(
controller: _phoneNumberController, controller: _phoneNumberController,
readOnly: true, readOnly: true,
onTap: () { onTap: () {
Navigator.of(context).push( Navigator.of(context).push(
CupertinoPageRoute( CupertinoPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return const NewNumberScreen(); return const NewNumberScreen();
}, },
), ),
); );
}, },
decoration: const InputDecoration( decoration: const InputDecoration(
prefixIcon: Icon(Icons.phone_android), prefixIcon: Icon(Icons.phone_android),
suffixIcon: Icon(Icons.edit_outlined), suffixIcon: Icon(Icons.edit_outlined),
hintText: '+57'), hintText: '+57'),
), ),
], ],
)), )),
), ),
Container( Container(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 100), margin: const EdgeInsets.only(top: 100),
padding: const EdgeInsets.only(bottom: 30), padding: const EdgeInsets.only(bottom: 30),
child: ElevatedButton( child: ElevatedButton(
onPressed: () async { onPressed: () async {
await updateInfo(); await updateInfo();
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF2BA4EC), backgroundColor: const Color(0xFF2BA4EC),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50), borderRadius: BorderRadius.circular(50),
),
elevation: 0,
minimumSize: const Size(200, 50),
), ),
child: const Text( elevation: 0,
'Guardar', minimumSize: const Size(200, 50),
style: TextStyle( ),
color: Colors.white, child: const Text(
fontWeight: FontWeight.bold, 'Guardar',
fontSize: 17, style: TextStyle(
), color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 17,
), ),
), ),
), ),
], ),
), ],
), ),
), ),
), ),
+184 -195
View File
@@ -10,6 +10,7 @@ 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/banner_photo.dart';
import 'package:prosappco/src/components/drawer_professional.dart'; import 'package:prosappco/src/components/drawer_professional.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';
import 'package:prosappco/src/screens/horario.dart'; import 'package:prosappco/src/screens/horario.dart';
@@ -258,217 +259,205 @@ class _ProfileProState extends State<ProfilePro> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
String address = _direccion.toString(); String address = _direccion.toString();
return SafeArea( return Scaffold(
child: Scaffold( appBar: PopAppbar(
appBar: AppBar( onPressed: () {
backgroundColor: Colors.white, Navigator.pop(context);
iconTheme: const IconThemeData( },
color: Colors.black, label: 'Perfil profesional'),
), body: SingleChildScrollView(
title: const Text( reverse: true,
'Perfil profesional', child: Column(
style: TextStyle( children: [
color: Colors.black, GestureDetector(
), onTap: () {
), _showChoiceDialog(context);
), },
drawer: DrawerProfessional(), child: Container(
body: SingleChildScrollView( child: (imagen_to_upload != null)
reverse: true, ? LocalPhoto(
child: Column( file: imagen_to_upload!,
children: [
GestureDetector(
onTap: () {
_showChoiceDialog(context);
},
child: Container(
child: (imagen_to_upload != null)
? LocalPhoto(
file: imagen_to_upload!,
)
: ReferenceBannerPhoto(
ref: storage.ref().child(_photo),
),
),
),
const Divider(
color: Colors.white,
height: 12,
),
customSwitch(
'Servicio a domicilio',
domicilioValue,
(value) {
domicilioValue = value;
},
),
const Divider(),
customSwitch(
'Servicio en sitio',
sitioValue,
(value) {
sitioValue = value;
},
),
sitioValue
? Padding(
padding: const EdgeInsets.only(
left: 40, right: 40, bottom: 15),
child: Column(
children: [
TextFormField(
// controller: _emailController,
readOnly: true,
onTap: () async {
final String? direccion = await Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return const ProfessionalDireccionScreen();
},
),
) as String?;
if (direccion != null) {
setState(() {
_direccion = direccion;
});
}
},
decoration: InputDecoration(
prefixIcon: const Icon(Icons.near_me),
hintStyle: address == ''
? const TextStyle()
: const TextStyle(color: Colors.black87),
hintText:
address == '' ? 'Dirección' : address),
),
const SizedBox(height: 10),
TextFormField(
controller: _opcionalAddressController,
decoration: const InputDecoration(
hintText: 'Oficina / Piso / Conjunto'),
),
],
) )
.animate() : ReferenceBannerPhoto(
.moveY(duration: const Duration(milliseconds: 100)), ref: storage.ref().child(_photo),
),
),
),
const Divider(
color: Colors.white,
height: 12,
),
customSwitch(
'Servicio a domicilio',
domicilioValue,
(value) {
domicilioValue = value;
},
),
const Divider(),
customSwitch(
'Servicio en sitio',
sitioValue,
(value) {
sitioValue = value;
},
),
sitioValue
? Padding(
padding:
const EdgeInsets.only(left: 40, right: 40, bottom: 15),
child: Column(
children: [
TextFormField(
// controller: _emailController,
readOnly: true,
onTap: () async {
final String? direccion = await Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return const ProfessionalDireccionScreen();
},
),
) as String?;
if (direccion != null) {
setState(() {
_direccion = direccion;
});
}
},
decoration: InputDecoration(
prefixIcon: const Icon(Icons.near_me),
hintStyle: address == ''
? const TextStyle()
: const TextStyle(color: Colors.black87),
hintText: address == '' ? 'Dirección' : address),
),
const SizedBox(height: 10),
TextFormField(
controller: _opcionalAddressController,
decoration: const InputDecoration(
hintText: 'Oficina / Piso / Conjunto'),
),
],
) )
: const SizedBox(), .animate()
const Divider(), .moveY(duration: const Duration(milliseconds: 100)),
const Padding( )
padding: EdgeInsets.symmetric(horizontal: 30), : const SizedBox(),
child: SizedBox( const Divider(),
width: double.infinity, const Padding(
child: Text( padding: EdgeInsets.symmetric(horizontal: 30),
'Horario estandar', child: SizedBox(
style: TextStyle( width: double.infinity,
color: Colors.black, child: Text(
fontSize: 15, 'Horario estandar',
), style: TextStyle(
color: Colors.black,
fontSize: 15,
), ),
), ),
), ),
GestureDetector( ),
onTap: () { GestureDetector(
Navigator.push( onTap: () {
context, Navigator.push(
CupertinoPageRoute( context,
builder: (BuildContext context) { CupertinoPageRoute(
return HorarioScreen( builder: (BuildContext context) {
horarios: _horarios!, return HorarioScreen(
); horarios: _horarios!,
}, );
), },
); ),
}, );
child: Column( },
children: [ child: Column(
Padding( children: [
padding: const EdgeInsets.symmetric(vertical: 10), Padding(
child: Row( padding: const EdgeInsets.symmetric(vertical: 10),
children: const [ child: Row(
Expanded( children: const [
child: Padding( Expanded(
padding: EdgeInsets.only(left: 30), child: Padding(
child: Text( padding: EdgeInsets.only(left: 30),
'Dia',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500),
),
),
),
Padding(
padding: EdgeInsets.only(right: 170),
child: Text( child: Text(
'Hora', 'Dia',
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.w500), fontWeight: FontWeight.w500),
), ),
), ),
Padding( ),
padding: EdgeInsets.only(right: 45), Padding(
child: Icon(Icons.edit_outlined), padding: EdgeInsets.only(right: 170),
child: Text(
'Hora',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500),
), ),
], ),
), Padding(
padding: EdgeInsets.only(right: 45),
child: Icon(Icons.edit_outlined),
),
],
), ),
Padding( ),
padding: sitioValue Padding(
? const EdgeInsets.only(bottom: 30) padding: sitioValue
: const EdgeInsets.only(bottom: 70), ? const EdgeInsets.only(bottom: 30)
child: Row( : const EdgeInsets.only(bottom: 70),
children: [ child: Row(
Padding( children: [
padding: const EdgeInsets.only(left: 30), Padding(
child: Column( padding: const EdgeInsets.only(left: 30),
crossAxisAlignment: CrossAxisAlignment.start, child: Column(
children: const [ crossAxisAlignment: CrossAxisAlignment.start,
Text('Lunes'), children: const [
Text('Martes'), Text('Lunes'),
Text('Miércoles'), Text('Martes'),
Text('Jueves'), Text('Miércoles'),
Text('Viernes'), Text('Jueves'),
Text('Sábado'), Text('Viernes'),
Text('Domingo'), Text('Sábado'),
], Text('Domingo'),
), ],
), ),
Padding( ),
padding: const EdgeInsets.only(left: 25), Padding(
child: Column( padding: const EdgeInsets.only(left: 25),
crossAxisAlignment: CrossAxisAlignment.start, child: Column(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
Text(timeList(_horarios?['Lunes'], context)), children: [
Text(timeList(_horarios?['Martes'], context)), Text(timeList(_horarios?['Lunes'], context)),
Text( Text(timeList(_horarios?['Martes'], context)),
timeList(_horarios?['Miercoles'], context)), Text(timeList(_horarios?['Miercoles'], context)),
Text(timeList(_horarios?['Jueves'], context)), Text(timeList(_horarios?['Jueves'], context)),
Text(timeList(_horarios?['Viernes'], context)), Text(timeList(_horarios?['Viernes'], context)),
Text(timeList(_horarios?['Sabado'], context)), Text(timeList(_horarios?['Sabado'], context)),
Text(timeList(_horarios?['Domingo'], context)), Text(timeList(_horarios?['Domingo'], context)),
], ],
),
), ),
], ),
), ],
), ),
], ),
), ],
), ),
PrimaryButtom( ),
onPressed: () { PrimaryButtom(
updateInfo(); onPressed: () {
}, updateInfo();
label: 'Guardar'), },
const SizedBox( label: 'Guardar'),
height: 20, const SizedBox(
) height: 20,
], )
), ],
), ),
), ),
); );
@@ -515,7 +504,7 @@ class _ProfileProState extends State<ProfilePro> {
return 'N/A'; return 'N/A';
} }
if (schedule.jornadaContinua) { if (schedule.jornadaContinua) {
return '${schedule.range1Hour1?.format(context).toString()} - ${schedule.range1Hour2?.format(context).toString()}'; return '${schedule.range1Hour1?.format(context).toString()} - ${schedule.range2Hour2?.format(context).toString()}';
} else { } else {
return '${schedule.range1Hour1?.format(context).toString()} - ${schedule.range1Hour2?.format(context).toString()}; ${schedule.range2Hour1?.format(context).toString()} - ${schedule.range2Hour2?.format(context).toString()}'; return '${schedule.range1Hour1?.format(context).toString()} - ${schedule.range1Hour2?.format(context).toString()}; ${schedule.range2Hour1?.format(context).toString()} - ${schedule.range2Hour2?.format(context).toString()}';
} }
+27
View File
@@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:prosappco/src/components/drawer_professional.dart';
class PruebaScreen extends StatelessWidget {
const PruebaScreen({super.key});
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
iconTheme: const IconThemeData(
color: Colors.black,
),
title: const Text(
'Prueba',
style: TextStyle(
color: Colors.black,
),
),
),
drawer: DrawerProfessional(),
),
);
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ class ReputationScreen extends StatelessWidget {
body: SingleChildScrollView( body: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
..._scoresList(professional.puntuacion.details), //..._scoresList(professional.puntuacion.details),
], ],
)), )),
)); ));