diff --git a/lib/screens/chat/chat_screen.dart b/lib/screens/chat/chat_screen.dart index f176a0a..924c24f 100644 --- a/lib/screens/chat/chat_screen.dart +++ b/lib/screens/chat/chat_screen.dart @@ -367,9 +367,9 @@ class _ChatScreenState extends State { Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Text( - DateFormat('h:mm a').format(e.createdAt), + _getFechaHoraFormateada(e.createdAt), style: - const TextStyle(color: Colors.grey, fontSize: 12), + const TextStyle(color: Colors.grey, fontSize: 11), ), ), ], @@ -403,10 +403,10 @@ class _ChatScreenState extends State { Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Text( - DateFormat('h:mm a').format(e.createdAt), + _getFechaHoraFormateada(e.createdAt), style: const TextStyle( color: Colors.grey, - fontSize: 12, + fontSize: 11, ), ), ), @@ -417,7 +417,26 @@ class _ChatScreenState extends State { .toList(); } - Future> _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> _getUserAndProfessionalInfo( + ServiceEntity service) async { final userRepo = FirebaseUserRepository(FirebaseAuth.instance); final MyUser? userInfo; diff --git a/lib/screens/lists/professional_list_screen.dart b/lib/screens/lists/professional_list_screen.dart index acf4066..b227ea5 100644 --- a/lib/screens/lists/professional_list_screen.dart +++ b/lib/screens/lists/professional_list_screen.dart @@ -81,55 +81,64 @@ class _ProfessionalListScreenState extends State { children: [ _isLoading ? _buildShimmerEffect() - : Container( - padding: const EdgeInsets.symmetric(horizontal: 20), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: Colors.grey[400]!, + : _selectedProfession == null + ? Container( + padding: const EdgeInsets.symmetric(horizontal: 20), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Colors.grey[400]!, + ), + ), ), + child: DropdownButtonHideUnderline( + child: DropdownButton( + isExpanded: true, + value: _selectedProfession, + hint: const Text('Seleccione una profesión'), + items: _filteredProfessions + ?.map((String profession) { + return DropdownMenuItem( + 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( - isExpanded: true, - value: _selectedProfession, - hint: const Text('Seleccione una profesión'), - items: - _filteredProfessions?.map((String profession) { - return DropdownMenuItem( - 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), - ), - ), - ), + ) + : Container(), 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 { .contains(removeDiacritics(_searchController.text.toLowerCase()))) .where((user) => user.myUser.id != FirebaseAuth.instance.currentUser!.uid) + .where( + (user) => user.professionalInfo.profession == _selectedProfession) .toList(); // } else { // filteredUsers = state.users @@ -160,7 +171,7 @@ class _ProfessionalListScreenState extends State { if (filteredUsers.isEmpty) { return const Center( - child: Text('No hay profesionales'), + child: Text('Ningun profesional coincide con la busqueda'), ); }