info pro
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:city_repository/city_repository.dart';
|
||||
import 'package:injector/injector.dart';
|
||||
import 'package:intl_phone_field/helpers.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
class CityListScreen extends StatefulWidget {
|
||||
const CityListScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<CityListScreen> createState() => _CityListScreenState();
|
||||
}
|
||||
|
||||
class _CityListScreenState extends State<CityListScreen> {
|
||||
final _searchController = TextEditingController();
|
||||
final cityRepository = Injector.appInstance.get<CityRepository>();
|
||||
List<CityUi>? _cities;
|
||||
List<CityUi>? _filteredCities;
|
||||
bool _isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadCities();
|
||||
}
|
||||
|
||||
void _loadCities() {
|
||||
cityRepository.getCities().then((List<CityUi> element) {
|
||||
setState(() {
|
||||
_cities = element;
|
||||
_filteredCities = _cities;
|
||||
_isLoading = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Ciudad'),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
TextField(
|
||||
controller: _searchController,
|
||||
onChanged: (value) {
|
||||
_filterCities(value);
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Busca una ciudad',
|
||||
prefixIcon: Icon(Icons.search),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.grey),
|
||||
),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
),
|
||||
_isLoading
|
||||
? _buildShimmerEffect()
|
||||
: Expanded(
|
||||
child: _filteredCities != null && _filteredCities!.isNotEmpty
|
||||
? ListView.builder(
|
||||
itemCount: _filteredCities!.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: Colors.grey.withOpacity(0.2)),
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
_filteredCities![index].cityName,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
"${_filteredCities![index].stateOfCity}, ${_filteredCities![index].countryOfCity}",
|
||||
style: const TextStyle(color: Colors.black54),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(context,
|
||||
_filteredCities![index].cityName);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
: const Center(
|
||||
child: Text('No se encontraron coincidencias'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _filterCities(String query) {
|
||||
if (_cities != null) {
|
||||
setState(() {
|
||||
_filteredCities = _cities!
|
||||
.where((city) => removeDiacritics(city.cityName.toLowerCase())
|
||||
.contains(removeDiacritics(query.toLowerCase())))
|
||||
.toList();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildShimmerEffect() {
|
||||
return Expanded(
|
||||
child: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: ListView.builder(
|
||||
itemCount: 8,
|
||||
itemBuilder: (_, __) => const ListTileShimmer(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ListTileShimmer extends StatelessWidget {
|
||||
const ListTileShimmer({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey.withOpacity(0.4)),
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
title: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.8,
|
||||
height: 20.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
subtitle: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.3,
|
||||
height: 15.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.3,
|
||||
height: 15.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:injector/injector.dart';
|
||||
import 'package:intl_phone_field/helpers.dart';
|
||||
import 'package:profession_repository/profession_repository.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
class ProfessionListScreen extends StatefulWidget {
|
||||
const ProfessionListScreen({super.key});
|
||||
|
||||
@override
|
||||
State<ProfessionListScreen> createState() => _ProfessionListScreenState();
|
||||
}
|
||||
|
||||
class _ProfessionListScreenState extends State<ProfessionListScreen> {
|
||||
final _searchController = TextEditingController();
|
||||
final professionRepository = Injector.appInstance.get<ProfessionRepository>();
|
||||
List<String>? _professions;
|
||||
List<String>? _filteredProfessions;
|
||||
bool _isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadProfessions();
|
||||
}
|
||||
|
||||
void _loadProfessions() {
|
||||
professionRepository.getProfessions().then((Professions element) {
|
||||
setState(() {
|
||||
_professions = element.professions;
|
||||
_filteredProfessions = _professions;
|
||||
_isLoading = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void _filterProfessions(String query) {
|
||||
if (_professions != null) {
|
||||
setState(() {
|
||||
_filteredProfessions = _professions!
|
||||
.where((profession) => removeDiacritics(profession.toLowerCase())
|
||||
.contains(removeDiacritics(query.toLowerCase())))
|
||||
.toList();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Profesiones'),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
TextField(
|
||||
controller: _searchController,
|
||||
onChanged: (value) {
|
||||
_filterProfessions(value);
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Busca una profesión',
|
||||
prefixIcon: Icon(Icons.search),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.grey),
|
||||
),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
),
|
||||
_isLoading
|
||||
? _buildShimmerEffect()
|
||||
: Expanded(
|
||||
child: _filteredProfessions != null &&
|
||||
_filteredProfessions!.isNotEmpty
|
||||
? ListView.builder(
|
||||
itemCount: _filteredProfessions!.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final profession = _filteredProfessions![index];
|
||||
return ListTile(
|
||||
title: Text(profession),
|
||||
onTap: () {
|
||||
Navigator.pop(
|
||||
context, _filteredProfessions![index]);
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
: const Center(
|
||||
child: Text('No se encontraron coincidencias'),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildShimmerEffect() {
|
||||
return Expanded(
|
||||
child: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: ListView.builder(
|
||||
itemCount: 8,
|
||||
itemBuilder: (_, __) => const ListTileShimmer(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ListTileShimmer extends StatelessWidget {
|
||||
const ListTileShimmer({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey.withOpacity(0.4)),
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
title: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.8,
|
||||
height: 20.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
subtitle: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.3,
|
||||
height: 15.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.3,
|
||||
height: 15.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:injector/injector.dart';
|
||||
import 'package:intl_phone_field/helpers.dart';
|
||||
import 'package:professional_repository/professional_repository.dart';
|
||||
import 'package:prosappco/blocs/professional_list_bloc/professional_list_bloc.dart';
|
||||
import 'package:prosappco/screens/user/user_view_profile_screen.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
class ProfessionalListScreen extends StatefulWidget {
|
||||
const ProfessionalListScreen({super.key});
|
||||
|
||||
@override
|
||||
State<ProfessionalListScreen> createState() => _ProfessionalListScreenState();
|
||||
}
|
||||
|
||||
class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
|
||||
final _searchController = TextEditingController();
|
||||
late final ProfessionalListBloc bloc;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
bloc = Injector.appInstance.get<ProfessionalListBloc>();
|
||||
bloc.add(const ProfessionalListFetch());
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<ProfessionalListBloc>(
|
||||
create: (context) => bloc,
|
||||
child: BlocBuilder<ProfessionalListBloc, ProfessionalListState>(
|
||||
builder: (context, state) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Selecciona un profesional'),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
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(
|
||||
child: _body(state),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_body(ProfessionalListState state) {
|
||||
if (state is ProfessionalListSuccess) {
|
||||
final List<UserProfessional> filteredUsers;
|
||||
// filtrar por nombre
|
||||
if (_searchController.text.isNotEmpty) {
|
||||
filteredUsers = state.users
|
||||
.where((element) => removeDiacritics(element.myUser.name!)
|
||||
.toLowerCase()
|
||||
.contains(
|
||||
removeDiacritics(_searchController.text.toLowerCase())))
|
||||
.toList();
|
||||
} else {
|
||||
filteredUsers = state.users;
|
||||
}
|
||||
|
||||
if (filteredUsers.isEmpty) {
|
||||
return const Center(
|
||||
child: Text('No hay profesionales'),
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: filteredUsers.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey.withOpacity(0.2)),
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
onTap: () {},
|
||||
trailing: GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => UserViewProfileScreen(
|
||||
userProfessional: filteredUsers[index],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: filteredUsers[index].professionalInfo.rate.isEmpty
|
||||
? const Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
color: Colors.black,
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
const SizedBox(height: 5),
|
||||
const Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
color: Colors.black,
|
||||
),
|
||||
Container(
|
||||
//fondo azul
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue[200],
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6, vertical: 2),
|
||||
child: Text(
|
||||
'\$${filteredUsers[index].professionalInfo.rate}',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
leading: Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade300,
|
||||
shape: BoxShape.circle,
|
||||
image: filteredUsers[index].myUser.picture == null
|
||||
? null
|
||||
: DecorationImage(
|
||||
image: NetworkImage(
|
||||
filteredUsers[index].myUser.picture ?? ''),
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
child: filteredUsers[index].myUser.picture == null
|
||||
? Icon(
|
||||
CupertinoIcons.person,
|
||||
color: Colors.grey.shade400,
|
||||
size: 40,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
title: Text(
|
||||
'${filteredUsers[index].myUser.name ?? ''}, ${filteredUsers[index].professionalInfo.profession}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
_disponibilidad(filteredUsers[index].professionalInfo),
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.blue,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: ListView.builder(
|
||||
itemCount: 8,
|
||||
itemBuilder: (_, __) => Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey.withOpacity(0.4)),
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
trailing: const Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
color: Colors.black,
|
||||
),
|
||||
leading: Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade300,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
title: Container(
|
||||
width: MediaQuery.of(context).size.width * 0.8,
|
||||
height: 20.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
subtitle: Container(
|
||||
width: MediaQuery.of(context).size.width * 0.3,
|
||||
height: 15.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _disponibilidad(ProfessionalEntity professionalInfo) {
|
||||
if (professionalInfo.locationPreferences == LocationPreferences.office) {
|
||||
return 'Disponibilidad: en sitio.';
|
||||
}
|
||||
|
||||
if (professionalInfo.locationPreferences == LocationPreferences.delivery) {
|
||||
return 'Disponibilidad: domicilio.';
|
||||
}
|
||||
|
||||
return 'Disponibilidad: domicilio, en sitio.';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user