This commit is contained in:
Juan Felipe Duarte
2023-05-10 08:43:40 -05:00
parent eeced3ac66
commit 40ee4f2ab2
30 changed files with 1175 additions and 147 deletions
+151 -6
View File
@@ -3,6 +3,7 @@ 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:get/get.dart';
import 'package:intl/intl.dart';
import 'package:prosappco/src/authentication/authentication_repository.dart';
import 'package:prosappco/src/components/photo_view.dart';
@@ -11,6 +12,7 @@ import 'package:prosappco/src/models/event_model.dart';
import 'package:prosappco/src/models/scores_model.dart';
import 'package:prosappco/src/models/user_model.dart';
import 'package:prosappco/src/screens/chat.dart';
import 'package:prosappco/src/screens/score.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:community_material_icon/community_material_icon.dart';
@@ -25,13 +27,20 @@ class CitaScreen extends StatefulWidget {
class _CitaScreenState extends State<CitaScreen> {
final uid = AuthenticationRepository.instance.getCurrentUserUid();
UserModel? user;
@override
DateTime today = DateTime.now();
String nombre = '';
int tarifa = 0;
Reference? ref_photo;
ScoresModel? scoresModel;
final phoneNumber = '+573022548060';
String formatCurrency(int number) {
final formatter =
NumberFormat.currency(locale: 'es_CO', decimalDigits: 0, symbol: '');
return '\$${formatter.format(number)}';
}
Future<void> _openMap(double lat, double lng) async {
final Uri _url =
Uri.parse('https://www.google.com/maps/search/?api=1&query=$lat,$lng');
@@ -73,17 +82,25 @@ class _CitaScreenState extends State<CitaScreen> {
@override
Widget build(BuildContext context) {
today.difference(DateTime.parse(widget.evento.range1Hour1));
// DateTime todays = DateFormat('hh:mm a').parse(today.timeZoneName);
final eventDate = DateFormat('yyyy-MM-dd').parse(widget.evento.day);
if (nombre == '') {
if (uid != widget.evento.userId) {
UserModel.getUser(widget.evento.userId).then((value) {
setState(() {
nombre = value.name;
ref_photo = value.photo;
UserModel.getUser(uid.toString()).then((me) {
setState(() {
tarifa = me.tarifa ?? 0;
nombre = value.name;
ref_photo = value.photo;
});
});
});
} else {
UserModel.getUser(widget.evento.professionalId).then((value) {
setState(() {
tarifa = value.tarifa ?? 0;
nombre = value.name;
ref_photo = value.photo;
});
@@ -122,7 +139,7 @@ class _CitaScreenState extends State<CitaScreen> {
),
TextSpan(
text:
'${DateFormat('dd MMM', 'es').format(DateTime.parse(widget.evento.day))} ${widget.evento.range1Hour1}',
'${DateFormat('dd MMM', 'es').format(DateTime.parse(widget.evento.day))} ${TimeOfDay.fromDateTime(DateTime.parse(widget.evento.range1Hour1)).format(context)}',
style: const TextStyle(
color: Colors.grey,
fontSize: 16,
@@ -151,7 +168,7 @@ class _CitaScreenState extends State<CitaScreen> {
),
const SizedBox(width: 5),
Text(
'(${scoresModel?.total.toString()}) ${scoresModel?.average.toString()}'),
'(${scoresModel?.total.toString()}) ${scoresModel?.average.toStringAsFixed(1)}'),
],
),
),
@@ -194,6 +211,18 @@ class _CitaScreenState extends State<CitaScreen> {
],
),
),
Column(
children: [
Text(
formatCurrency(tarifa),
style: const TextStyle(
fontWeight: FontWeight.w600, fontSize: 25),
),
Text('Tarifa consulta ${widget.evento.tarifa}',
style: const TextStyle(fontSize: 15)),
],
),
const SizedBox(height: 15),
Text(
textAlign: TextAlign.center,
'" ${widget.evento.description} "',
@@ -367,6 +396,80 @@ class _CitaScreenState extends State<CitaScreen> {
],
),
),
widget.evento.status == 'aprobado'
? eventDate.year == today.year &&
eventDate.month == today.month &&
eventDate.day == today.day
? (DateTime.now()
.difference(
DateTime.parse(widget.evento.range1Hour1))
.abs() <=
const Duration(minutes: 30))
? Padding(
padding: const EdgeInsets.only(bottom: 30),
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(bottom: 20),
child: ElevatedButton(
onPressed: () {
FirebaseFirestore.instance
.collection("services")
.doc('${widget.evento.id}')
.update({"status": "iniciado"});
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF2BA4EC),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
elevation: 0,
minimumSize: const Size(230, 60),
),
child: const Text(
'Iniciar servicio',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
),
),
ElevatedButton(
onPressed: () {
FirebaseFirestore.instance
.collection("services")
.doc('${widget.evento.id}')
.update({"status": "denegado"}).then(
(value) {
Navigator.pushReplacementNamed(
context, '/solicitud');
});
},
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,
),
),
),
],
),
)
: const SizedBox()
: const SizedBox()
: const SizedBox(),
widget.evento.status == 'pendiente'
? Padding(
padding: const EdgeInsets.only(bottom: 30),
@@ -433,6 +536,48 @@ class _CitaScreenState extends State<CitaScreen> {
),
)
: const SizedBox(),
widget.evento.status == 'iniciado'
? Padding(
padding: const EdgeInsets.only(bottom: 30),
child: Column(
children: [
ElevatedButton(
onPressed: () {
FirebaseFirestore.instance
.collection("services")
.doc('${widget.evento.id}')
.update({"status": "terminado"}).then((value) {
Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return ScoreScreen(evento: widget.evento);
},
),
);
});
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF2BA4EC),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
elevation: 0,
minimumSize: const Size(230, 60),
),
child: const Text(
'Terminar servicio',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
),
],
),
)
: const SizedBox(),
],
),
);