You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
3.3 KiB
Dart
96 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
import 'package:test_sa/models/visits/visit.dart';
|
|
import 'package:test_sa/views/widgets/loaders/lazy_loading.dart';
|
|
import 'package:test_sa/views/widgets/loaders/no_item_found.dart';
|
|
import 'package:test_sa/views/widgets/visits/visit_item.dart';
|
|
|
|
import '../../../controllers/providers/api/user_provider.dart';
|
|
|
|
class VisitsList extends StatefulWidget {
|
|
final List<Visit> visits;
|
|
final bool nextPage;
|
|
final Future<void> Function() onLazyLoad;
|
|
final Function(List<Visit>) onEditGroup;
|
|
|
|
const VisitsList({Key key, this.visits, this.nextPage, this.onLazyLoad, this.onEditGroup}) : super(key: key);
|
|
|
|
@override
|
|
_VisitsListState createState() => _VisitsListState();
|
|
}
|
|
|
|
class _VisitsListState extends State<VisitsList> {
|
|
final List<Visit> _selectedVisits = [];
|
|
|
|
@override
|
|
void initState() {
|
|
_selectedVisits.clear();
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
UserProvider userProvider = Provider.of<UserProvider>(context);
|
|
if (widget.visits.isEmpty) {
|
|
return NoItemFound(message: context.translation.noVisitsFound);
|
|
}
|
|
return Stack(
|
|
children: [
|
|
LazyLoading(
|
|
nextPage: widget.nextPage,
|
|
onLazyLoad: widget.onLazyLoad,
|
|
child: ListView.builder(
|
|
itemCount: widget.visits.length,
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
itemBuilder: (context, itemIndex) {
|
|
Visit visit = widget.visits[itemIndex];
|
|
// bool isSelected = _selectedVisits.contains(visit);
|
|
return VisitItem(visit: visit);
|
|
},
|
|
),
|
|
),
|
|
// Align(
|
|
// alignment: Alignment.bottomLeft,
|
|
// child: Padding(
|
|
// padding: EdgeInsets.all(8.0 * AppStyle.getScaleFactor(context)),
|
|
// child: AnimatedSwitcher(
|
|
// duration: const Duration(milliseconds: 400),
|
|
// child: Visibility(
|
|
// key: ValueKey(_selectedVisits.isNotEmpty),
|
|
// visible: _selectedVisits.isNotEmpty,
|
|
// child: Row(
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
// children: [
|
|
// FloatingActionButton(
|
|
// heroTag: "cancel",
|
|
// child: const Icon(Icons.cancel),
|
|
// onPressed: () {
|
|
// _selectedVisits.clear();
|
|
// setState(() {});
|
|
// },
|
|
// ),
|
|
// FloatingActionButton(
|
|
// heroTag: "edit",
|
|
// child: const Icon(Icons.edit),
|
|
// onPressed: () {
|
|
// if (!widget.visits.contains(_selectedVisits.first)) {
|
|
// _selectedVisits.clear();
|
|
// setState(() {});
|
|
// return;
|
|
// }
|
|
// widget.onEditGroup(_selectedVisits);
|
|
// //_selectedVisits.clear();
|
|
// },
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// ),
|
|
// ),
|
|
// )
|
|
],
|
|
);
|
|
}
|
|
}
|