update faltan los ifs
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:injector/injector.dart';
|
||||
import 'package:profession_repository/profession_repository.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
class DropdownListScreen extends StatefulWidget {
|
||||
const DropdownListScreen({super.key});
|
||||
|
||||
@override
|
||||
State<DropdownListScreen> createState() => _DropdownListScreenState();
|
||||
}
|
||||
|
||||
class _DropdownListScreenState extends State<DropdownListScreen> {
|
||||
final professionRepository = Injector.appInstance.get<ProfessionRepository>();
|
||||
List<String>? _professions;
|
||||
List<String>? _filteredProfessions;
|
||||
String? _selectedProfession;
|
||||
bool _isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadProfessions();
|
||||
}
|
||||
|
||||
void _loadProfessions() {
|
||||
professionRepository.getProfessions().then((Professions element) {
|
||||
setState(() {
|
||||
_professions = element.professions;
|
||||
_filteredProfessions = _professions;
|
||||
_isLoading = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Profesiones'),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_isLoading
|
||||
? _buildShimmerEffect()
|
||||
: Expanded(
|
||||
child: _filteredProfessions != null &&
|
||||
_filteredProfessions!.isNotEmpty
|
||||
? 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;
|
||||
});
|
||||
},
|
||||
)
|
||||
: 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),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,10 @@ 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:profession_repository/profession_repository.dart';
|
||||
import 'package:professional_repository/professional_repository.dart';
|
||||
import 'package:prosappco/blocs/professional_list_bloc/professional_list_bloc.dart';
|
||||
import 'package:prosappco/screens/lists/city_list_screen.dart';
|
||||
import 'package:prosappco/screens/user/user_calendar_screen.dart';
|
||||
import 'package:prosappco/screens/user/user_view_profile_screen.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
@@ -19,6 +21,13 @@ class ProfessionalListScreen extends StatefulWidget {
|
||||
|
||||
class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
|
||||
final _searchController = TextEditingController();
|
||||
final professionRepository = Injector.appInstance.get<ProfessionRepository>();
|
||||
List<String>? _professions;
|
||||
List<String>? _filteredProfessions;
|
||||
String? _selectedProfession;
|
||||
|
||||
bool _isLoading = true;
|
||||
|
||||
late final ProfessionalListBloc bloc;
|
||||
|
||||
@override
|
||||
@@ -26,6 +35,18 @@ class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
|
||||
super.initState();
|
||||
bloc = Injector.appInstance.get<ProfessionalListBloc>();
|
||||
bloc.add(const ProfessionalListFetch());
|
||||
|
||||
_loadProfessions();
|
||||
}
|
||||
|
||||
void _loadProfessions() {
|
||||
professionRepository.getProfessions().then((Professions element) {
|
||||
setState(() {
|
||||
_professions = element.professions;
|
||||
_filteredProfessions = _professions;
|
||||
_isLoading = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -36,10 +57,59 @@ class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
|
||||
builder: (context, state) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Selecciona un profesional'),
|
||||
actions: [
|
||||
_selectedProfession != null
|
||||
? IconButton(
|
||||
icon: const Icon(
|
||||
Icons.clear,
|
||||
color: Colors.red,
|
||||
size: 32,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_selectedProfession = null;
|
||||
});
|
||||
},
|
||||
)
|
||||
: Container()
|
||||
],
|
||||
title: _selectedProfession != null
|
||||
? Text(_selectedProfession!)
|
||||
: const Text('Selecciona un profesional'),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_isLoading
|
||||
? _buildShimmerEffect()
|
||||
: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
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;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
controller: _searchController,
|
||||
onChanged: (value) {
|
||||
@@ -267,4 +337,17 @@ class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
|
||||
|
||||
return 'Disponibilidad: domicilio, en sitio.';
|
||||
}
|
||||
|
||||
Widget _buildShimmerEffect() {
|
||||
return Expanded(
|
||||
child: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: ListView.builder(
|
||||
itemCount: 8,
|
||||
itemBuilder: (_, __) => const ListTileShimmer(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user