Untitled
user_5465063857
dart
2 years ago
6.0 kB
4
Indexable
import 'package:flutter/material.dart'; import 'package:flutter_foro/src/models/asistentes_model.dart'; import 'package:flutter_foro/src/providers/asistentes_provider.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; class ListaAsistentesAppState extends StatelessWidget { const ListaAsistentesAppState({Key? key}) : super(key: key); @override Widget build(BuildContext context) { Map? parametros = ModalRoute.of(context)!.settings.arguments as Map?; final idSede = parametros?['idSede'] ?? 0; return MultiProvider( providers: [ ChangeNotifierProvider( create: (_) => AsistentesProvider(), lazy: false, ) ], child: ListaAsistentes(idSede: idSede), ); } } class ListaAsistentes extends StatefulWidget { final int idSede; const ListaAsistentes({Key? key, required this.idSede}) : super(key: key); @override State<ListaAsistentes> createState() => _ListaAsistentesState(); } class _ListaAsistentesState extends State<ListaAsistentes> { Widget customSearchBar = const Text('Registro'); int ast = 0; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: const Color(0xFFFAFAFA), resizeToAvoidBottomInset: false, appBar: AppBar( title: customSearchBar, automaticallyImplyLeading: true, centerTitle: true, backgroundColor: const Color(0xFF5c6bc0), elevation: 0, toolbarHeight: 60, ), body: BusquedaListado(idSede: widget.idSede), /*persistentFooterButtons: [ Container( color: Colors.black87, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Padding( padding: EdgeInsets.fromLTRB(20, 10, 20, 10), child: Text( 'Asistentes Registrados', style: TextStyle(color: Colors.white, fontSize: 16), ), ), Padding( padding: const EdgeInsets.fromLTRB(20, 10, 20, 10), child: Text(ast.toString(), style: const TextStyle(color: Colors.white, fontSize: 22)), ) ], ), ), ],*/ ); } } class BusquedaListado extends StatefulWidget { final int idSede; const BusquedaListado({Key? key, required this.idSede}) : super(key: key); @override State<BusquedaListado> createState() => _BusquedaListadoState(); } class _BusquedaListadoState extends State<BusquedaListado> { //final items = List<String>.generate(25, (i) => "Item $i"); @override Widget build(BuildContext context) { final asisProvider = Provider.of<AsistentesProvider>(context); final size = MediaQuery.of(context).size; return FutureBuilder( future: asisProvider.resultsAsistentes(widget.idSede), builder: (_, AsyncSnapshot<List<Result>> snapshot) { if (!snapshot.hasData) { return SizedBox( width: double.infinity, height: size.height * 0.5, child: const Center( child: CircularProgressIndicator(), ), ); } final List<Result> asdata = snapshot.data!; /*WidgetsBinding.instance.addPostFrameCallback((timeStamp) { setState(() { ListaAsistentes }); });*/ return Column( children: <Widget>[ /*Padding( padding: const EdgeInsets.all(8.0), child: TextField( onChanged: (value) {}, decoration: const InputDecoration( labelText: "Buscar", hintText: "Buscar", prefixIcon: Icon(Icons.search), border: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(5.0)))), ), ),*/ Expanded( child: ListView.separated( shrinkWrap: true, itemCount: asdata.length, itemBuilder: (BuildContext context, int index) => Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.fromLTRB(20, 10, 0, 10), child: Text( asdata[index].nombre.toString() + ' ' + asdata[index].apellidos.toString(), style: const TextStyle( fontSize: 14, color: Color(0xFF757575))), ), Padding( padding: const EdgeInsets.fromLTRB(0, 10, 20, 10), child: Container( color: const Color(0xFF2fc298), width: 35.0, height: 35.0, child: TextButton( onPressed: () { Navigator.pushNamed(context, 'asignacodigo', arguments: {'idsus': asdata[index].idsus}); }, child: const Icon( FontAwesomeIcons.plus, color: Colors.white, size: 15.0, )), ), ) ], ), separatorBuilder: (BuildContext context, int index) => const Divider(color: Colors.black12), ), ), ], ); }); } }