fecha en mensajes y lista profesional

This commit is contained in:
Felipe
2024-05-25 10:09:54 -05:00
parent f1b2497c92
commit 0e93bc23b8
2 changed files with 81 additions and 51 deletions
+24 -5
View File
@@ -367,9 +367,9 @@ class _ChatScreenState extends State<ChatScreen> {
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric(horizontal: 10),
child: Text( child: Text(
DateFormat('h:mm a').format(e.createdAt), _getFechaHoraFormateada(e.createdAt),
style: style:
const TextStyle(color: Colors.grey, fontSize: 12), const TextStyle(color: Colors.grey, fontSize: 11),
), ),
), ),
], ],
@@ -403,10 +403,10 @@ class _ChatScreenState extends State<ChatScreen> {
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric(horizontal: 10),
child: Text( child: Text(
DateFormat('h:mm a').format(e.createdAt), _getFechaHoraFormateada(e.createdAt),
style: const TextStyle( style: const TextStyle(
color: Colors.grey, color: Colors.grey,
fontSize: 12, fontSize: 11,
), ),
), ),
), ),
@@ -417,7 +417,26 @@ class _ChatScreenState extends State<ChatScreen> {
.toList(); .toList();
} }
Future<List<dynamic>> _getUserAndProfessionalInfo(ServiceEntity service) async { String _getFechaHoraFormateada(DateTime fecha) {
final now = DateTime.now();
final yesterday = now.subtract(const Duration(days: 1));
final formatter = DateFormat('h:mm a');
if (fecha.day == now.day &&
fecha.month == now.month &&
fecha.year == now.year) {
return 'Hoy - ${formatter.format(fecha)}';
} else if (fecha.day == yesterday.day &&
fecha.month == yesterday.month &&
fecha.year == yesterday.year) {
return 'Ayer - ${formatter.format(fecha)}';
} else {
return '${DateFormat('dd/MM/yyyy').format(fecha)} - ${formatter.format(fecha)}';
}
}
Future<List<dynamic>> _getUserAndProfessionalInfo(
ServiceEntity service) async {
final userRepo = FirebaseUserRepository(FirebaseAuth.instance); final userRepo = FirebaseUserRepository(FirebaseAuth.instance);
final MyUser? userInfo; final MyUser? userInfo;
+57 -46
View File
@@ -81,55 +81,64 @@ class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
children: [ children: [
_isLoading _isLoading
? _buildShimmerEffect() ? _buildShimmerEffect()
: Container( : _selectedProfession == null
padding: const EdgeInsets.symmetric(horizontal: 20), ? Container(
decoration: BoxDecoration( padding: const EdgeInsets.symmetric(horizontal: 20),
border: Border( decoration: BoxDecoration(
bottom: BorderSide( border: Border(
color: Colors.grey[400]!, bottom: BorderSide(
color: Colors.grey[400]!,
),
),
), ),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
isExpanded: true,
value: _selectedProfession,
hint: const Text('Seleccione una profesión'),
items: _filteredProfessions
?.map((String profession) {
return DropdownMenuItem<String>(
value: profession,
child: Text(profession),
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
_selectedProfession = newValue;
});
},
),
),
)
: Container(),
_selectedProfession != null
? TextField(
controller: _searchController,
onChanged: (value) {
setState(() {
_searchController.text = value;
});
},
decoration: const InputDecoration(
hintText: 'Busca un profesional',
prefixIcon: Icon(Icons.search),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.grey),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.grey),
), ),
), ),
child: DropdownButtonHideUnderline( )
child: DropdownButton<String>( : Container(),
isExpanded: true,
value: _selectedProfession,
hint: const Text('Seleccione una profesión'),
items:
_filteredProfessions?.map((String profession) {
return DropdownMenuItem<String>(
value: profession,
child: Text(profession),
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
_selectedProfession = newValue;
});
},
),
),
),
TextField(
controller: _searchController,
onChanged: (value) {
setState(() {
_searchController.text = value;
});
},
decoration: const InputDecoration(
hintText: 'Busca un profesional',
prefixIcon: Icon(Icons.search),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.grey),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.grey),
),
),
),
Expanded( Expanded(
child: _body(state), child: _selectedProfession != null
? _body(state)
: const Center(
child: Text(
'Agrega los filtros para ver los profesionales'),
),
), ),
], ],
), ),
@@ -151,6 +160,8 @@ class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
.contains(removeDiacritics(_searchController.text.toLowerCase()))) .contains(removeDiacritics(_searchController.text.toLowerCase())))
.where((user) => .where((user) =>
user.myUser.id != FirebaseAuth.instance.currentUser!.uid) user.myUser.id != FirebaseAuth.instance.currentUser!.uid)
.where(
(user) => user.professionalInfo.profession == _selectedProfession)
.toList(); .toList();
// } else { // } else {
// filteredUsers = state.users // filteredUsers = state.users
@@ -160,7 +171,7 @@ class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
if (filteredUsers.isEmpty) { if (filteredUsers.isEmpty) {
return const Center( return const Center(
child: Text('No hay profesionales'), child: Text('Ningun profesional coincide con la busqueda'),
); );
} }