push ordenar por timestamp
This commit is contained in:
+1
-1
@@ -106,7 +106,7 @@ class MyApp extends StatelessWidget {
|
||||
'/profilePro': (context) => const ProfileProScreen(),
|
||||
'/calendar': (context) => const CalendarScreen(),
|
||||
'/solicitud': (context) => SolicitudScreen(),
|
||||
'/misserviciospro': (context) => const MyServicesProScreen(),
|
||||
'/misserviciospro': (context) => MyServicesProScreen(),
|
||||
'/misservicios': (context) => MyServicesScreen(),
|
||||
},
|
||||
onGenerateRoute: (settings) {
|
||||
|
||||
@@ -27,7 +27,6 @@ class DrawerMenu extends StatefulWidget {
|
||||
|
||||
class _DrawerMenuState extends State<DrawerMenu> {
|
||||
final uid = AuthenticationRepository.instance.getCurrentUserUid();
|
||||
UserModel? user;
|
||||
ScoresModel? scoresModel;
|
||||
|
||||
@override
|
||||
@@ -54,7 +53,7 @@ class _DrawerMenuState extends State<DrawerMenu> {
|
||||
Widget build(BuildContext context) {
|
||||
final userProvider = Provider.of<UserProvider>(context);
|
||||
|
||||
// final UserModel? user = userProvider.user;
|
||||
UserModel? user;
|
||||
|
||||
return Drawer(
|
||||
child: Column(
|
||||
@@ -68,7 +67,7 @@ class _DrawerMenuState extends State<DrawerMenu> {
|
||||
builder: (BuildContext context,
|
||||
AsyncSnapshot<UserModel> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (snapshot.hasError) {
|
||||
return Center(child: Text('Error: ${snapshot.error}'));
|
||||
} else {
|
||||
@@ -343,59 +342,77 @@ class _DrawerMenuState extends State<DrawerMenu> {
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
if (user?.name == '' ||
|
||||
user?.city == '' ||
|
||||
user?.phoneNumber == '' ||
|
||||
user?.phoneNumber == null) {
|
||||
Get.snackbar(
|
||||
'Completa tu perfil',
|
||||
'Para ser un profesional registrado, asegúrate de llenar todos los campos necesarios y no olvides guardar tus cambios para que surtan efecto.',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
);
|
||||
StreamBuilder<UserModel>(
|
||||
stream: userProvider.itemsStream,
|
||||
builder:
|
||||
(BuildContext context, AsyncSnapshot<UserModel> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (snapshot.hasError) {
|
||||
return Center(child: Text('Error: ${snapshot.error}'));
|
||||
} else {
|
||||
if (user?.phoneNumber != user?.phoneNumber) {
|
||||
Get.snackbar(
|
||||
'Tu número de teléfono sigue sin cambios.',
|
||||
'Para guardar esta información, dirígete a tu perfil y selecciona la opción Guardar',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
);
|
||||
} else {
|
||||
if (user?.state == 'pendiente' || user?.state == null) {
|
||||
if (kIsWeb) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const ProfessionalProfileWebScreen()),
|
||||
UserModel? user = snapshot.data;
|
||||
|
||||
return ElevatedButton(
|
||||
onPressed: () {
|
||||
if (user?.name == '' ||
|
||||
user?.city == '' ||
|
||||
user?.phoneNumber == '' ||
|
||||
user?.phoneNumber == null) {
|
||||
Get.snackbar(
|
||||
'Completa tu perfil',
|
||||
'Para ser un profesional registrado, asegúrate de llenar todos los campos necesarios y no olvides guardar tus cambios para que surtan efecto.',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
);
|
||||
} else {
|
||||
Navigator.pushNamed(context, '/profesionalProfile');
|
||||
if (user?.phoneNumber != user?.phoneNumber) {
|
||||
Get.snackbar(
|
||||
'Tu número de teléfono sigue sin cambios.',
|
||||
'Para guardar esta información, dirígete a tu perfil y selecciona la opción Guardar',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
);
|
||||
} else {
|
||||
if (user?.state == 'pendiente' ||
|
||||
user?.state == null) {
|
||||
if (kIsWeb) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const ProfessionalProfileWebScreen(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
Navigator.pushNamed(
|
||||
context, '/profesionalProfile');
|
||||
}
|
||||
} else if (user?.state == 'revision') {
|
||||
Navigator.pushNamed(
|
||||
context, '/profesionalRevision');
|
||||
} else if (user?.state == 'activo') {
|
||||
Navigator.pushNamed(context, '/solicitud');
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (user?.state == 'revision') {
|
||||
Navigator.pushNamed(context, '/profesionalRevision');
|
||||
} else if (user?.state == 'activo') {
|
||||
Navigator.pushNamed(context, '/solicitud');
|
||||
}
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF2BA4EC),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
),
|
||||
elevation: 0,
|
||||
minimumSize: const Size(230, 45),
|
||||
),
|
||||
child: const Text(
|
||||
'Modo profesional',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF2BA4EC),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
),
|
||||
elevation: 0,
|
||||
minimumSize: const Size(230, 45),
|
||||
),
|
||||
child: const Text(
|
||||
'Modo profesional',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ElevatedButton(
|
||||
|
||||
@@ -133,7 +133,7 @@ class _DrawerProfessionalState extends State<DrawerProfessional> {
|
||||
Navigator.of(context).push(
|
||||
CupertinoPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return const MyServicesProScreen();
|
||||
return MyServicesProScreen();
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@@ -65,6 +65,7 @@ Future<List<Event>> getByProId(String day) async {
|
||||
.where('professional_id', isEqualTo: uid)
|
||||
.where('day', isEqualTo: day.toString())
|
||||
.where('status', isEqualTo: 'aprobado')
|
||||
.orderBy('Timestamp', descending: true)
|
||||
.get();
|
||||
|
||||
List<Event> eventos = [];
|
||||
@@ -141,6 +142,7 @@ class Event {
|
||||
int? tarifa;
|
||||
bool professionalScored;
|
||||
bool userScored;
|
||||
Timestamp? timeStamp;
|
||||
|
||||
Event({
|
||||
this.id,
|
||||
@@ -156,6 +158,7 @@ class Event {
|
||||
this.longitud,
|
||||
this.latitud,
|
||||
this.status = 'pendiente',
|
||||
this.timeStamp,
|
||||
this.tarifa,
|
||||
this.professionalScored = false,
|
||||
this.userScored = false,
|
||||
@@ -176,6 +179,7 @@ class Event {
|
||||
longitud: json['longitude'] ?? 0,
|
||||
latitud: json['latitude'] ?? 0,
|
||||
status: json['status'],
|
||||
timeStamp: json['Timestamp'] ?? 0,
|
||||
tarifa: json['tarifa'] ?? 0,
|
||||
professionalScored: json['professional_scored'],
|
||||
userScored: json['user_scored'],
|
||||
|
||||
@@ -87,7 +87,7 @@ class _MyServicesScreenState extends State<MyServicesScreen> {
|
||||
|
||||
try {
|
||||
eventos.addAll(snapshot.data!);
|
||||
eventos.sort((a, b) => a.range1Hour1.compareTo(b.range1Hour1));
|
||||
eventos.sort((a, b) => a.timeStamp!.compareTo(b.timeStamp!));
|
||||
} catch (e) {
|
||||
print("Error" + e.toString());
|
||||
}
|
||||
|
||||
@@ -10,21 +10,12 @@ import 'package:prosappco/src/models/event_model.dart';
|
||||
import 'package:prosappco/src/models/scores_model.dart';
|
||||
import 'package:prosappco/src/screens/cita.dart';
|
||||
|
||||
class MyServicesProScreen extends StatefulWidget {
|
||||
const MyServicesProScreen({super.key});
|
||||
class MyServicesProScreen extends StatelessWidget {
|
||||
MyServicesProScreen({super.key});
|
||||
|
||||
@override
|
||||
State<MyServicesProScreen> createState() => _MyServicesProScreenState();
|
||||
}
|
||||
|
||||
class _MyServicesProScreenState extends State<MyServicesProScreen> {
|
||||
DateTime today = DateTime.now();
|
||||
final uid = AuthenticationRepository.instance.getCurrentUserUid();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
final uid = AuthenticationRepository.instance.getCurrentUserUid();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -83,7 +74,7 @@ class _MyServicesProScreenState extends State<MyServicesProScreen> {
|
||||
|
||||
try {
|
||||
eventos.addAll(snapshot.data!);
|
||||
eventos.sort((a, b) => a.range1Hour1.compareTo(b.range1Hour1));
|
||||
eventos.sort((a, b) => a.timeStamp!.compareTo(b.timeStamp!));
|
||||
} catch (e) {
|
||||
print("Error" + e.toString());
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class SolicitudScreen extends StatelessWidget {
|
||||
|
||||
try {
|
||||
eventos.addAll(snapshot.data!);
|
||||
eventos.sort((a, b) => a.range1Hour1.compareTo(b.range1Hour1));
|
||||
eventos.sort((a, b) => a.timeStamp!.compareTo(b.timeStamp!));
|
||||
} catch (e) {
|
||||
print("Error" + e.toString());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user